/* Sukhija CRM — mobile-first app styles */
:root {
	color-scheme: light;
	--brand: #1f4e79;
	--brand-ink: #ffffff;
	--bg: #f4f5f7;
	--surface: #ffffff;
	--surface-2: #f6f7f9;
	--surface-3: #eceef1;
	--border: #e2e4e8;
	--border-strong: #cfd3d9;
	--text: #14171c;
	--text-2: #4d5562;
	--muted: #858c97;
	--focus: #2a78d6;
	--good: #0a8a0a;
	--good-bg: #e7f6e7;
	--warn: #b77900;
	--warn-bg: #fff4dc;
	--bad: #c93434;
	--bad-bg: #fdecec;
	--info-bg: #e9f1fc;
	--shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
	--shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
	--radius: 12px;
	--radius-sm: 8px;
	--nav-h: 64px;
	--top-h: 56px;
	--side-w: 236px;
	/* charts (validated categorical + chrome) */
	--chart-surface: #fcfcfb;
	--grid: #e1e0d9;
	--axis: #c3c2b7;
	--s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
	--s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
	:root {
		color-scheme: dark;
		--bg: #0f1012;
		--surface: #1a1b1e;
		--surface-2: #212226;
		--surface-3: #2a2b30;
		--border: #2e3036;
		--border-strong: #3c3f46;
		--text: #f0efec;
		--text-2: #c3c2b7;
		--muted: #898781;
		--good: #3cc23c;
		--good-bg: #12301a;
		--warn: #f2b33a;
		--warn-bg: #33270c;
		--bad: #ef6b6b;
		--bad-bg: #3a1717;
		--info-bg: #172538;
		--shadow: 0 1px 2px rgba(0, 0, 0, .4);
		--shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
		--chart-surface: #1a1a19;
		--grid: #2c2c2a;
		--axis: #383835;
		--s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
		--s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
	}
}

*, *::before, *::after { box-sizing: border-box; }
svg[aria-hidden="true"] { width: 20px; height: 20px; flex: none; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.45 var(--font);
	-webkit-font-smoothing: antialiased;
	overscroll-behavior-y: none;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
@media (prefers-color-scheme: dark) { a { color: #7fb2ec; } }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 10px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.mt { margin-top: 12px; } .mt-lg { margin-top: 20px; } .mb { margin-bottom: 12px; }
@media (max-width: 899.98px) { .hide-mobile { display: none !important; } }
@media (min-width: 900px) { .hide-desktop { display: none !important; } }

/* ---------- Boot / spinner ---------- */
.boot { min-height: 100vh; display: flex; gap: 12px; align-items: center; justify-content: center; color: var(--muted); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--border-strong); border-top-color: var(--brand); animation: spin .8s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { padding: 48px 16px; display: flex; justify-content: center; }

/* ---------- Layout ---------- */
.shell { min-height: 100vh; }
.topbar {
	position: sticky; top: 0; z-index: 30;
	height: calc(var(--top-h) + env(safe-area-inset-top));
	padding: env(safe-area-inset-top) 8px 0 16px;
	display: flex; align-items: center; gap: 4px;
	background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .brand-mark { margin-right: 8px; }
.main { min-width: 0; padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 1320px; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.page-head h1 { flex: 1 1 auto; }
.page-head .count { color: var(--muted); font-weight: 500; font-size: 15px; margin-left: 6px; }

.bottomnav {
	position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
	height: calc(var(--nav-h) + env(safe-area-inset-bottom));
	padding-bottom: env(safe-area-inset-bottom);
	display: grid; grid-template-columns: repeat(5, 1fr);
	background: var(--surface); border-top: 1px solid var(--border);
}
.bottomnav a, .bottomnav button {
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
	font-size: 11.5px; font-weight: 550; color: var(--muted); background: none; border: 0; text-decoration: none; position: relative; cursor: pointer;
}
.bottomnav .on { color: var(--brand); }
@media (prefers-color-scheme: dark) { .bottomnav .on { color: #7fb2ec; } }
.bottomnav svg { width: 23px; height: 23px; }
.nav-badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

.sidebar { display: none; }
@media (min-width: 900px) {
	.bottomnav { display: none; }
	.sidebar {
		display: flex; flex-direction: column;
		position: fixed; top: 0; bottom: 0; left: 0; width: var(--side-w); z-index: 35;
		background: var(--surface); border-right: 1px solid var(--border); padding: 14px 10px;
	}
	.shell { padding-left: var(--side-w); }
	.topbar { padding-left: 24px; }
	.topbar .brand-mark, .topbar .menu-btn { display: none; }
	.main { min-width: 0; padding: 24px 28px 48px; }
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.side-brand .name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.side-brand .sub { font-size: 12px; color: var(--muted); }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-nav a {
	display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px;
	color: var(--text-2); font-weight: 550; text-decoration: none; position: relative;
}
.side-nav a:hover { background: var(--surface-2); }
.side-nav a.on { background: var(--surface-3); color: var(--text); }
.side-nav a.on::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.side-nav svg { width: 19px; height: 19px; flex: none; }
.side-nav .badge { margin-left: auto; }
.side-sep { height: 1px; background: var(--border); margin: 10px 8px; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 10px 4px; font-weight: 650; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 10px 8px 2px; border-top: 1px solid var(--border); margin-top: 8px; }
.side-user .who { flex: 1; min-width: 0; }
.side-user .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.brand-mark {
	width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: var(--brand-ink);
	display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px; flex: none;
}

/* ---------- Buttons ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 7px;
	min-height: 40px; padding: 0 14px; border-radius: 9px;
	border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
	font-weight: 600; font-size: 14.5px; cursor: pointer; text-decoration: none; white-space: nowrap;
	transition: background .12s, border-color .12s, transform .05s;
	-webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand); filter: brightness(1.08); }
.btn-danger { color: var(--bad); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: var(--bad); filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13.5px; border-radius: 8px; }
.btn-lg { min-height: 48px; font-size: 16px; }
.btn-block { width: 100%; }
.icon-btn {
	width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--text-2);
	display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 21px; height: 21px; }
.btn-call { background: var(--good-bg); color: var(--good); border-color: transparent; }
.btn-wa { background: #e5f7ec; color: #128c4a; border-color: transparent; }
@media (prefers-color-scheme: dark) { .btn-wa { background: #10301f; color: #3fd27f; } }
.fab {
	position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 38;
	width: 56px; height: 56px; border-radius: 16px; border: 0; background: var(--brand); color: var(--brand-ink);
	box-shadow: var(--shadow-lg); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.fab svg { width: 26px; height: 26px; }
@media (min-width: 900px) { .fab { display: none; } }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; flex-wrap: wrap; }
.card-head h2 { flex: 1 1 auto; font-size: 15.5px; }
.card-body { padding: 4px 16px 16px; }
.card + .card { margin-top: 14px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 0 0 8px; }
.grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
@media (min-width: 900px) {
	.grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
	.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.grid-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; }
	.span-2 { grid-column: span 2; }
}

/* ---------- Pills / badges ---------- */
.pill {
	display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 12px;
	background: var(--surface-3); color: var(--text); font-size: 12.5px; font-weight: 600; white-space: nowrap; max-width: 100%;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pill-tint { background: color-mix(in srgb, var(--c, #888) 14%, var(--surface)); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 700; }
.badge-bad { background: var(--bad); color: #fff; }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-good { background: var(--good-bg); color: var(--good); }
.tag-hot { color: #c93434; } .tag-warm { color: #b77900; } .tag-cold { color: #2a78d6; }
.avatar {
	width: 32px; height: 32px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
	font-size: 12.5px; font-weight: 700; color: #fff; background: var(--c, #6b7280); letter-spacing: .02em;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10.5px; }
.avatar-lg { width: 48px; height: 48px; font-size: 17px; }

/* ---------- Forms ---------- */
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld > span:first-child, .fld-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.fld .req { color: var(--bad); }
.fld .hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.input, .fld input:not([type=checkbox]):not([type=radio]):not([type=color]), .fld select, .fld textarea, select.input {
	width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 9px;
	border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
	font-size: 16px; line-height: 1.3; outline: none; transition: border-color .12s, box-shadow .12s;
}
.fld textarea { min-height: 88px; resize: vertical; }
.input:focus, .fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
@media (min-width: 900px) { .input, .fld input:not([type=checkbox]):not([type=radio]):not([type=color]), .fld select, .fld textarea, select.input { font-size: 14.5px; min-height: 40px; } }
select.input, .fld select { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23858c97' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }
.form-section { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 8px 0 -4px; grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14.5px; }
.check input { width: 19px; height: 19px; accent-color: var(--brand); flex: none; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 64px !important; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--brand); font-weight: 600; font-size: 13px; padding: 6px 8px; cursor: pointer; }
.error-text { color: var(--bad); font-size: 13px; }
.notice { padding: 10px 12px; border-radius: 9px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.notice-warn { background: var(--warn-bg); color: var(--warn); }
.notice-bad { background: var(--bad-bg); color: var(--bad); }
.notice-info { background: var(--info-bg); color: var(--text); }
.notice-good { background: var(--good-bg); color: var(--good); }

/* chips (multi select + quick choices) */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
	display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 17px;
	border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: 13.5px; font-weight: 550; cursor: pointer; white-space: nowrap;
	-webkit-tap-highlight-color: transparent;
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip .x { opacity: .7; margin-left: 2px; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip-scroll { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chip-scroll::-webkit-scrollbar { display: none; }
@media (min-width: 900px) { .chip-scroll { margin: 0; padding-left: 0; padding-right: 0; flex-wrap: wrap; } }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13.5px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Search ---------- */
.search { position: relative; flex: 1 1 220px; min-width: 0; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; min-height: 42px; padding: 8px 12px 8px 38px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 16px; outline: none; }
.search input:focus { border-color: var(--focus); }
@media (min-width: 900px) { .search input { font-size: 14.5px; min-height: 40px; } }

/* ---------- Lists / tables ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); align-items: flex-start; color: inherit; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item .title { font-weight: 650; }
.list-item .meta { font-size: 13px; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; }
.list-item > svg { color: var(--muted); align-self: center; width: 18px; height: 18px; }
.list-item .acts { display: flex; gap: 6px; flex: none; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl tr.sel td { background: color-mix(in srgb, var(--brand) 7%, var(--surface)); }
.tbl .r { text-align: right; }
.tbl tfoot td { font-weight: 700; border-bottom: 0; border-top: 1px solid var(--border-strong); }
.tbl .th-sort { cursor: pointer; user-select: none; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty svg { width: 36px; height: 36px; margin-bottom: 8px; opacity: .6; }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.load-more { display: flex; justify-content: center; padding: 14px; }

.bulkbar {
	position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top)); z-index: 25; margin: 0 0 10px;
	display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 10px;
	background: var(--text); color: var(--bg);
}
.bulkbar .btn { min-height: 34px; background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 35%, transparent); }
.bulkbar select { min-height: 34px; border-radius: 8px; background: var(--surface); color: var(--text); border: 0; padding: 0 8px; font-size: 14px; }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10, 12, 16, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet {
	background: var(--surface); width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column;
	box-shadow: var(--shadow-lg); animation: up .2s ease; padding-bottom: env(safe-area-inset-bottom);
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.sheet-full { height: 100%; max-height: 100%; border-radius: 0; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px 18px; border-bottom: 1px solid var(--border); flex: none; }
.sheet-head h2 { flex: 1; font-size: 17px; }
.sheet-body { padding: 16px 18px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); flex: none; justify-content: flex-end; flex-wrap: wrap; }
.sheet-foot .btn { flex: 1 1 auto; }
@media (min-width: 700px) {
	.overlay { align-items: center; padding: 24px; }
	.sheet, .sheet-full { width: 100%; max-width: 560px; height: auto; max-height: 88vh; border-radius: 14px; }
	.sheet.wide { max-width: 820px; }
	.sheet-foot .btn { flex: 0 0 auto; }
}
.grabber { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 8px auto 0; }
@media (min-width: 700px) { .grabber { display: none; } }
.menu { padding: 6px 0; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 12px; padding: 13px 18px; border: 0; background: none; text-align: left; font-size: 15.5px; color: var(--text); cursor: pointer; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu svg { width: 20px; height: 20px; color: var(--text-2); }
.menu .danger, .menu .danger svg { color: var(--bad); }
.menu .on { font-weight: 700; }

.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
@media (min-width: 900px) { .toasts { bottom: 24px; left: auto; right: 24px; transform: none; } }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14.5px; animation: up .2s ease; pointer-events: auto; display: flex; gap: 10px; align-items: center; }
.toast.err { background: var(--bad); color: #fff; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi {
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
	padding: 13px 14px 12px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; text-align: left; min-width: 0;
	transition: border-color .12s, transform .08s; color: inherit;
}
.kpi:hover { border-color: var(--border-strong); }
.kpi:active { transform: scale(.99); }
.kpi .k-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .k-label svg { width: 15px; height: 15px; color: var(--muted); }
.kpi .k-value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); min-height: 18px; }
.kpi .spark { margin-left: auto; width: 76px; height: 26px; flex: none; }
.kpi.hero { grid-column: span 2; background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 70%, #000)); color: #fff; border-color: transparent; }
.kpi.hero .k-label, .kpi.hero .k-label svg, .kpi.hero .k-foot { color: rgba(255,255,255,.8); }
.kpi.hero .k-value { font-size: 34px; }
@media (min-width: 1100px) { .kpi.hero .k-value { font-size: 40px; } }
.kpi.alert .k-value { color: var(--bad); }
.delta { font-weight: 700; font-size: 12px; display: inline-flex; align-items: center; gap: 2px; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); }
.kpi.hero .delta.up, .kpi.hero .delta.down { color: #fff; background: rgba(255,255,255,.16); padding: 1px 6px; border-radius: 6px; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { cursor: pointer; transition: opacity .1s; }
.chart .bar.dim { opacity: .35; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .bar-label { fill: var(--text-2); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip {
	position: absolute; z-index: 5; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border);
	box-shadow: var(--shadow-lg); border-radius: 9px; padding: 8px 10px; font-size: 12.5px; min-width: 120px; transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap;
}
.tooltip .tt-title { font-weight: 700; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.tooltip .tt-row .sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.tooltip .tt-hint { color: var(--muted); font-size: 11.5px; margin-top: 4px; }

.hbars { display: flex; flex-direction: column; gap: 4px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 7px 8px; margin: 0 -8px; border-radius: 8px; cursor: pointer; border: 0; background: none; text-align: left; color: inherit; width: calc(100% + 16px); }
.hbar:hover { background: var(--surface-2); }
.hbar .hb-label { font-size: 13.5px; font-weight: 550; display: flex; align-items: center; gap: 7px; min-width: 0; }
.hbar .hb-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .hb-val { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.hbar .hb-val small { font-weight: 500; color: var(--muted); margin-left: 6px; }
.hbar .hb-track { grid-column: 1 / -1; height: 8px; border-radius: 0 4px 4px 0; background: transparent; position: relative; }
.hbar .hb-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.stackbar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.stackbar > div { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

/* daily table */
.day-table td.clickable { cursor: pointer; }
.day-table td.clickable:hover { text-decoration: underline; }
.day-table td.zero { color: var(--muted); }
.day-table tr.today td:first-child { font-weight: 700; }

/* ---------- Detail pages ---------- */
.detail-head { display: flex; gap: 14px; align-items: flex-start; }
.detail-head h1 { font-size: 21px; word-break: break-word; }
.detail-sub { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.quick-acts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.quick-acts .btn { flex-direction: column; gap: 4px; min-height: 62px; font-size: 12.5px; padding: 6px 4px; white-space: normal; text-align: center; line-height: 1.15; }
.quick-acts .btn svg { width: 21px; height: 21px; }
@media (min-width: 900px) { .quick-acts { display: flex; flex-wrap: wrap; } .quick-acts .btn { flex-direction: row; min-height: 38px; font-size: 14px; padding: 0 14px; } .quick-acts .btn svg { width: 18px; height: 18px; } }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 9px 12px; font-size: 14.5px; }
.kv dt { color: var(--muted); font-size: 13.5px; }
.kv dd { margin: 0; word-break: break-word; }
.inline-select { border: 0; background: transparent; padding: 0; font-weight: 600; cursor: pointer; }
.status-select { position: relative; display: inline-flex; }
.status-select select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; font-size: 16px; }
.status-select .pill { height: 30px; padding: 0 12px; font-size: 13.5px; }
.status-select .pill svg { width: 14px; height: 14px; }

.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: 0; }
.tl-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: flex; align-items: center; justify-content: center; flex: none; }
.tl-icon svg { width: 16px; height: 16px; }
.tl-icon.call { background: var(--good-bg); color: var(--good); }
.tl-icon.whatsapp { background: #e5f7ec; color: #128c4a; }
.tl-icon.site_visit { background: #efeafd; color: #6250d6; }
.tl-icon.task { background: var(--warn-bg); color: var(--warn); }
.tl-icon.stage { background: var(--info-bg); color: var(--s1); }
.tl-main { flex: 1; min-width: 0; }
.tl-title { font-size: 14px; font-weight: 600; }
.tl-body { font-size: 14px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.tl-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task-check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); flex: none; cursor: pointer; display: flex; align-items: center; justify-content: center; margin-top: 1px; color: transparent; padding: 0; }
.task-check:hover { border-color: var(--good); color: var(--good); }
.task-check.done { background: var(--good); border-color: var(--good); color: #fff; }
.task-check svg { width: 14px; height: 14px; }
.due { font-size: 12.5px; font-weight: 600; }
.due.over { color: var(--bad); } .due.today { color: var(--warn); } .due.later { color: var(--text-2); }

/* stage progress */
.stages { display: flex; gap: 3px; margin: 14px 0 4px; }
.stages button { flex: 1; height: 8px; border: 0; padding: 0; border-radius: 4px; background: var(--surface-3); cursor: pointer; }
.stages button.done { background: var(--brand); opacity: .55; }
.stages button.cur { background: var(--brand); }
.stages.won button { background: var(--good); opacity: 1; }
.stages.lost button.cur { background: var(--bad); }

/* ---------- Pipeline board ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 16px 16px; margin: 0 -16px; -webkit-overflow-scrolling: touch; align-items: flex-start; }
@media (min-width: 900px) { .board { margin: 0 -28px; padding: 2px 28px 20px; scroll-snap-type: none; } }
.col { flex: 0 0 86vw; max-width: 330px; scroll-snap-align: start; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 210px); }
@media (min-width: 900px) { .col { flex: 0 0 280px; max-height: calc(100vh - 170px); } }
.col.drop { outline: 2px dashed var(--brand); outline-offset: -2px; background: color-mix(in srgb, var(--brand) 6%, var(--surface-2)); }
.col-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--border); }
.col-head .t { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.col-head .t .dot { width: 10px; height: 10px; border-radius: 3px; }
.col-head .s { font-size: 12.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 10px; }
.col-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 80px; }
.dcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 5px; }
.dcard:hover { border-color: var(--border-strong); }
.dcard[draggable=true] { cursor: grab; }
.dcard.dragging { opacity: .5; }
.dcard .t { font-weight: 650; font-size: 14px; line-height: 1.3; }
.dcard .v { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.dcard .m { font-size: 12.5px; color: var(--text-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dcard .foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.dcard .move { margin-left: auto; }

/* ---------- Settings ---------- */
.settings-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.settings-layout > * { min-width: 0; }
@media (min-width: 900px) { .settings-layout { grid-template-columns: 220px minmax(0, 1fr); align-items: start; } }
.subnav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 80px; }
.subnav a { padding: 9px 12px; border-radius: 8px; color: var(--text-2); font-weight: 550; text-decoration: none; }
.subnav a.on { background: var(--surface-3); color: var(--text); }
.opt-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.opt-row.archived .input { opacity: .55; text-decoration: line-through; }
.opt-row .opt-acts { grid-column: 3; display: flex; align-items: center; gap: 2px; justify-content: flex-end; margin-top: -4px; }
.opt-row .extras { grid-column: 3; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (min-width: 900px) { .opt-row { grid-template-columns: auto auto minmax(0, 1fr) auto auto; } .opt-row .extras, .opt-row .opt-acts { grid-column: auto; margin-top: 0; } .opt-row .extras { order: 4; } .opt-row .opt-acts { order: 5; } }
.order-btns { display: flex; flex-direction: column; }
.order-btns button { border: 0; background: none; color: var(--muted); padding: 0 4px; height: 20px; cursor: pointer; }
.order-btns button:hover { color: var(--text); }
.order-btns svg { width: 16px; height: 16px; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border-strong); padding: 0; overflow: hidden; cursor: pointer; flex: none; }
.swatch input { width: 44px; height: 44px; border: 0; padding: 0; margin: -7px; cursor: pointer; }
.usage { font-size: 12px; color: var(--muted); white-space: nowrap; }
.savebar { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px); z-index: 20; display: flex; gap: 10px; align-items: center; padding: 10px 12px 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); margin-top: 16px; }
@media (min-width: 900px) { .savebar { bottom: 16px; } }
.savebar .btn { min-height: 36px; }
.savebar .btn-ghost { color: var(--bg); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface-3); padding: 10px 12px; border-radius: 8px; overflow-x: auto; white-space: pre; display: block; }
.copyline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.copyline .code { min-width: 0; flex: 1 1 200px; }
.code { max-width: 100%; }
.stack > *, .fld > * { min-width: 0; max-width: 100%; }
.copyline .code { flex: 1; white-space: nowrap; padding: 9px 10px; }

/* ---------- Search overlay ---------- */
.search-pop { position: fixed; inset: 0; z-index: 120; background: var(--surface); display: flex; flex-direction: column; }
.search-pop .bar { display: flex; gap: 8px; align-items: center; padding: calc(env(safe-area-inset-top) + 10px) 10px 10px 12px; border-bottom: 1px solid var(--border); }
.search-pop .res { overflow-y: auto; flex: 1; }
@media (min-width: 900px) { .search-pop { inset: 60px auto auto 50%; transform: translateX(-50%); width: 640px; max-height: 70vh; border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); } .search-pop .bar { padding-top: 10px; } }

/* ---------- Login ---------- */
.login-body { min-height: 100vh; display: flex; background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent), var(--bg); }
.login-wrap { margin: auto; width: 100%; max-width: 420px; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 26px 22px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .brand-mark { width: 44px; height: 44px; font-size: 21px; border-radius: 12px; }
.login-company { font-weight: 700; font-size: 17px; }
.login-sub { color: var(--muted); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; font-weight: 650; }
.login-title { font-size: 22px; margin-bottom: 16px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-error { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 9px; font-size: 14px; margin-bottom: 14px; }
.login-forgot { display: block; text-align: center; margin-top: 16px; font-weight: 600; font-size: 14px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 16px; }

/* misc */
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.link-btn { border: 0; background: none; color: var(--brand); font-weight: 600; cursor: pointer; padding: 0; font-size: inherit; }
@media (prefers-color-scheme: dark) { .link-btn { color: #7fb2ec; } }
.progress { height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); transition: width .2s; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: 12px; padding: 32px 16px; text-align: center; cursor: pointer; color: var(--text-2); }
.dropzone.over { border-color: var(--brand); background: var(--info-bg); }
.dropzone svg { width: 32px; height: 32px; color: var(--muted); }
.map-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--border); }
@media (min-width: 700px) { .map-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; } }
.map-row .sample { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-count { background: var(--brand); color: var(--brand-ink); border-radius: 9px; min-width: 18px; height: 18px; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
.feed { max-height: 560px; overflow-y: auto; overscroll-behavior: contain; }
.feed-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .tl-icon { width: 28px; height: 28px; }
.feed-item .tl-icon svg { width: 14px; height: 14px; }
.rank { width: 22px; height: 22px; border-radius: 6px; background: var(--surface-3); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); }
.rank.r1 { background: #fff1c7; color: #8a6100; }
@media (prefers-color-scheme: dark) { .rank.r1 { background: #3d3110; color: #f2c14e; } }
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 14px; margin-bottom: 14px; cursor: pointer; border: 0; width: 100%; text-align: left; }
.banner svg { width: 18px; height: 18px; flex: none; }

/* ---------- 2-step verification ---------- */
.login-help { color: var(--text-2); font-size: 14.5px; }
.login-details { margin-top: 14px; font-size: 14px; color: var(--text-2); }
.login-details summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.code-input { font-size: 24px !important; letter-spacing: .25em; text-align: center; font-variant-numeric: tabular-nums; }
.steps { padding-left: 20px; margin: 14px 0 0; display: flex; flex-direction: column; gap: 18px; }
.steps li { padding-left: 4px; }
.steps li > b { display: block; margin-bottom: 6px; }
.steps .small, .steps .hide-touch { display: block; margin: 8px 0 4px; }
.qr { width: 200px; max-width: 100%; background: #fff; border-radius: 10px; border: 1px solid var(--border); margin: 6px 0 4px; }
.qr svg { display: block; width: 100%; height: auto; }
.secret { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; letter-spacing: .06em; background: var(--surface-3); padding: 10px 12px; border-radius: 8px; word-break: break-all; user-select: all; }
.backup-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.backup-codes code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 16px; padding: 9px; text-align: center; background: var(--surface-3); border-radius: 8px; }
.only-touch { display: none; margin: 4px 0 2px; }
@media (hover: none) and (pointer: coarse) { .only-touch { display: inline-flex; } .hide-touch { display: none !important; } .qr { width: 160px; } }

/* ---------- Dashboard breathing room (v1.2) ---------- */
.dash .page-head { margin-bottom: 18px; row-gap: 14px; }
.dash-ranges { margin-top: 2px; margin-bottom: 22px; padding-top: 2px; padding-bottom: 4px; }
.dash .banner { margin-bottom: 18px; }
.dash .kpis { gap: 12px; }
.dash .kpi { padding: 16px 16px 14px; gap: 6px; }
.dash .kpi .k-foot { margin-top: 2px; }
.dash .kpi.hero { padding: 20px 20px 18px; gap: 8px; margin-bottom: 2px; }
.dash .kpi.hero .k-value { margin: 2px 0 4px; }
.dash .grid.mt { margin-top: 18px; gap: 16px; }
@media (min-width: 900px) { .dash .kpis { gap: 14px; } .dash-ranges { margin-bottom: 24px; } .dash .kpi.hero { padding: 22px 24px 20px; } }
