/* ===========================================================================
   HEXACODES CRM — design rules:
   the HEXACODES blue-to-purple gradient is the ONE primary action per view
   (white label); navy-ink neutrals; states never borrow the brand; Space Grotesk
   for headings and figures 20px+, Inter for everything else; six radii; calm motion.
   :root = dark (the default); [data-theme="light"] is its own theme.
   theme.js sets data-theme before the first paint (Device / Light / Dark).
   Brand colours are sampled from the HEXACODES logo: cyan #4fc3e8, sky #74b7e5,
   blue #5471b7, purple #765aa6, pink #e17ab1.
   =========================================================================== */
:root {
  /* ---- design tokens ---- */
  --bg: #0b1020;
  --bg-sunken: #070b16;
  --surface: #141b2e;
  --surface-2: #1b2338;
  --surface-3: #232c45;
  --surface-overlay: #1d2640;
  --border: #2a3552;
  --border-strong: #3a4870;
  --field-border: #56699e;
  --text: #e8edf7;
  --text-2: #b4bfd8;
  --muted: #8e9bbb;
  --disabled: #5a6788;
  --brand-cyan: #4fc3e8; --brand-sky: #74b7e5; --brand-blue: #5471b7; --brand-purple: #765aa6; --brand-pink: #e17ab1;
  --brand-hexa: #74b7e5; --brand-codes: #8aa2e4;
  --accent-fill: #5471b7;
  --accent-fill-2: #765aa6;
  --accent-fill-deep: #4a63a8;
  --on-accent: #ffffff;
  --accent-text: #8fb5f2;
  --accent-soft: #6f8fe02e;
  --accent-line: #6f8fe066;
  --success: #4ade80; --success-soft: #4ade8024; --success-fill: #16a34a;
  --warning: #facc15; --warning-soft: #facc1524;
  --danger: #f87171; --danger-soft: #f8717124; --danger-fill: #dc2626;
  --info: #60a5fa; --info-soft: #60a5fa24;
  --focus-ring: #74b7e5;
  --cat-1: #6ea8ff; --cat-2: #2dd4bf; --cat-3: #5ee08a; --cat-4: #38bdf8;
  --cat-5: #a3e635; --cat-6: #f472b6; --cat-7: #d6a77a; --cat-8: #a5b4cc;
  --sidebar: #070b16;
  --glass: rgba(11, 16, 32, 0.72);
  --glass-solid: rgba(11, 16, 32, 0.94);
  --glow-1: rgba(84, 113, 183, 0.20);
  --glow-2: rgba(118, 90, 166, 0.14);
  --overlay: rgba(3, 6, 14, 0.62);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-overlay: 0 24px 64px rgba(0, 0, 0, 0.45);
  --elev: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --elev-hover: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px; --r-pill: 999px;
  --font: 'Inter', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Arabic', Tahoma, sans-serif;
  --font-display: 'Space Grotesk', 'IBM Plex Sans Arabic', 'Inter', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;
  --fs-2xs: 11px; --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px; --fs-md: 15px; --fs-lg: 17px; --fs-xl: 20px;
  --fs-2xl: clamp(22px, 1.2vw + 16px, 28px);
  --dur-1: 120ms; --dur-2: 180ms; --dur-3: 260ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --icon-stroke: 1.75;
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--focus-ring);

  /* ---- the CRM's own names, mapped onto the tokens ---- */
  --ground: var(--bg);
  --border-2: var(--border-strong);
  --faint: var(--muted);
  --accent: var(--accent-text);
  --accent-2: var(--accent-text);
  --accent-weak: var(--accent-soft);
  --ok: var(--success); --ok-weak: var(--success-soft); --ok-mark: var(--success-fill);
  --warn: var(--warning); --warn-weak: var(--warning-soft); --warn-mark: var(--warning);
  --bad: var(--danger); --bad-weak: var(--danger-soft); --bad-mark: var(--danger-fill);
  --info-weak: var(--info-soft); --info-mark: var(--info);
  --idle: var(--text-2); --idle-weak: var(--surface-3); --idle-mark: var(--disabled);
  --shadow-sm: var(--elev); --shadow: var(--shadow-2); --shadow-lg: var(--shadow-overlay);
  --r: var(--r-md);
  --sans: var(--font); --mono: var(--font-mono);
  --t0: var(--cat-1); --t1: var(--cat-2); --t2: var(--cat-7); --t3: var(--cat-3);
  --t4: var(--cat-6); --t5: var(--cat-4); --t6: var(--cat-5); --t7: var(--cat-8);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f7fa;
  --bg-sunken: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f3f5f9;
  --surface-3: #e8ecf2;
  --surface-overlay: #ffffff;
  --border: #dfe4ec;
  --border-strong: #c3cbd8;
  --field-border: #7d8ca3;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #5b6780;
  --disabled: #9aa3b5;
  --brand-hexa: #3b93cf; --brand-codes: #5471b7;
  --accent-fill: #5471b7;
  --accent-fill-2: #765aa6;
  --accent-fill-deep: #4a63a8;
  --on-accent: #ffffff;
  --accent-text: #4560a6;
  --accent-soft: #5471b71f;
  --accent-line: #5471b759;
  --success: #15803d; --success-soft: #e8f5ec; --success-fill: #16a34a;
  --warning: #a16207; --warning-soft: #fdf6dc;
  --danger: #c81e1e; --danger-soft: #fdecec; --danger-fill: #dc2626;
  --info: #1d63d8; --info-soft: #e8f0fd;
  --focus-ring: #4560a6;
  --cat-1: #1d4ed8; --cat-2: #0f766e; --cat-3: #15803d; --cat-4: #0369a1;
  --cat-5: #4d7c0f; --cat-6: #be185d; --cat-7: #7c4a2d; --cat-8: #475569;
  --sidebar: #ffffff;
  --glass: rgba(255, 255, 255, 0.8);
  --glass-solid: rgba(255, 255, 255, 0.94);
  --glow-1: rgba(84, 113, 183, 0.09);
  --glow-2: rgba(225, 122, 177, 0.06);
  --overlay: rgba(15, 23, 42, 0.40);
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-2: 0 10px 30px rgba(16, 24, 40, 0.12);
  --shadow-overlay: 0 24px 64px rgba(15, 23, 42, 0.22);
  --elev: var(--shadow-1);
  --elev-hover: var(--shadow-2);
  --warn-mark: #e8b100;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { overflow-x: clip; }
body { background: var(--bg); color: var(--text); font: var(--fs-base)/1.5 var(--font); -webkit-font-smoothing: antialiased; min-height: 100vh; }
body.modal-open { overflow: hidden; }
/* The one brand glow: Home and sign-in only. */
body.page-home::before, body.page-login::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(1100px 560px at 85% -12%, var(--glow-1), transparent 60%), radial-gradient(900px 520px at -10% 110%, var(--glow-2), transparent 60%);
}
[hidden] { display: none !important; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0; text-wrap: balance; }
h1 { font: 700 var(--fs-2xl)/1.15 var(--font-display); letter-spacing: -0.02em; }
h2 { font-size: var(--fs-md); font-weight: 600; }
h3 { font-size: var(--fs-base); font-weight: 600; }
p { margin: 0; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
:where(a, button, [role="button"], [tabindex], summary, input[type="checkbox"], input[type="radio"]):focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
main[tabindex="-1"]:focus, main[tabindex="-1"]:focus-visible { outline: none; }
:where(input[type="checkbox"], input[type="radio"]) { width: 18px; height: 18px; accent-color: var(--accent-fill-deep); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; } }
.muted { color: var(--muted); }
.small { font-size: var(--fs-xs); }
.mb { margin-bottom: 16px; }
.pad { padding: 10px 2px; }
.grow { flex: 1; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; flex: none; }
.money { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* ---------------------------------------------------------------- buttons -- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--r-md);
  font-size: var(--fs-base); font-weight: 600; line-height: 1.2; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out); }
:where(:root[data-theme="light"]) .btn { background: var(--surface); }
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; }
/* Primary = the one brand-gradient action per view (blue to purple); white label in both themes. */
.btn-primary { background: linear-gradient(135deg, var(--accent-fill), var(--accent-fill-2)) !important; border-color: transparent; color: var(--on-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 6px 16px -8px var(--accent-fill-deep); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, var(--accent-fill-deep), var(--accent-fill-2) 85%) !important; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 8px 20px -8px var(--accent-fill-deep); }
.btn-ghost { background: var(--surface-2); }
.btn-tonal { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.btn-tonal:hover:not(:disabled) { background: color-mix(in srgb, var(--accent-fill) 24%, transparent); }
/* States never borrow the brand: Won is the success fill, Reject the danger wash. */
.btn-ok { background: var(--success-fill); border-color: transparent; color: #fff; }
.btn-ok:hover:not(:disabled) { background: color-mix(in srgb, var(--success-fill) 88%, black); }
.btn-danger { background: var(--danger-fill); border-color: transparent; color: #fff; }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger-fill) 88%, black); }
.btn-danger-ghost { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 22%, transparent); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: var(--r-md); background: transparent; color: var(--text-2); cursor: pointer; position: relative;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .ico { width: 20px; height: 20px; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: var(--r-sm); }
.icon-btn.sm .ico { width: 16px; height: 16px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-text); cursor: pointer; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }
.link-btn.center { display: block; margin: 0 auto; }
.link-btn.danger, .danger { color: var(--danger); }

/* ---------------------------------------------------------------- shell --
   App shell:
     >= 1280px   248px sidebar (brand, nav with counts, theme, profile)
     720-1279px  76px icon rail (labels hidden, kept as tooltips / names)
     < 720px     slim top bar + floating bottom tab bar (+ More sheet)      */
:root { --sidebar-w: 248px; --shell-top: 64px; --shell-bottom: 0px; }
@media (max-width: 1279px) { :root { --sidebar-w: 76px; } }
@media (max-width: 719px) { :root { --sidebar-w: 0px; --shell-top: 56px; --shell-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } }

.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.app-main { min-width: 0; display: flex; flex-direction: column; }
.sidebar { position: sticky; top: 0; z-index: 30; height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: 16px 12px;
  background: var(--sidebar); border-inline-end: 1px solid var(--border); overflow: hidden; }
.sb-brand { display: flex; align-items: center; gap: 10px; flex: none; height: 48px; padding: 0 8px; margin-bottom: 10px; border-radius: var(--r-md); color: var(--text); text-decoration: none !important; }
.brand-mark { display: block; height: 40px; width: auto; flex: none; color: var(--text); }
.brand-mark.sm { height: 34px; }
.sb-word { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sb-word b { font: 600 18px/1 var(--font); letter-spacing: .04em; }
.sb-word .bw-i { color: var(--brand-hexa); }
.sb-word .bw-l { color: var(--brand-codes); }
.sb-word small { font: 500 var(--fs-xs)/1 var(--font); color: var(--muted); }
.sb-nav { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 2px; margin: 0 -12px; padding: 0 12px 8px; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
.nav-label { margin: 0; padding: 16px 12px 6px; font: 600 var(--fs-xs)/1 var(--font); color: var(--muted); }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 0 12px; border: 0; border-radius: var(--r-md);
  background: none; color: var(--text-2); font: 500 var(--fs-base)/1 var(--font); text-align: start; text-decoration: none !important; cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out); }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item .ico { width: 20px; height: 20px; color: var(--muted); }
.nav-item:hover .ico { color: var(--text-2); }
.nav-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3; }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.nav-item[aria-current="page"] .ico { color: var(--accent-text); }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; inset-inline-start: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent-fill); }
.nav-count { display: inline-grid; place-items: center; flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--danger-fill); color: #fff; font: 600 var(--fs-2xs)/1 var(--font); font-variant-numeric: tabular-nums; }
.side-foot { flex: none; display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
.theme-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; margin: 0; padding: 3px; min-width: 0; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.theme-seg button { display: flex; align-items: center; justify-content: center; gap: 6px; height: 30px; min-width: 0; border: 0; border-radius: var(--r-sm); background: none;
  color: var(--muted); font: 500 var(--fs-xs)/1 var(--font); cursor: pointer; }
.theme-seg button:hover { color: var(--text); }
.theme-seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--elev), 0 0 0 1px var(--border); }
.theme-seg .ico { width: 15px; height: 15px; }
.me-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; text-align: start; cursor: pointer; box-shadow: var(--elev); }
.me-btn:hover { background: var(--surface-2); }
.me-txt { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.me-txt b { font-size: var(--fs-sm); font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-txt > span { font-size: var(--fs-xs); color: var(--muted); }
.me-btn .chev { width: 16px; height: 16px; color: var(--muted); }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: linear-gradient(145deg, var(--accent-fill), var(--accent-fill-2)); color: var(--on-accent); font: 700 13px/1 var(--font-display); }
.avatar-lg { width: 48px; height: 48px; font-size: 17px; }
.menu-wrap, .bell-wrap { position: relative; }
.menu { position: absolute; z-index: 55; min-width: 220px; padding: 6px; background: var(--surface-overlay); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-overlay); }
.side-foot .menu { left: 0; bottom: calc(100% + 8px); }
.menu-head { display: flex; flex-direction: column; gap: 2px; padding: 8px 8px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px; border: 0; background: none; border-radius: var(--r-md); cursor: pointer; text-align: start; color: var(--text); font-weight: 500; }
.menu-item:hover { background: var(--surface-2); }
.menu-item .ico { color: var(--muted); }

.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px; height: var(--shell-top); padding: 0 clamp(20px, 3vw, 56px);
  background: var(--glass); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
@supports not ((backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px))) { .topbar { background: var(--glass-solid); } }
.tb-title { min-width: 0; flex: 1; margin: 0; font: 600 var(--fs-md)/1.2 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-home, .tb-avatar { display: none; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.dot-badge { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--danger-fill); color: #fff;
  font: 600 var(--fs-2xs)/18px var(--font); text-align: center; box-shadow: 0 0 0 2px var(--bg); }
.bell-panel { position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, calc(100vw - 24px)); max-height: 70vh; overflow: auto; background: var(--surface-overlay);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-overlay); z-index: 55; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface-overlay); }
.bell-list { list-style: none; margin: 0; padding: 6px; }
.bell-list a { display: block; padding: 10px; border-radius: var(--r-md); color: var(--text); text-decoration: none; }
.bell-list a:hover { background: var(--surface-2); }
.bell-list li.unread a { background: var(--accent-soft); }
.bell-title { font-weight: 600; }
.bell-body { color: var(--text-2); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bell-time { color: var(--muted); font-size: var(--fs-2xs); margin-top: 3px; }
.main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px clamp(20px, 3vw, 56px) 64px; outline: none; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px 0; justify-content: center; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent-fill); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
.tabbar, .more-sheet { display: none; }

/* ---- Icon rail: 720-1279px ---- */
@media (min-width: 720px) and (max-width: 1279px) {
  .sidebar { padding: 16px 10px; align-items: center; }
  .sb-brand { justify-content: center; padding: 0; width: 100%; }
  .sb-word, .nav-item .lbl, .me-txt, .me-btn .chev, .theme-seg button span, .nav-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .sb-nav { margin: 0 -10px; padding: 0 10px 8px; width: calc(100% + 20px); }
  .side-foot { width: 100%; align-items: center; }
  .nav-item { justify-content: center; padding: 0; min-height: 44px; }
  .nav-item[aria-current="page"]::before { inset-inline-start: -10px; }
  .nav-item .nav-count { position: absolute; top: 2px; inset-inline-end: 2px; min-width: 18px; height: 18px; padding: 0 5px; box-shadow: 0 0 0 2px var(--sidebar); }
  .theme-seg { grid-template-columns: 1fr; width: 44px; }
  .theme-seg button { height: 32px; }
  .me-btn { width: auto; padding: 4px; border-color: transparent; background: transparent; box-shadow: none; justify-content: center; }
  .topbar { padding: 0 24px; }
}

/* ---- Phones: < 720px ---- */
@media (max-width: 719px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar { padding: 0 6px 0 4px; gap: 4px; }
  .tb-home { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: var(--r-md); }
  .tb-title { font: 700 var(--fs-lg)/1.2 var(--font-display); letter-spacing: -.01em; }
  .add-deal { width: 44px; min-height: 44px; padding: 0; border-radius: var(--r-md); }
  .add-deal span { display: none; }
  .add-deal .ico { width: 20px; height: 20px; }
  .icon-btn { width: 44px; height: 44px; }
  .tb-avatar { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
  .tb-avatar .avatar { width: 32px; height: 32px; font-size: 12px; }
  .main { padding: 18px 16px calc(var(--shell-bottom) + 28px); }
  .tabbar { position: fixed; z-index: 45; inset-inline: 12px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    gap: 2px; height: 64px; padding: 6px; border-radius: var(--r-xl); background: var(--glass); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    border: 1px solid var(--border); box-shadow: var(--shadow-2); }
  .tb-tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; padding: 0; border: 0;
    border-radius: var(--r-lg); background: none; color: var(--muted); font: 600 var(--fs-2xs)/1 var(--font); text-decoration: none !important; cursor: pointer; }
  .tb-tab:hover { color: var(--text); }
  .tb-tab .pip { display: grid; place-items: center; width: 52px; height: 30px; border-radius: var(--r-pill); transition: background-color var(--dur-2) var(--ease-out); }
  .tb-tab .ico { width: 22px; height: 22px; }
  .tb-tab .tl { max-width: 100%; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tb-tab[aria-current="page"] { color: var(--text); }
  .tb-tab[aria-current="page"] .pip { background: var(--accent-soft); color: var(--accent-text); }
  .tb-tab .nav-count { position: absolute; top: 2px; inset-inline-start: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; box-shadow: 0 0 0 2px var(--surface); }
  .more-sheet { display: block; position: fixed; inset: 0; z-index: 58; }
  .more-sheet[hidden] { display: none; }
  .ms-scrim { position: absolute; inset: 0; background: var(--overlay); animation: fade var(--dur-2) var(--ease-out); }
  .ms-panel { position: absolute; inset-inline: 0; bottom: 0; max-height: 88vh; overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--surface-overlay); border: 1px solid var(--border-strong); border-bottom: 0; box-shadow: var(--shadow-overlay);
    animation: sheet-up var(--dur-3) var(--ease-out); }
  .ms-grab { width: 40px; height: 4px; margin: 4px auto 12px; border-radius: 2px; background: var(--border-strong); }
  .ms-me { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
  .ms-me .me-txt { flex: 1; }
  .ms-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
  .ms-item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 84px; padding: 10px 6px;
    border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font: 500 var(--fs-xs)/1.3 var(--font);
    text-align: center; text-decoration: none !important; cursor: pointer; overflow-wrap: anywhere; }
  .ms-item:hover { color: var(--text); border-color: var(--border-strong); }
  .ms-item .ico { width: 22px; height: 22px; color: var(--text); }
  .ms-item[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
  .ms-item[aria-current="page"] .ico { color: var(--accent-text); }
  .more-sheet .theme-seg { margin-top: 18px; }
  .more-sheet .theme-seg button { height: 44px; font-size: var(--fs-sm); }
  .ms-foot { display: flex; gap: 8px; margin-top: 14px; }
  .ms-foot .btn { flex: 1; min-height: 44px; }
  #toasts { bottom: calc(var(--shell-bottom) + 12px) !important; }
}
@media (max-width: 719px) and (pointer: coarse) { .topbar, .tabbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--glass-solid); } }

/* ---------------------------------------------------------------- page bits -- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-titles { min-width: 0; }
.page-sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; margin-bottom: 12px; }
.back:hover { color: var(--text); text-decoration: none; }
.back .ico { width: 16px; height: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--elev); min-width: 0; }
.card h2 { font-size: var(--fs-lg); font-weight: 600; }
.card + .card, .card + section, section + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-warn { border-color: color-mix(in srgb, var(--warning) 45%, transparent); background: color-mix(in srgb, var(--warning-soft) 60%, var(--surface)); }
.sec { margin: 18px 0 8px; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.sec-title { margin: 32px 0 14px; font: 600 var(--fs-xl)/1.3 var(--font-display); letter-spacing: -.01em; color: var(--text); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); display: grid; gap: 10px; justify-items: center; }
.empty h3 { color: var(--text); font: 600 var(--fs-lg)/1.3 var(--font); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid2 > * { min-width: 0; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: var(--fs-md); unicode-bidi: plaintext; }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); font-size: var(--fs-2xs); font-weight: 600; line-height: 1; white-space: nowrap; margin-left: 6px; vertical-align: middle; }
.badge-warn { background: var(--warn-weak); color: var(--warn); }
.badge-ok { background: var(--ok-weak); color: var(--ok); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-bad { background: var(--danger-soft); color: var(--danger); }
.new-tag { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-text); font-size: var(--fs-2xs); font-weight: 600; white-space: nowrap; }
.warn-pill { display: inline-flex; align-items: center; gap: 4px; height: 20px; color: var(--warning); background: var(--warning-soft); border-radius: var(--r-pill); padding: 0 8px; font-size: var(--fs-2xs); font-weight: 600; white-space: nowrap; }
.warn-pill .ico { width: 13px; height: 13px; }
.unread-pill { display: inline-flex; align-items: center; gap: 4px; height: 20px; background: var(--accent-soft); color: var(--accent-text); border-radius: var(--r-pill); padding: 0 8px; font-size: var(--fs-2xs); font-weight: 600; }
.unread-pill .ico { width: 11px; height: 11px; }
.role-tag { display: inline-flex; align-items: center; height: 18px; font-size: var(--fs-2xs); color: var(--text-2); background: var(--surface-3); border-radius: var(--r-pill); padding: 0 7px; font-weight: 600; }
.notice { padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 14px; display: block; }
.notice .ico { width: 16px; height: 16px; vertical-align: -3px; }
.notice-warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.notice-warn a { color: inherit; text-decoration: underline; }
.notice-bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* status colours: one per deal status, always with its label */
.status { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px 0 8px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-pending { background: var(--warn-weak); color: var(--warn); }
.st-approved { background: var(--info-soft); color: var(--info); }
.st-won { background: var(--ok-weak); color: var(--ok); }
.st-lost { background: var(--surface-3); color: var(--text-2); }
.st-rejected { background: var(--bad-weak); color: var(--bad); }

/* ---------------------------------------------------------------- forms -- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; min-width: 0; }
.field-label { font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); }
.field-hint { color: var(--muted); font-size: var(--fs-xs); }
.input { width: 100%; min-height: 40px; padding: 9px 13px; border: 1px solid var(--field-border); border-radius: var(--r-md); background: var(--bg); color: var(--text); font: inherit; font-size: var(--fs-base); min-width: 0;
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out); }
:root[data-theme="light"] .input { background: var(--surface); }
.input:focus { outline: 2px solid transparent; border-color: var(--focus-ring); box-shadow: var(--ring); }
.input::placeholder { color: var(--muted); }
.input:disabled { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
textarea.input { resize: vertical; line-height: 1.5; }
select.input { padding-right: 28px; }
.range-in { display: flex; align-items: center; gap: 6px; }
.range-in .input { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.range-in .cur { color: var(--muted); font-weight: 600; }
.range-in .dash { color: var(--muted); padding: 0 2px; }
.copy-box { display: flex; gap: 8px; }
.check-row { display: flex; align-items: flex-start; gap: 9px; padding: 6px 0; cursor: pointer; }
.check-row input { margin-top: 2px; flex: none; }
.check-list { display: grid; gap: 0; }
.check-list.cols { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 14px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-pill); background: var(--surface-2); cursor: pointer; white-space: nowrap; font-size: var(--fs-sm); }
.seg { display: inline-grid; grid-auto-flow: column; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.seg-btn { border: 0; background: none; height: 32px; padding: 0 14px; border-radius: var(--r-sm); cursor: pointer; color: var(--muted); font-weight: 500; font-size: var(--fs-sm); }
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--surface); color: var(--text); box-shadow: var(--elev), 0 0 0 1px var(--border); }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 10px 13px; border-radius: var(--r-md); margin-bottom: 14px; }
.form-note { color: var(--text); background: var(--surface-2); border: 1px solid var(--border); padding: 10px 13px; border-radius: var(--r-md); margin-bottom: 14px; }
.me-card { display: flex; gap: 12px; align-items: center; }
.danger-zone { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 12px; }
.archive-row { margin-top: 14px; }

/* ---------------------------------------------------------------- login -- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1100px 560px at 85% -12%, var(--glow-1), transparent 60%), radial-gradient(900px 520px at -10% 110%, var(--glow-2), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 32px 28px; box-shadow: var(--shadow-2); display: grid; gap: 4px; }
.login-card { position: relative; overflow: hidden; }
.login-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--brand-cyan), var(--brand-blue) 45%, var(--brand-purple) 80%, var(--brand-pink)); }
.login-card > .btn { margin-top: 4px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-brand .brand-mark { height: 52px; }
.login-title { font: 700 22px/1.2 var(--font-display); letter-spacing: -.02em; }
.login-sub { color: var(--muted); }
.login-foot { color: var(--muted); font-size: var(--fs-xs); text-align: center; margin-top: 12px; }

/* ---------------------------------------------------------------- modal + toast -- */
.modal-back { position: fixed; inset: 0; z-index: 60; background: var(--overlay); display: grid; place-items: center; padding: 24px; overflow-y: auto; animation: fade var(--dur-1) var(--ease-out); }
.modal { width: 100%; max-width: 520px; background: var(--surface-overlay); border: 1px solid var(--border-strong); border-radius: var(--r-xl); box-shadow: var(--shadow-overlay); display: flex; flex-direction: column; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); animation: pop var(--dur-2) var(--ease-out); }
.modal-wide { max-width: 760px; }
.modal.nudge { animation: nudge var(--dur-3) var(--ease-out); }
@keyframes nudge { 30% { transform: scale(1.015); } 60% { transform: scale(.995); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: var(--fs-lg); font-weight: 600; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-body > p { margin-bottom: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@media (max-width: 560px) {
  .modal-back { padding: 0; place-items: end stretch; }
  .modal, .modal-wide { max-width: none; border-radius: var(--r-xl) var(--r-xl) 0 0; border-bottom: 0; max-height: 92vh; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom, 0px); animation: sheet-up var(--dur-3) var(--ease-out); }
  .modal-foot .btn { flex: 1; }
}
#toasts { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--surface-overlay); color: var(--text); border: 1px solid var(--border-strong); padding: 11px 16px; border-radius: var(--r-md); box-shadow: var(--shadow-overlay); font-weight: 500; transition: opacity .4s, transform .4s; }
.toast-err { background: var(--danger-fill); border-color: transparent; color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------------------------------------------------------------- filters + lists -- */
.filters { display: grid; gap: 10px; margin-bottom: 14px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .filter-row { margin-bottom: 0; }
.filter-row > select.input { width: auto; max-width: 220px; }
.search-in { position: relative; flex: 1 1 240px; min-width: 0; max-width: 420px; }
.search-in .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search-in .input { padding-left: 36px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; min-height: 32px; border: 1px solid var(--border-strong); background: var(--surface-2); padding: 0 12px; border-radius: var(--r-pill); cursor: pointer; font-weight: 500; font-size: var(--fs-sm); color: var(--text-2); }
.chip:hover { color: var(--text); background: var(--surface-3); }
.chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); font-weight: 600; }
.chips.sm .chip { min-height: 28px; padding: 0 10px; font-size: var(--fs-xs); }
.list-head { margin: 4px 0 10px; font-size: var(--fs-sm); }
.deal-list { display: grid; gap: 8px; }
.deal-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); color: var(--text); text-decoration: none !important; box-shadow: var(--elev);
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out); }
.deal-row:hover { background: var(--surface-2); border-color: var(--border-strong); box-shadow: var(--elev-hover); }
:root[data-theme="light"] .deal-row:hover { background: var(--surface); }
.dr-main { min-width: 0; }
.dr-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dr-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.dr-sub { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-value { text-align: right; display: grid; justify-items: end; gap: 2px; }
.follow { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; white-space: nowrap; }
.follow .ico { width: 13px; height: 13px; }
.follow.due, .due-text { color: var(--warn); }
@media (max-width: 640px) {
  .deal-row { grid-template-columns: auto 1fr auto; gap: 10px; }
  .dr-status { grid-column: 2 / 4; }
  .deal-row .plogo { grid-row: span 2; align-self: start; }
}
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--elev); }
.card .table-wrap { border: 0; border-radius: 0; margin: 0 -4px; box-shadow: none; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table.compact td, .table.compact th { padding: 7px 10px; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }
.table th.num { text-align: right; }
.pills { display: flex; gap: 4px; flex-wrap: wrap; }
.count-pill { display: inline-flex; align-items: center; height: 20px; font-size: var(--fs-2xs); font-weight: 600; padding: 0 8px; border-radius: var(--r-pill); white-space: nowrap; }
.detail { max-width: 420px; overflow-wrap: anywhere; }
.copyable { display: inline-flex; align-items: center; gap: 4px; }
@media (max-width: 640px) { .hide-sm { display: none; } }

/* ---------------------------------------------------------------- project logos -- */
.plogo { width: 40px; height: 40px; border-radius: var(--r-md); object-fit: contain; background: var(--surface); border: 1px solid var(--border); flex: none; display: inline-grid; place-items: center; }
.plogo.sm { width: 34px; height: 34px; border-radius: var(--r-sm); }
.plogo.lg { width: 48px; height: 48px; border-radius: var(--r-md); }
.plogo.xl { width: 64px; height: 64px; border-radius: var(--r-lg); }
/* Initials tile: soft wash + its colour. */
.plogo-text { font: 700 14px/1 var(--font-display); letter-spacing: -0.01em; border: 0; background: color-mix(in srgb, var(--tc) 16%, transparent) !important; color: var(--tc);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tc) 22%, transparent); }
.plogo-text.lg { font-size: 16px; } .plogo-text.xl { font-size: 21px; }
.tint-0 { --tc: var(--t0); } .tint-1 { --tc: var(--t1); } .tint-2 { --tc: var(--t2); } .tint-3 { --tc: var(--t3); }
.tint-4 { --tc: var(--t4); } .tint-5 { --tc: var(--t5); } .tint-6 { --tc: var(--t6); } .tint-7 { --tc: var(--t7); }

/* ---------------------------------------------------------------- home -- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.tiles-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; color: var(--text); text-decoration: none !important; display: grid; gap: 4px; min-width: 0; box-shadow: var(--elev);
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out); }
a.tile:hover { background: var(--surface-2); border-color: var(--border-strong); box-shadow: var(--elev-hover); }
:root[data-theme="light"] a.tile:hover { background: var(--surface); }
.tile-label { color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; }
.tile-val { font: 700 30px/1.15 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-sub { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-warn { border-color: var(--accent-line); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.tile-warn .tile-val { color: var(--accent-text); }
.tile-ok .tile-val { color: var(--ok); }
@media (max-width: 1100px) { .tiles-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .tiles, .tiles-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tile-val { font-size: 22px; } }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.home-main > .card:first-child, .home-side > .card:first-child { margin-top: 0; }
@media (max-width: 960px) { .home-grid { grid-template-columns: 1fr; } }
.mini-list { display: grid; }
.mini-deal { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--border); color: var(--text); text-decoration: none !important; }
.mini-list > .mini-deal:first-child { border-top: 0; }
a.mini-deal:hover strong { color: var(--accent-text); }
.md-text { flex: 1; min-width: 0; display: grid; }
.md-text strong, .md-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-right { display: grid; justify-items: end; text-align: right; }
.mini-projects { display: grid; gap: 4px; }
.mini-project { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: var(--r-sm); color: var(--text); text-decoration: none !important; }
.mini-project:hover { background: var(--surface-2); }
.mp-text { flex: 1; min-width: 0; display: grid; }
.mp-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-mini { display: block; padding: 8px 0; border-top: 1px solid var(--border); color: var(--text); text-decoration: none !important; }
.note-mini:first-of-type { border-top: 0; }

/* ---------------------------------------------------------------- projects -- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 18px; }
.project-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  color: var(--text); text-decoration: none !important; box-shadow: var(--elev); min-width: 0;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out); }
.project-card:hover { background: var(--surface-2); border-color: var(--border-strong); box-shadow: var(--elev-hover); }
:root[data-theme="light"] .project-card:hover { background: var(--surface); }
.project-card.archived { opacity: .7; }
.pc-top { display: flex; justify-content: space-between; align-items: flex-start; }
.project-card h3 { font-size: var(--fs-lg); font-weight: 600; }
.pc-desc { color: var(--text-2); font-size: var(--fs-sm); flex: 1; overflow-wrap: anywhere; }
.pc-desc.muted { color: var(--muted); }
.pc-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pc-range { font-weight: 650; font-variant-numeric: tabular-nums; }
.project-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.ph-text { flex: 1; min-width: 200px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; }
.tab { border: 0; background: none; padding: 12px 16px; cursor: pointer; color: var(--muted); font-size: var(--fs-base); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center;
  transition: color var(--dur-1) var(--ease-out), border-color var(--dur-2) var(--ease-out); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent-fill); }
.tab-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; background: var(--surface-2); color: var(--text-2); border-radius: var(--r-pill); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.tab-actions { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 400px); gap: 14px; align-items: start; }
.overview-grid > * > .card:first-child, .ov-side > .card:first-child { margin-top: 0; }
@media (max-width: 960px) { .overview-grid { grid-template-columns: 1fr; } }
.link-list { display: grid; gap: 8px; }
.demo-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); color: var(--text); text-decoration: none !important; }
.demo-link:hover { border-color: var(--accent-line); background: var(--surface-3); }
.demo-link > span { flex: 1; min-width: 0; display: grid; }
.demo-link > span > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-link .ico:first-child { color: var(--accent-text); }
.demo-link .ico:last-child { color: var(--faint); width: 16px; }
.login-list { display: grid; gap: 10px; }
.login-card-item { border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; background: var(--surface-2); display: grid; gap: 4px; }
.lc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.lc-head .ico { color: var(--accent-text); width: 16px; }
.lc-head .link-btn { margin-left: auto; }
.lc-row { display: flex; align-items: center; gap: 6px; min-height: 28px; }
.lc-k { color: var(--muted); width: 72px; font-size: var(--fs-xs); flex: none; }
.lc-row .mono { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file-list { display: grid; gap: 6px; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--elev); }
.file-item > a:not(.icon-btn) { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 550; }
.file-item > .ico { color: var(--muted); }
.logo-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.logo-row .link-btn { margin-left: 10px; }
.rows { display: grid; gap: 8px; margin-bottom: 8px; }
.row-ed { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) auto; gap: 8px; align-items: center; }
.login-ed { position: relative; border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 40px 10px 10px; display: grid; gap: 8px; background: var(--surface-2); }
.login-ed .grid2 { gap: 8px; }
.login-ed .del { position: absolute; right: 6px; top: 8px; }
.pw-cell { display: flex; align-items: center; gap: 8px; }
@media (max-width: 560px) { .row-ed { grid-template-columns: 1fr auto; } .row-ed > :first-child { grid-column: 1 / -1; } }

/* ---------------------------------------------------------------- release notes -- */
.notes { display: grid; gap: 12px; }
.note-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; display: grid; gap: 10px; box-shadow: var(--elev); }
.note-card.unread { box-shadow: var(--elev), inset 3px 0 0 var(--accent-fill); }
.note-head { display: flex; gap: 12px; align-items: flex-start; }
.note-titles { flex: 1; min-width: 0; display: grid; gap: 2px; }
.note-project { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); font-weight: 600; flex-wrap: wrap; }
.version { font-family: var(--font-mono); font-size: var(--fs-xs); background: var(--surface-3); padding: 1px 7px; border-radius: var(--r-xs); color: var(--text-2); }
.note-head h3 { font-size: var(--fs-lg); font-weight: 600; }
.note-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 8px; }
.note-admin { display: flex; gap: 14px; }

/* ---------------------------------------------------------------- deal page -- */
.deal-head { display: grid; gap: 10px; margin-bottom: 14px; }
.deal-head .back { margin-bottom: 0; }
.deal-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dt-text { flex: 1; min-width: 200px; }
.dt-text h1 { overflow-wrap: anywhere; }
.dt-sub { color: var(--muted); margin-top: 2px; }
.deal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.deal-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
.deal-side > .card:first-child, .deal-main > .card:first-child { margin-top: 0; }
@media (max-width: 960px) { .deal-grid { grid-template-columns: 1fr; } }
.amounts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.amount { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 14px; min-width: 0;
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; align-items: baseline; }
.amount-label, .amount-val { grid-row: 1; }
.amount-val { text-align: right; }
.amount-sub { grid-column: 1 / -1; text-align: right; }
.amount-label { color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; }
.amount-val { font-weight: 700; font-variant-numeric: tabular-nums; font-size: var(--fs-md); overflow-wrap: anywhere; }
.amount-sub { color: var(--muted); font-size: var(--fs-2xs); }
.amount-final { background: var(--ok-weak); border-color: transparent; }
.amount-final .amount-val { color: var(--ok); }
.amounts + .muted { margin-top: 10px; }
.follow-card.due { border-color: var(--accent-line); box-shadow: var(--elev), inset 3px 0 0 var(--accent-fill); }
.follow-set { display: grid; gap: 8px; }
.client-lines { display: grid; gap: 6px; }
.cl-name { font-weight: 600; font-size: var(--fs-md); }
.cl-line { display: flex; align-items: center; gap: 8px; color: var(--text); min-width: 0; }
.cl-line > .ico { color: var(--muted); width: 16px; height: 16px; }
.cl-line > a, .cl-line > span { min-width: 0; overflow-wrap: anywhere; }
.thread { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 14px; max-height: 620px; overflow-y: auto; }
.thread-empty { color: var(--muted); padding: 18px 0; text-align: center; }
.cm { display: flex; gap: 10px; align-items: flex-start; }
.cm .avatar { width: 32px; height: 32px; font-size: 12px; background: var(--surface-3); color: var(--text-2); }
.cm-body { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px var(--r-lg) var(--r-lg) var(--r-lg); padding: 10px 14px; font-size: var(--fs-md); }
.cm-mine .cm-body { background: color-mix(in srgb, var(--accent-fill) 14%, var(--surface)); border-color: transparent; }
.cm-mine .avatar { background: linear-gradient(145deg, var(--brand-cyan), var(--accent-fill)); color: var(--on-accent); }
.cm-new .cm-body { border-color: var(--accent-line); }
.cm-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-xs); margin-bottom: 4px; }
.cm-meta time { color: var(--muted); }
.cm-del { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.cm-deleted { justify-content: center; }
.cm-file { margin-top: 8px; display: grid; gap: 6px; }
.cm-img { max-width: min(320px, 100%); max-height: 240px; border-radius: var(--r-sm); border: 1px solid var(--border); display: block; }
.file-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 550; overflow-wrap: anywhere; }
.file-link .ico { width: 15px; height: 15px; }
.composer { border: 1px solid var(--field-border); border-radius: var(--r-md); padding: 8px; background: var(--bg); }
:root[data-theme="light"] .composer { background: var(--surface); }
.composer:focus-within { border-color: var(--focus-ring); box-shadow: var(--ring); }
.composer .input { border: 0; padding: 4px 6px; box-shadow: none !important; resize: none; min-height: 44px; background: transparent !important; font-size: var(--fs-md); }
.composer-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.file-tag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--text-2); background: var(--surface-3); padding: 2px 4px 2px 8px; border-radius: var(--r-sm); max-width: 100%; overflow-wrap: anywhere; }
.file-tag .ico { width: 14px; height: 14px; }
.history { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); display: grid; gap: 12px; }
.history li { position: relative; }
.history li::before { content: ''; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.history li:first-child::before { border-color: var(--accent-fill); }
.ev-text { overflow-wrap: anywhere; }
.ev-note { color: var(--text); background: var(--surface-2); border-radius: var(--r-sm); padding: 7px 11px; margin-top: 4px; white-space: pre-wrap; font-size: var(--fs-sm); }
.ev-time { color: var(--muted); font-size: var(--fs-xs); }

/* new-deal client picker */
.picker-results { border: 1px solid var(--border-strong); border-radius: var(--r-md); margin-top: 4px; max-height: 240px; overflow-y: auto; background: var(--surface-overlay); }
.pick-item { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 8px 12px; border: 0; background: none; cursor: pointer; text-align: left; border-bottom: 1px solid var(--border); }
.pick-item:last-child { border-bottom: 0; }
.pick-item:hover, .pick-item:focus { background: var(--surface-2); }
.pick-new { flex-direction: row; align-items: center; gap: 6px; color: var(--accent-text); font-weight: 600; }
.picked { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 13px; border: 1px solid var(--accent-line); border-radius: var(--r-md); background: var(--accent-soft); }
.new-client { border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 14px 4px; background: var(--surface-2); }

/* ---------------------------------------------------------------- users -- */
.user-list { display: grid; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.user-list > .user-row:first-child { border-top: 0; }
.user-row.inactive { opacity: .6; }
.ur-main { flex: 1; min-width: 0; }
.ur-main > div { overflow-wrap: anywhere; }
.ur-side { text-align: right; }
@media (max-width: 640px) { .ur-side { display: none; } }
.manage-row { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 6px; }

/* ---------------------------------------------------------------- reports -- */
.report-filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--elev); }
.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; }
.inline .input { width: auto; }
.report-body > .card, .report-body > .report-grid { margin-top: 14px; }
.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.report-grid > .card { margin-top: 0; }
@media (max-width: 960px) { .report-grid { grid-template-columns: 1fr; } }
.tile.static { box-shadow: none; }
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { stroke: var(--border-2); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--accent-fill); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: color-mix(in srgb, var(--accent-fill) 8%, transparent); }
.chart-tip { position: absolute; top: 0; background: var(--surface-overlay); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow-overlay); padding: 9px 12px; font-size: var(--fs-xs); pointer-events: none; min-width: 150px; }
.table-toggle { margin-top: 8px; }
.table-toggle summary { cursor: pointer; color: var(--accent-text); font-weight: 600; font-size: var(--fs-sm); }
.status-bar { display: flex; gap: 2px; height: 14px; border-radius: var(--r-pill); overflow: hidden; }
.sbar { display: block; min-width: 4px; }
.sbar.st-won { background: var(--success); } .sbar.st-approved { background: var(--info); } .sbar.st-pending { background: var(--warn-mark); }
.sbar.st-lost { background: var(--idle-mark); } .sbar.st-rejected { background: var(--bad-mark); }
.status-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 13px; }
.status-legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.key.st-won { background: var(--success); } .key.st-approved { background: var(--info); } .key.st-pending { background: var(--warn-mark); }
.key.st-lost { background: var(--idle-mark); } .key.st-rejected { background: var(--bad-mark); }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.hbar-label { font-size: 13px; }
.hbar-track { height: 10px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--text-2); border-radius: var(--r-pill); }
.hbar-val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
@media (max-width: 560px) { .hbar { grid-template-columns: 1fr auto; } .hbar-track { grid-column: 1 / -1; grid-row: 2; } }
.report-foot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 18px; }

/* ==========================================================================
   Touch / phones (2026-11-07): big enough to tap, no zoom-on-focus, no stray
   double-tap zoom, and forms that stay usable above the on-screen keyboard.
   ========================================================================== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
a, button, label, summary, select, .chip, .deal-row, .tile, .project-card { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
@media (pointer: coarse) {
  /* iOS zooms the page when a field under 16px gets focus. */
  .input, select.input, textarea.input, .composer .input { font-size: 16px; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; padding: 0 14px; }
  .icon-btn, .icon-btn.sm { width: 44px; height: 44px; }
  .icon-btn.sm .ico { width: 18px; height: 18px; }
  .chip, .chips.sm .chip { min-height: 40px; padding: 0 14px; }
  .toggle { min-height: 40px; }
  .seg-btn { height: 40px; }
  .tab { padding: 14px 16px; }
  .link-btn { min-height: 40px; display: inline-flex; align-items: center; }
  .link-btn.center { display: flex; justify-content: center; margin: 0 auto; }
  .check-row { min-height: 44px; align-items: center; padding: 8px 0; }
  .check-row input { margin-top: 0; }
  .menu-item { min-height: 48px; }
  .bell-list a { padding: 12px; }
  .pick-item { min-height: 48px; justify-content: center; }
  .btn:active:not(:disabled), .chip:active, .deal-row:active, .tile:active, .project-card:active { transform: scale(.98); }
}
@media (max-width: 719px) {
  h1 { font-size: 24px; }
  .page-head { margin-bottom: 16px; align-items: flex-start; }
  .page-actions { width: 100%; }
  .card { padding: 16px; }
  .modal-head { padding: 14px 18px; }
  .modal-body { padding: 18px; }
  .modal-foot { padding: 12px 18px; position: sticky; bottom: 0; background: var(--surface-overlay); }
  .modal-foot .btn { flex: 1 1 0; min-width: 0; }
  #toasts { max-width: calc(100vw - 24px); }
}
/* Menus that open from a button on the right edge (deal "More"). */
.menu-right { right: 0; left: auto; }
@media (max-width: 719px) {
  /* On a phone a pop-up menu is a sheet along the bottom, above the tab bar — never off the screen edge. */
  .menu-wrap .menu, .deal-actions .menu { position: fixed; left: 12px; right: 12px; top: auto; bottom: calc(var(--shell-bottom) + 12px); min-width: 0; z-index: 60; }
  .menu-item { min-height: 48px; font-size: var(--fs-md); }
  /* Notifications drop down under the top bar across the whole width. */
  .bell-panel { position: fixed; left: 8px; right: 8px; top: calc(var(--shell-top) + 6px); width: auto;
    max-height: calc(100vh - var(--shell-top) - var(--shell-bottom) - 24px); max-height: calc(100dvh - var(--shell-top) - var(--shell-bottom) - 24px); }
  /* Big figures wrap instead of being cut off. */
  .tile-val { white-space: normal; overflow-wrap: anywhere; font-size: 24px; }
  .tile-sub { white-space: normal; }
}
@media (pointer: coarse) {
  .theme-seg button { height: 40px; }
  .back { min-height: 40px; }
  .theme-seg { width: auto; }
}
@media (pointer: coarse) and (min-width: 720px) and (max-width: 1279px) { .theme-seg { width: 48px; } .theme-seg button { height: 40px; } }
/* Wide tables (reports by project / salesman, clients, activity) become small cards on phones:
   the first cell is the title, every other cell shows its column name above the value. */
@media (max-width: 719px) {
  .table-wrap:has(.table.stack) { overflow: visible; }
  .table.stack, .table.stack tbody { display: block; }
  .table.stack thead { display: none; }
  .table.stack tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .table.stack tr:last-child { border-bottom: 0; }
  .table.stack td { display: flex; flex-direction: column; gap: 2px; padding: 0; border: 0; min-width: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .table.stack td::before { content: attr(data-label); font-size: var(--fs-2xs); font-weight: 600; color: var(--muted); }
  .table.stack td:first-child { grid-column: 1 / -1; font-size: var(--fs-md); font-weight: 600; }
  .table.stack td:first-child::before { display: none; }
  .table.stack td.hide-sm { display: none; }
  .table.stack td:empty { display: none; }
  .table.stack tr.click:hover td { background: none; }
  .card .table-wrap:has(.table.stack) { margin: 0 -16px; }
  .table.stack td > * { align-self: flex-start; max-width: 100%; }
  .table.stack .badge { margin-left: 0; }
}
@media (pointer: coarse) { .link-btn:not(.center) { padding: 0 10px; margin: 0 -10px; min-width: 44px; justify-content: center; } }
