/* SimFlex CRM design system
   Built from the SimFlex brand (violet / plum / orchid, Schibsted Grotesk + Source Sans 3).
   8px grid; every gap, radius and size below comes from the tokens. */

@font-face { font-family: "Schibsted Grotesk"; src: url("/fonts/schibsted-grotesk.woff2") format("woff2"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url("/fonts/source-sans-3.woff2") format("woff2"); font-weight: 200 900; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/ibm-plex-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  /* Surfaces */
  --bg: #f6f5f9;
  --surface: #ffffff;
  --surface-2: #faf9fc;
  --surface-hover: #f7f5fb;
  --line: #e8e4ef;
  --line-strong: #d6d0e0;
  /* Text */
  --ink: #1f1b24;
  --ink-2: #4a4453;
  --ink-3: #6b6576;
  --ink-inverse: #ffffff;
  /* Brand */
  --violet: #6048a7;
  --violet-hover: #513b93;
  --violet-soft: #efeaf8;
  --violet-softer: #f7f4fc;
  --plum: #854cab;
  --orchid: #b26dbd;
  --on-violet: #ffffff;
  --primary: #6048a7; --primary-hover: #513b93; --on-primary: #ffffff;
  /* Status */
  --green: #1d6b45; --green-soft: #e7f4ed; --green-line: #c4e5d2;
  --red: #a8291f; --red-soft: #fcefee; --red-line: #f2cbc7;
  --amber: #7d5300; --amber-soft: #fdf4e1; --amber-line: #f1dcab;
  --plum-ink: #74399a; --plum-soft: #f5edfa;
  /* Shape and depth */
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-full: 9999px;
  --shadow-xs: 0 1px 2px rgba(31, 27, 36, 0.05);
  --shadow-sm: 0 1px 2px rgba(31, 27, 36, 0.05), 0 2px 8px rgba(96, 72, 167, 0.06);
  --shadow-md: 0 8px 24px rgba(31, 27, 36, 0.10), 0 2px 6px rgba(31, 27, 36, 0.06);
  --ring: 0 0 0 3px rgba(96, 72, 167, 0.22);
  /* Type */
  --display: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  /* Layout */
  --sidebar-w: 248px;
  --topbar-h: 64px;
  color-scheme: light;
}

/* Dark theme: chosen by the person (data-theme="dark"), or following the device when they pick System */
:root[data-theme="dark"] {
    --bg: #0f0e13; --surface: #17151d; --surface-2: #1c1a23; --surface-hover: #221f2a;
    --line: #2a2733; --line-strong: #3a3645;
    --ink: #eeedf3; --ink-2: #c6c2d1; --ink-3: #928ca0;
    --violet: #ab9bf2; --violet-hover: #c0b4f6; --violet-soft: #252040; --violet-softer: #1d1a2e; --on-violet: #14121a;
    --primary: #6f56c9; --primary-hover: #7e66d6; --on-primary: #ffffff;
    --plum: #c79be0; --orchid: #d9a8e4;
    --green: #6fcf9c; --green-soft: #13261c; --green-line: #1f4130;
    --red: #ff8f85; --red-soft: #2e1718; --red-line: #4a2324;
    --amber: #eec36a; --amber-soft: #2a2211; --amber-line: #453716;
    --plum-ink: #d3a8ec; --plum-soft: #281d31;
    --shadow-xs: 0 1px 0 rgba(0,0,0,.25); --shadow-sm: 0 1px 2px rgba(0,0,0,.45), 0 4px 12px rgba(0,0,0,.25); --shadow-md: 0 16px 40px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.4);
    --ring: 0 0 0 3px rgba(171, 155, 242, 0.32);
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
      --bg: #0f0e13; --surface: #17151d; --surface-2: #1c1a23; --surface-hover: #221f2a;
      --line: #2a2733; --line-strong: #3a3645;
      --ink: #eeedf3; --ink-2: #c6c2d1; --ink-3: #928ca0;
      --violet: #ab9bf2; --violet-hover: #c0b4f6; --violet-soft: #252040; --violet-softer: #1d1a2e; --on-violet: #14121a;
      --primary: #6f56c9; --primary-hover: #7e66d6; --on-primary: #ffffff;
      --plum: #c79be0; --orchid: #d9a8e4;
      --green: #6fcf9c; --green-soft: #13261c; --green-line: #1f4130;
      --red: #ff8f85; --red-soft: #2e1718; --red-line: #4a2324;
      --amber: #eec36a; --amber-soft: #2a2211; --amber-line: #453716;
      --plum-ink: #d3a8ec; --plum-soft: #281d31;
      --shadow-xs: 0 1px 0 rgba(0,0,0,.25); --shadow-sm: 0 1px 2px rgba(0,0,0,.45), 0 4px 12px rgba(0,0,0,.25); --shadow-md: 0 16px 40px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.4);
      --ring: 0 0 0 3px rgba(171, 155, 242, 0.32);
      color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/20px var(--sans); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
a { color: var(--violet); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; font-family: var(--display); color: var(--ink); font-weight: 700; }
p { margin: 0; }
p + p { margin-top: 12px; }
img { max-width: 100%; }
code { font: 500 12.5px/1.4 var(--mono); background: var(--violet-soft); color: var(--ink); padding: 2px 6px; border-radius: var(--r-xs); }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-xs); }
::selection { background: var(--violet-soft); }
.i { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 22px; height: 22px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; line-height: 18px; }
.strong { font-weight: 600; color: var(--ink); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 24px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); padding: 0 12px 12px; overflow-y: auto; }
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; padding: 0 10px; flex: none; }
.sidebar-brand > a { display: block; width: 100%; }
.sidebar-brand img { width: 100%; height: auto; display: block; }
.logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-light { display: none !important; } :root:not([data-theme="light"]) .logo-dark { display: block !important; } }

.workspace { display: flex; align-items: center; gap: 10px; padding: 10px; margin: 4px 0 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); min-width: 0; }
.workspace-logo { width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--violet-soft); display: grid; place-items: center; overflow: hidden; flex: none; }
.workspace-logo.has-img { background: #fff; border: 1px solid var(--line); }
.workspace-logo img { max-width: 28px; max-height: 28px; object-fit: contain; }
.workspace-logo .initial { font: 700 13px/1 var(--display); color: var(--violet); }
.workspace-name { font-weight: 600; color: var(--ink); line-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-plan { font-size: 12px; line-height: 16px; color: var(--ink-3); white-space: nowrap; }

.nav-label { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink-3); padding: 16px 10px 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 600; font-size: 14px; }
.nav a .i { color: var(--ink-3); }
.nav a:hover { background: var(--surface-hover); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--violet-soft); color: var(--violet); }
.nav a.active .i { color: var(--violet); }
.nav .count { margin-left: auto; display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 5px; font-size: 12px; line-height: 1; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-full); }
.nav a.active .count { color: var(--violet); border-color: transparent; background: var(--surface); }
.nav .count.count-due { background: var(--red-soft); color: var(--red); border-color: transparent; }

.sidebar-foot { margin-top: auto; padding-top: 16px; }
.powered { display: block; font-size: 12px; line-height: 16px; color: var(--ink-3); padding: 0 10px; }
.powered strong { color: var(--violet); font-weight: 700; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 32px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar .mobile-brand { display: none; }
.search { position: relative; flex: 0 1 420px; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.topbar .search input { width: 100%; height: 38px; padding: 0 44px 0 38px; border-radius: var(--r-full); background: var(--surface); border: 1px solid var(--line); font: 400 14px/20px var(--sans); color: var(--ink); }
.topbar .search input::placeholder { color: var(--ink-3); }
.topbar .search input:focus { outline: none; border-color: var(--violet); box-shadow: var(--ring); }
.kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 500 11px/18px var(--mono); color: var(--ink-3); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; background: var(--surface-2); }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-md); padding: 6px; z-index: 40; }
.menu-head { padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-panel a, .menu-panel button { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border-radius: var(--r-sm); color: var(--ink-2); font: 600 14px/20px var(--sans); background: none; border: 0; cursor: pointer; text-align: left; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-hover); color: var(--ink); text-decoration: none; }
.menu-panel .i { color: var(--ink-3); }
.user-chip { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px 0 4px; border-radius: var(--r-full); border: 1px solid transparent; }
.user-chip:hover, .menu[open] .user-chip { background: var(--surface); border-color: var(--line); }

.content { width: 100%; max-width: 1360px; padding: 28px 32px 64px; }
.content.narrow { max-width: 920px; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-header h1 { font-size: 24px; line-height: 32px; letter-spacing: -0.015em; }
.page-sub { margin-top: 4px; color: var(--ink-3); font-size: 14px; line-height: 20px; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 18px; color: var(--ink-3); margin-bottom: 6px; font-weight: 600; }
.crumbs a { color: var(--ink-3); }
.crumbs a:hover { color: var(--ink); }
.crumbs .i { width: 14px; height: 14px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: var(--r-full); border: 1px solid transparent; font: 600 14px/20px var(--sans); cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s; }
.btn .i { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 1px 2px rgba(96, 72, 167, 0.25); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--ink-3); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--ink); }
.btn-soft { background: var(--violet-soft); color: var(--violet); }
.btn-soft:hover { background: color-mix(in srgb, var(--violet-soft) 70%, var(--violet) 12%); }
.btn-danger { background: var(--surface); color: var(--red); border-color: var(--red-line); }
.btn-danger:hover { background: var(--red-soft); }
.btn-wa { background: #1d7f4e; color: #fff; }
.btn-wa:hover { background: #176a41; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--violet); font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn.muted { color: var(--ink-3); }
.link-btn.danger { color: var(--red); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-xs); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.card-title { font: 700 15px/20px var(--display); color: var(--ink); letter-spacing: -0.005em; }
.card-sub { font-size: 13px; line-height: 18px; color: var(--ink-3); margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 12px 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--r-md) var(--r-md); }
.card-flush .card-body { padding: 0; }
.section-title { font: 700 13px/18px var(--display); color: var(--ink); margin-bottom: 12px; }

/* ---------- Grids ---------- */
.grid { display: grid; gap: 20px; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid-kpi { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
/* Dashboard: lists span three KPI columns, side panel the fourth, so every edge lines up */
.grid-dash { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; }
.grid-dash > :first-child { grid-column: span 3; }
.grid-dash > :last-child { grid-column: span 1; }
.record { display: grid; gap: 20px; grid-template-columns: 300px minmax(0, 1fr) 300px; align-items: start; }

/* ---------- KPI tiles ---------- */
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; color: var(--ink); }
a.kpi:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.kpi-label { display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink-3); }
.kpi-icon { width: 28px; height: 28px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--violet-soft); color: var(--violet); }
.kpi-icon .i { width: 16px; height: 16px; }
.kpi-icon.red { background: var(--red-soft); color: var(--red); }
.kpi-icon.green { background: var(--green-soft); color: var(--green); }
.kpi-icon.plum { background: var(--plum-soft); color: var(--plum-ink); }
.kpi-value { font: 700 28px/34px var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-foot { font-size: 13px; line-height: 18px; color: var(--ink-3); }

/* Pipeline bars */
.pipeline { display: flex; flex-direction: column; gap: 14px; }
.pipe-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 36px; align-items: center; gap: 12px; color: var(--ink); font-weight: 600; }
.pipe-row:hover { text-decoration: none; }
.pipe-row:hover .pipe-track { background: var(--line); }
.pipe-track { height: 8px; border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.pipe-fill { height: 100%; border-radius: var(--r-full); background: var(--violet); min-width: 0; }
.pipe-fill.lead { background: var(--orchid); } .pipe-fill.prospect { background: var(--plum); } .pipe-fill.qualified { background: var(--violet); } .pipe-fill.client { background: var(--green); } .pipe-fill.lost { background: var(--line-strong); }
.pipe-count { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: 12.5px; line-height: 16px; font-weight: 600; color: var(--ink-3); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .1s; }
.table tbody tr:hover td { background: var(--surface-hover); }
.table tr.clickable { cursor: pointer; }
.table .cell-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.table .name { font-weight: 600; color: var(--ink); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table a.name:hover { color: var(--violet); }
.table .sub { font-size: 13px; line-height: 18px; color: var(--ink-3); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.card > .table-wrap:first-child .table th:first-child { border-top-left-radius: var(--r-md); }
.card > .table-wrap:first-child .table th:last-child { border-top-right-radius: var(--r-md); }
.table-footer { padding: 12px 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }

/* ---------- Avatars ---------- */
.avatar { width: 32px; height: 32px; border-radius: var(--r-full); display: inline-grid; place-items: center; flex: none; font: 700 12px/1 var(--display); letter-spacing: .02em; background: var(--violet-soft); color: var(--violet); }
.avatar.t2 { background: var(--plum-soft); color: var(--plum-ink); }
.avatar.t3 { background: color-mix(in srgb, var(--orchid) 18%, var(--surface)); color: color-mix(in srgb, var(--orchid) 60%, var(--ink)); }
.avatar.t4 { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.xl { width: 72px; height: 72px; font-size: 24px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-full); font-size: 12.5px; line-height: 16px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.badge.neutral { background: var(--surface-2); color: var(--ink-2); }
.badge.plum { background: var(--plum-soft); color: var(--plum-ink); border-color: transparent; }
.badge.violet { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.badge.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.badge.muted { background: transparent; color: var(--ink-3); }
.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: var(--r-full); font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); margin: 0 6px 6px 0; }
a.tag:hover { border-color: var(--violet); color: var(--violet); text-decoration: none; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.dot.ok { background: var(--green); } .dot.bad { background: var(--red); } .dot.warn { background: var(--amber); } .dot.brand { background: var(--violet); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.label, .field > label { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink-2); }
.label .opt, .field > label .opt { font-weight: 400; color: var(--ink-3); }
.help { font-size: 12.5px; line-height: 17px; color: var(--ink-3); }
.input, input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=date], input[type=search], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 400 14px/20px var(--sans); transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 120px; padding: 10px 12px; line-height: 22px; resize: vertical; }
select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6576' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: .8; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); box-shadow: var(--ring); }
input[type=file] { font: 400 14px/20px var(--sans); color: var(--ink-2); }
input[type=file]::file-selector-button { font: 600 13px/20px var(--sans); height: 32px; padding: 0 14px; margin-right: 12px; border-radius: var(--r-full); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { padding: 24px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; }
.form-section:last-of-type { border-bottom: 0; }
.form-section-head h3 { font-size: 15px; line-height: 20px; }
.form-section-head p { font-size: 13px; line-height: 18px; color: var(--ink-3); margin-top: 4px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; line-height: 20px; color: var(--ink-2); cursor: pointer; margin-bottom: 12px; }
.check:last-child { margin-bottom: 0; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--violet); flex: none; cursor: pointer; }
.check strong { color: var(--ink); }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.toolbar .search-inline { position: relative; flex: 1 1 260px; max-width: 360px; }
.toolbar .search-inline .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 16px; height: 16px; }
.toolbar .search-inline input { height: 36px; padding-left: 34px; }
.toolbar select { height: 36px; width: auto; min-width: 140px; font-size: 13.5px; }
.toolbar .check { margin: 0 4px; font-size: 13.5px; align-items: center; }
.toolbar .check input { margin: 0; }
.code-input { font: 500 20px/1 var(--mono) !important; letter-spacing: .25em; text-align: center; height: 48px !important; }

/* ---------- Alerts ---------- */
.flash, .alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); font-size: 14px; line-height: 20px; color: var(--ink-2); margin-bottom: 20px; box-shadow: var(--shadow-xs); }
.flash .i, .alert .i { margin-top: 1px; }
.flash.success, .alert.success { background: var(--green-soft); border-color: var(--green-line); color: var(--green); }
.flash.error, .alert.error { background: var(--red-soft); border-color: var(--red-line); color: var(--red); }
.alert.info { background: var(--violet-softer); border-color: var(--violet-soft); color: var(--ink-2); }
.alert.info .i { color: var(--violet); }
.alert.warn { background: var(--amber-soft); border-color: var(--amber-line); color: var(--amber); }
.flash strong, .alert strong { font-weight: 700; }
.alert a, .alert .link-btn { font-weight: 700; color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.errors ul { margin: 0; padding-left: 18px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 32px; font-size: 13.5px; line-height: 20px; background: var(--violet-softer); border-bottom: 1px solid var(--violet-soft); color: var(--ink-2); }
.banner .i { color: var(--violet); }
.banner a, .banner .link-btn { font-weight: 700; }
.banner.warn { background: var(--red-soft); border-color: var(--red-line); color: var(--red); }
.banner.warn .i, .banner.warn a { color: var(--red); }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 48px 24px; }
.empty-icon { width: 48px; height: 48px; border-radius: var(--r-full); background: var(--violet-soft); color: var(--violet); display: grid; place-items: center; margin: 0 auto 14px; }
.empty-icon .i { width: 22px; height: 22px; }
.empty h3, .empty h1 { font-size: 16px; line-height: 22px; }
.empty p { color: var(--ink-3); margin: 6px auto 18px; max-width: 380px; }
.empty .actions { justify-content: center; }
.empty.compact { padding: 28px 20px; }
.empty.compact p { margin-bottom: 0; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); color: var(--ink); }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-hover); text-decoration: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { font-size: 13px; line-height: 18px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Checklist */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .tick { width: 22px; height: 22px; border-radius: 50%; border: 1.5px dashed var(--line-strong); display: grid; place-items: center; flex: none; color: transparent; }
.checklist li.done .tick { border: 0; background: var(--green); color: #fff; }
.checklist li.done .tick .i { width: 14px; height: 14px; }
.checklist li.done .step { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.checklist .step { flex: 1; font-weight: 600; color: var(--ink); }
.progress { height: 6px; border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--violet); border-radius: var(--r-full); }

/* Properties (definition lists) */
.props { margin: 0; display: grid; gap: 14px; }
.props > div { min-width: 0; }
.props dt { font-size: 12.5px; line-height: 16px; color: var(--ink-3); font-weight: 600; margin-bottom: 3px; }
.props dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.props dd.empty-val { color: var(--ink-3); }
.kv { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--ink-3); font-weight: 600; font-size: 13px; }
.kv dd { margin: 0; color: var(--ink); text-align: right; overflow-wrap: anywhere; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 10px; font-weight: 600; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab .i { width: 16px; height: 16px; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--violet); border-bottom-color: var(--violet); }
.panel { display: none; padding: 20px; }
.panel.active { display: block; }
.compose-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); margin-bottom: 16px; }
.compose-meta strong { color: var(--ink); font-weight: 600; }
.compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-top: 16px; }
.compose-foot > .help { flex: 1 1 260px; }
.compose-foot > .btn, .compose-foot > .actions { margin-left: auto; }

/* ---------- Record (contact) page ---------- */
.profile { text-align: center; padding: 24px 20px 20px; }
.profile .avatar { margin: 0 auto 12px; }
.profile h1 { font-size: 20px; line-height: 26px; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.profile .role { color: var(--ink-3); margin-top: 4px; }
.profile .badge { margin-top: 12px; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 16px 12px; border-top: 1px solid var(--line); }
.quick a, .quick button { display: flex; flex-direction: column; align-items: center; gap: 6px; font: 600 12px/16px var(--sans); color: var(--ink-2); background: none; border: 0; cursor: pointer; padding: 4px 0; border-radius: var(--r-sm); }
.quick a:hover, .quick button:hover { text-decoration: none; color: var(--violet); }
.quick .qi { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--violet-soft); color: var(--violet); transition: background-color .12s; }
.quick a:hover .qi { background: var(--primary); color: var(--on-primary); }
.quick .disabled { opacity: .4; pointer-events: none; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 8px 20px 20px; position: relative; }
.timeline li { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 14px; padding-top: 16px; }
.timeline li::before { content: ""; position: absolute; left: 17.5px; top: 52px; bottom: -16px; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.t-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-3); position: relative; z-index: 1; }
.t-icon .i { width: 16px; height: 16px; }
.t-icon.email { background: var(--violet-soft); border-color: transparent; color: var(--violet); }
.t-icon.whatsapp { background: var(--green-soft); border-color: transparent; color: var(--green); }
.t-icon.call, .t-icon.meeting { background: var(--plum-soft); border-color: transparent; color: var(--plum-ink); }
.t-card { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: 12px 16px; min-width: 0; }
.t-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 13px; line-height: 18px; color: var(--ink-3); }
.t-head .what { font-weight: 700; color: var(--ink); font-size: 14px; }
.t-head .when { margin-left: auto; white-space: nowrap; }
.t-subject { font-weight: 600; color: var(--ink); margin-top: 6px; }
.t-body { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); line-height: 21px; }
.t-body.clamp { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.t-status { font-weight: 600; }
.t-status.ok { color: var(--green); } .t-status.bad { color: var(--red); }
.t-simple { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 13.5px; color: var(--ink-2); }
.t-simple .when { margin-left: auto; color: var(--ink-3); font-size: 13px; white-space: nowrap; }

/* ---------- Plans / billing ---------- */
.plan { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.plan-price { font: 700 32px/38px var(--display); letter-spacing: -0.02em; }
.plan-price small { font: 600 14px/20px var(--sans); color: var(--ink-3); letter-spacing: 0; }
.feature-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; }
.feature-list li { display: flex; gap: 8px; align-items: flex-start; color: var(--ink-2); }
.feature-list .i { color: var(--green); width: 16px; height: 16px; margin-top: 2px; }

/* ---------- Two-factor ---------- */
.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; gap: 24px; }
.steps > li { counter-increment: s; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 14px; }
.steps > li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--violet-soft); color: var(--violet); font: 700 13px/1 var(--display); }
.steps h4 { font-size: 15px; line-height: 22px; }
.steps p { color: var(--ink-3); margin-top: 2px; }
.qr { display: inline-block; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); margin: 12px 0 8px; }
.qr img { display: block; width: 176px; height: 176px; }
.secret { display: inline-block; font: 500 13px/1.4 var(--mono); letter-spacing: .08em; padding: 6px 10px; margin-top: 4px; overflow-wrap: anywhere; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; padding: 20px 24px; border-radius: var(--r-md); background: var(--surface-2); border: 1px dashed var(--line-strong); font: 500 16px/24px var(--mono); color: var(--ink); max-width: 440px; }

/* ---------- Logo upload ---------- */
.logo-box { width: 100%; height: 96px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); background: #fff; display: grid; place-items: center; margin-bottom: 12px; padding: 12px; }
.logo-box img { max-height: 64px; max-width: 80%; object-fit: contain; }
.logo-box .placeholder { color: #6b6576; font-size: 13px; display: flex; align-items: center; gap: 8px; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--surface); }
.auth-aside { position: relative; overflow: hidden; background: #16131c; color: #e9e4f2; padding: 48px 56px; display: flex; flex-direction: column; }
.auth-aside img { height: 26px; width: auto; align-self: flex-start; }
.auth-aside .pitch { margin: auto 0; max-width: 460px; }
.auth-aside h2 { color: #fff; font-size: 40px; line-height: 46px; letter-spacing: -0.025em; font-weight: 800; }
.auth-aside h2 span { color: #b9a6f0; }
.auth-aside p { color: #b3abc0; font-size: 16px; line-height: 26px; margin-top: 16px; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; color: #e9e4f2; font-size: 15px; line-height: 22px; }
.auth-points .pi { width: 28px; height: 28px; border-radius: 8px; background: rgba(185, 166, 240, .14); color: #b9a6f0; display: grid; place-items: center; flex: none; }
.auth-points .pi .i { width: 16px; height: 16px; }
.auth-aside .bars { position: absolute; right: -60px; bottom: -40px; display: grid; gap: 22px; opacity: .14; pointer-events: none; }
.auth-aside .bars span { display: block; height: 44px; border-radius: 9999px; }
.auth-aside .bars span:nth-child(1) { width: 420px; background: #6048a7; }
.auth-aside .bars span:nth-child(2) { width: 360px; background: #854cab; }
.auth-aside .bars span:nth-child(3) { width: 300px; background: #b26dbd; }
.auth-aside .foot { font-size: 13px; color: #8f879c; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .mobile-logo { display: none; height: 24px; margin-bottom: 32px; }
.auth-card h1 { font-size: 28px; line-height: 34px; letter-spacing: -0.02em; }
.auth-card .lead { color: var(--ink-3); font-size: 15px; line-height: 22px; margin: 8px 0 28px; }
.auth-card .field { margin-bottom: 18px; }
.auth-card input:not([type=checkbox]) { height: 44px; font-size: 15px; }
.auth-links { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 20px; font-size: 14px; }
.auth-links.center { justify-content: center; }
.auth-divider { border-top: 1px solid var(--line); margin: 28px 0 20px; }
.honey { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.label-row a { font-size: 13px; font-weight: 600; }

/* ---------- Standalone (error, WhatsApp hand-off) ---------- */
.standalone { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.standalone .card { width: 100%; max-width: 460px; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .record { grid-template-columns: 280px minmax(0, 1fr); }
  .record > .record-aside { grid-column: 1; }
}
@media (max-width: 1100px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-dash { grid-template-columns: minmax(0, 1fr); }
  .grid-dash > :first-child, .grid-dash > :last-child { grid-column: auto; }
  .form-section { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}
@media (max-width: 960px) {
  .record { grid-template-columns: minmax(0, 1fr); }
  .record > .record-aside { grid-column: auto; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .auth-card .mobile-logo { display: block; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  :root { --topbar-h: 56px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-md); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(18, 16, 23, .4); z-index: 45; }
  .topbar { padding: 0 16px; }
  .topbar .mobile-brand { display: flex; align-items: center; gap: 4px; }
  .topbar .mobile-brand img { height: 20px; }
  .search { display: none; }
  .content { padding: 20px 16px 48px; }
  .banner { padding: 10px 16px; }
  .page-header { margin-bottom: 20px; }
  .page-header h1 { font-size: 22px; line-height: 28px; }
  .hide-sm { display: none !important; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .feature-list { grid-template-columns: minmax(0, 1fr); }
  .table th:first-child, .table td:first-child { padding-left: 16px; }
  .table th:last-child, .table td:last-child { padding-right: 16px; }
  .toolbar { padding: 12px 16px; }
  .toolbar .search-inline { max-width: none; }
  .card-header, .card-body, .panel { padding-left: 16px; padding-right: 16px; }
  .timeline { padding-left: 16px; padding-right: 16px; }
  .user-chip .who { display: none; }
}
@media (min-width: 861px) { .nav-toggle { display: none !important; } }
@media (max-width: 560px) {
  .grid-kpi { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
  .kpi { padding: 14px 16px; }
  .kpi-value { font-size: 24px; line-height: 30px; }
  .codes { grid-template-columns: minmax(0, 1fr); }
  .t-head .when { margin-left: 0; width: 100%; }
}
@media print {
  .sidebar, .topbar, .banner, .flash, .actions, .no-print { display: none !important; }
  .app { display: block; } body { background: #fff; }
}

/* ---------- Contact views: switcher, board, cards ---------- */
.i-xs { width: 13px; height: 13px; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-full); box-shadow: var(--shadow-xs); }
.segmented a { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: var(--r-full); font: 600 13px/18px var(--sans); color: var(--ink-3); }
.segmented a .i { width: 16px; height: 16px; }
.segmented a:hover { color: var(--ink); background: var(--surface-hover); text-decoration: none; }
.segmented a.active { background: var(--violet-soft); color: var(--violet); }

.card-menu > summary { color: var(--ink-3); }
.card-menu .menu-panel { min-width: 200px; right: 0; }
.card-menu .menu-panel form { margin: 0; }
.card-menu .menu-panel button { height: 34px; }
.card-menu .menu-head { padding: 6px 10px 8px; margin-bottom: 4px; }

/* Board (kanban) */
.card-board { background: var(--surface); }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(208px, 1fr); gap: 12px; padding: 16px; overflow-x: auto; scroll-snap-type: x proximity; background: var(--surface-2); border-radius: 0 0 var(--r-md) var(--r-md); min-height: 420px; }
.board-col { display: flex; flex-direction: column; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); scroll-snap-align: start; }
.board-col-head { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--line); }
.pipe-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pipe-dot.lead { background: var(--orchid); } .pipe-dot.prospect { background: var(--plum); } .pipe-dot.qualified { background: var(--violet); } .pipe-dot.client { background: var(--green); } .pipe-dot.lost { background: var(--line-strong); }
.board-list { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 10px; min-height: 120px; border-radius: 0 0 var(--r-md) var(--r-md); transition: background-color .12s, box-shadow .12s; }
.board-list.drop-over { background: var(--violet-softer); box-shadow: inset 0 0 0 2px var(--violet); }
.board-empty { display: grid; place-items: center; min-height: 72px; border: 1.5px dashed var(--line-strong); border-radius: var(--r-sm); color: var(--ink-3); font-size: 13px; }
.board-empty[hidden] { display: none; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; box-shadow: var(--shadow-xs); cursor: grab; transition: box-shadow .12s, border-color .12s, transform .12s; }
.kcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.kcard.dragging { opacity: .5; transform: rotate(1.5deg); cursor: grabbing; }
.kcard.saving { opacity: .6; pointer-events: none; }
.kcard-top { display: flex; align-items: flex-start; gap: 10px; }
.kcard-name { display: block; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 20px; }
.kcard-name:hover { color: var(--violet); text-decoration: none; }
.kcard-sub { font-size: 13px; line-height: 18px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; min-height: 24px; }
.kcard-meta { font-size: 12.5px; line-height: 16px; color: var(--ink-3); }
.kcard .card-menu > summary { margin: -4px -6px 0 0; }

/* Cards grid */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; padding: 20px; background: var(--surface-2); }
.ccard { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px; box-shadow: var(--shadow-xs); cursor: pointer; transition: box-shadow .12s, border-color .12s, transform .12s; min-width: 0; }
.ccard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.ccard-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.ccard-head .avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.ccard-name { font: 700 16px/22px var(--display); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -0.005em; }
.ccard-name:hover { color: var(--violet); text-decoration: none; }
.ccard-sub { font-size: 13px; line-height: 18px; color: var(--ink-3); min-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.ccard-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ccard-props { margin: 14px 0 0; display: grid; gap: 6px; }
.ccard-props > div { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ccard-props dt { color: var(--ink-3); display: flex; }
.ccard-props dd { margin: 0; font-size: 13.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccard-tags { margin-top: -4px; }
.ccard-tags .tag { margin-bottom: 0; }
.ccard-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.ccard-props, .ccard-tags { margin-bottom: 16px; }
.btn.is-off { opacity: .35; pointer-events: none; }

@media (max-width: 860px) {
  .segmented span { display: none; }
  .segmented a { padding: 0 10px; }
  .board { grid-auto-columns: 82%; padding: 12px; }
  .cards-grid { padding: 12px; gap: 12px; grid-template-columns: minmax(0, 1fr); }
}

/* Appearance switch (user menu and My settings) */
.theme-switch { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px 10px; margin: 0 0 6px; border-bottom: 1px solid var(--line); }
.menu-panel .segmented.sm button { width: 34px; height: 28px; padding: 0; justify-content: center; border-radius: var(--r-full); color: var(--ink-3); }
.segmented button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 12px; border: 0; background: none; border-radius: var(--r-full); font: 600 13px/18px var(--sans); color: var(--ink-3); cursor: pointer; }
.segmented button .i { width: 16px; height: 16px; }
.segmented button:hover { color: var(--ink); background: var(--surface-hover); }
.segmented button.active { background: var(--violet-soft); color: var(--violet); }
.theme-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.theme-card { display: flex; flex-direction: column; gap: 10px; padding: 10px; border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--surface); cursor: pointer; font: 600 14px/20px var(--sans); color: var(--ink); text-align: left; }
.theme-card:hover { border-color: var(--line-strong); }
.theme-card.active { border-color: var(--violet); box-shadow: var(--ring); }
.theme-card .row { gap: 8px; }
.theme-card .i { width: 16px; height: 16px; color: var(--ink-3); }
.theme-preview { height: 72px; border-radius: var(--r-sm); border: 1px solid var(--line); display: grid; grid-template-columns: 26% 1fr; overflow: hidden; }
.theme-preview .tp-side { border-right: 1px solid; }
.theme-preview .tp-main { padding: 8px; display: grid; gap: 6px; align-content: start; }
.theme-preview .tp-main span { display: block; height: 8px; border-radius: 4px; }
.theme-preview.light { background: #f6f5f9; border-color: #e8e4ef; } .theme-preview.light .tp-side { background: #fff; border-color: #e8e4ef; } .theme-preview.light .tp-main span { background: #fff; border: 1px solid #e8e4ef; height: 14px; } .theme-preview.light .tp-main span:first-child { background: #6048a7; border: 0; width: 40%; height: 8px; }
.theme-preview.dark { background: #0f0e13; border-color: #2a2733; } .theme-preview.dark .tp-side { background: #17151d; border-color: #2a2733; } .theme-preview.dark .tp-main span { background: #17151d; border: 1px solid #2a2733; height: 14px; } .theme-preview.dark .tp-main span:first-child { background: #6f56c9; border: 0; width: 40%; height: 8px; }
.theme-preview.system { background: linear-gradient(90deg, #f6f5f9 50%, #0f0e13 50%); grid-template-columns: 1fr; }
@media (max-width: 560px) { .theme-cards { grid-template-columns: minmax(0, 1fr); } }

/* Round counters: a perfect circle for 1–2 digits, a pill only if it grows longer */
.count-dot { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-width: 24px; height: 24px; padding: 0 5px; border-radius: var(--r-full); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); font: 600 12px/1 var(--sans); font-variant-numeric: tabular-nums; }
.tab.active .count-dot { background: var(--violet-soft); border-color: transparent; color: var(--violet); }

/* ---------- Mobile app ---------- */
/* Bottom tab bar on phones */
.tabbar { display: none; }
@media (max-width: 860px) {
  .tabbar { position: fixed; z-index: 35; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 4px; background: none; border: 0; color: var(--ink-3); font: 600 11px/14px var(--sans); text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .tabbar .i { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--violet); }
  .tabbar .tab-ic { position: relative; display: inline-flex; }
  .tabbar .tab-badge { position: absolute; top: -7px; left: 13px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; display: grid; place-items: center; background: var(--red); color: #fff; font: 700 10px/1 var(--sans); border: 2px solid var(--surface); box-sizing: content-box; }
  .tabbar .tab-new { align-self: center; }
  .tab-plus { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 16px rgba(96, 72, 167, 0.35); }
  .tab-plus .i { width: 24px; height: 24px; }
  .main { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .topbar .nav-toggle, .topbar > .btn-primary { display: none !important; }
  .topbar { padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); }
  .sidebar { padding-top: env(safe-area-inset-top); padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
/* Feels like an app once installed: no text selection on controls, no pull-to-refresh bounce on the shell */
.is-standalone .tabbar a, .is-standalone .tabbar button, .is-standalone .nav a { -webkit-user-select: none; user-select: none; }
.is-standalone body { overscroll-behavior-y: none; }

/* Install sheet */
.install-sheet[hidden] { display: none; }
.install-sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(15, 14, 19, 0.45); animation: fade .2s ease; }
.sheet-card { position: relative; width: 100%; max-width: 520px; background: var(--surface); border-radius: 20px 20px 0 0; padding: 10px 20px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-md); animation: rise .28s cubic-bezier(.2, .8, .2, 1); max-height: 90vh; overflow-y: auto; }
.sheet-grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 0 auto 14px; }
.sheet-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.sheet-icon { border-radius: 12px; border: 1px solid var(--line); flex: none; }
.sheet-title { font: 700 18px/24px var(--display); color: var(--ink); letter-spacing: -0.01em; }
.sheet-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 861px) { .sheet-card { border-radius: 20px; margin-bottom: 24px; } }

/* Install steps */
.isteps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.isteps li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start; color: var(--ink-2); line-height: 22px; }
.istep-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--violet-soft); color: var(--violet); font: 700 13px/1 var(--display); }
.kbd-icon { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--violet); vertical-align: middle; margin: 0 2px; }
.kbd-icon .i { width: 16px; height: 16px; }
.install-now[hidden], [data-install-now][hidden] { display: none !important; }
.qr-img { border-radius: var(--r-md); border: 1px solid var(--line); background: #fff; padding: 8px; }
@media (max-width: 860px) { .qr-card { display: none; } }

/* Phones: keep cards to the essentials */
@media (max-width: 860px) {
  .kpi-foot, .card-sub { display: none; }
  .kpi { gap: 4px; }
  .card-header { min-height: 52px; }
}
.show-sm { display: none; }
@media (max-width: 860px) { .show-sm { display: inline; } .kpi-label { white-space: nowrap; } }
@media (min-width: 961px) { html body .auth-card img.mobile-logo.mobile-logo { display: none !important; } }
:root[data-theme="dark"] .auth-main { background: var(--bg); }
:root[data-theme="dark"] .auth-aside { border-right: 1px solid var(--line); background: #17151d; }
