/* ══════════════════════════════════════════════════════════════
   ByteNet Digital CRM — design system
   Built around the ByteNet electric-blue mark, in two themes.

   Every colour lives in a token. The dark palette is the default on
   :root; [data-theme="light"] restates the same token names with
   light values, so no rule below needs to know which theme is on.
   Add a colour here, not in a rule, or the light theme won't follow.
   ══════════════════════════════════════════════════════════════ */

:root {
  color-scheme: dark;

  --bg:            #05070C;
  --bg-elev:       #0A0E17;
  --surface:       #0E1420;
  --surface-2:     #141B2A;
  --surface-3:     #1B2334;
  --line:          #1E2739;
  --line-soft:     #182031;
  --line-strong:   #2A354B;

  --text:          #E8EDF7;
  --text-dim:      #9AA6BC;
  --text-faint:    #64708A;

  --brand:         #1F6BFF;
  --brand-2:       #0EA5E9;
  --brand-deep:    #0B3FCC;
  --brand-glow:    rgba(31,107,255,.35);
  --grad:          linear-gradient(135deg, #0EA5E9 0%, #1F6BFF 48%, #0B3FCC 100%);
  --on-brand:      #fff;

  --ok:            #10B981;
  --warn:          #F59E0B;
  --danger:        #F43F5E;
  --info:          #38BDF8;
  --purple:        #A78BFA;

  /* foreground tones for tinted badges, flashes and chart series */
  --fg-blue:   #93B4FF;  --fg-green:  #6EE7B7;  --fg-amber:  #FCD34D;
  --fg-red:    #FDA4AF;  --fg-purple: #C4B5FD;  --fg-cyan:   #7DD3FC;
  --fg-grey:   #A5B0C2;
  --fg-red-hi: #FECDD3;  --fg-green-hi: #A7F3D0;

  --link-hover:    #7DD3FC;
  --nav-active-fg: #fff;
  --chip-on-fg:    #A9C4FF;
  --topbar-bg:     rgba(5,7,12,.82);
  --scrim:         rgba(2,4,8,.72);
  --scrollbar:     #1E2739;
  --scrollbar-hi:  #2A354B;
  --logo-glow:     drop-shadow(0 4px 16px rgba(31,107,255,.30));
  --chart-muted:   #243352;

  --r-sm: 7px; --r: 11px; --r-lg: 16px; --r-xl: 22px;
  --sidebar: 244px;
  --shadow: 0 4px 24px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 60px rgba(0,0,0,.6);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="light"] {
  color-scheme: light;

  --bg:            #F4F6FB;
  --bg-elev:       #FFFFFF;
  --surface:       #FFFFFF;
  --surface-2:     #F1F4FA;
  --surface-3:     #E4EAF4;
  --line:          #DDE4EF;
  --line-soft:     #EBEFF6;
  --line-strong:   #C2CDDE;

  --text:          #0D1626;
  --text-dim:      #4C5972;
  --text-faint:    #78859C;

  --brand:         #1F6BFF;
  --brand-2:       #0B72C4;
  --brand-deep:    #0B3FCC;
  --brand-glow:    rgba(31,107,255,.20);

  --ok:            #059669;
  --warn:          #B45309;
  --danger:        #DC2626;
  --info:          #0284C7;
  --purple:        #7C3AED;

  --fg-blue:   #1D4ED8;  --fg-green:  #047857;  --fg-amber:  #B45309;
  --fg-red:    #BE123C;  --fg-purple: #6D28D9;  --fg-cyan:   #0369A1;
  --fg-grey:   #475569;
  --fg-red-hi: #9F1239;  --fg-green-hi: #065F46;

  --link-hover:    #0B3FCC;
  --nav-active-fg: #0B3FCC;
  --chip-on-fg:    #1D4ED8;
  --topbar-bg:     rgba(255,255,255,.88);
  --scrim:         rgba(15,23,42,.42);
  --scrollbar:     #CBD5E1;
  --scrollbar-hi:  #94A3B8;
  --logo-glow:     none;
  --chart-muted:   #B9C7DE;

  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 6px 20px rgba(16,24,40,.07);
  --shadow-lg: 0 20px 50px rgba(16,24,40,.16);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { color: var(--link-hover); }
h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -.02em; }
img { max-width: 100%; }
::selection { background: var(--brand-glow); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hi); }

/* ─────────────── shell ─────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar); flex: 0 0 var(--sidebar); background: var(--bg-elev);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 40;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.sidebar-brand img.brand-lockup { height: 36px; width: auto; filter: var(--logo-glow); }
.sidebar-brand .bn-crm {
  font-size: 9.5px; letter-spacing: .18em; color: var(--text-faint); font-weight: 700;
  border-left: 1px solid var(--line); padding-left: 9px; align-self: center; margin-left: -2px;
}

.nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 2px; }
.nav-label {
  font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 700; padding: 6px 10px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--text-dim); font-size: 13.5px; font-weight: 500; margin-bottom: 1px;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: linear-gradient(90deg, rgba(31,107,255,.18), rgba(31,107,255,.04)); color: var(--nav-active-fg); box-shadow: inset 2px 0 0 var(--brand); }
.nav a svg { width: 16px; height: 16px; flex: 0 0 16px; opacity: .85; }
.nav a .count {
  margin-left: auto; font-size: 10.5px; font-weight: 700; background: var(--surface-3);
  color: var(--text-dim); padding: 1px 6px; border-radius: 20px; min-width: 20px; text-align: center;
}
.nav a.active .count { background: var(--brand); color: var(--on-brand); }
.nav a .count.hot { background: rgba(244,63,94,.2); color: var(--fg-red); }

.sidebar-foot { border-top: 1px solid var(--line-soft); padding: 10px; }
.userchip { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: var(--r-sm); }
.userchip:hover { background: var(--surface-2); }
.userchip .meta { min-width: 0; }
.userchip .nm { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userchip .rl { font-size: 10.5px; color: var(--text-faint); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 0 22px; height: 58px; background: var(--topbar-bg);
  backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 17px; }
.topbar .crumb { color: var(--text-faint); font-size: 12.5px; margin-top: 1px; }
.topbar .spacer { flex: 1; }

.searchbox { position: relative; width: min(340px, 34vw); }
/* input[type=search] in the forms section below matches with the same
   specificity and would otherwise win on source order, taking the left
   padding that keeps the text clear of the magnifier. */
.searchbox input[type=search] {
  width: 100%; background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: 20px; padding: 7px 12px 7px 32px; font-size: 13px; outline: none;
}
.searchbox input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,107,255,.13); }
.searchbox svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-faint); }
.search-results {
  position: absolute; top: 40px; left: 0; right: 0; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg);
  max-height: 60vh; overflow-y: auto; display: none; padding: 6px;
}
.search-results.open { display: block; }
.search-results .sr-group { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-faint); padding: 8px 10px 4px; font-weight: 700; }
.search-results a { display: block; padding: 7px 10px; border-radius: var(--r-sm); color: var(--text); font-size: 13px; }
.search-results a:hover, .search-results a.sel { background: var(--surface-3); }
.search-results a small { color: var(--text-faint); display: block; font-size: 11px; }

.content { padding: 22px; flex: 1; }
.content.wide { padding: 22px 22px 40px; }

/* ─────────────── buttons ─────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-size: 13px; font-weight: 550; cursor: pointer; transition: all .13s; white-space: nowrap;
  font-family: inherit; text-decoration: none;
}
.btn:hover { background: var(--surface-3); border-color: var(--line-strong); color: var(--text); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--grad); border-color: transparent; color: var(--on-brand); box-shadow: 0 2px 14px rgba(31,107,255,.3); }
.btn-primary:hover { color: var(--on-brand); filter: brightness(1.12); box-shadow: 0 3px 20px rgba(31,107,255,.45); }
.btn-danger { background: rgba(244,63,94,.12); border-color: rgba(244,63,94,.3); color: var(--fg-red); }
.btn-danger:hover { background: rgba(244,63,94,.2); color: var(--fg-red-hi); }
.btn-ok { background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.3); color: var(--fg-green); }
.btn-ok:hover { background: rgba(16,185,129,.2); color: var(--fg-green-hi); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-icon { padding: 6px; }
.btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ─────────────── cards & panels ─────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h3 { font-size: 14px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.g-1-2 { grid-template-columns: minmax(0,1fr) minmax(0,2fr); }
.g-3-2 { grid-template-columns: minmax(0,3fr) minmax(0,2fr); }

/* KPI tiles */
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px 16px; position: relative; overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--grad); opacity: .8;
}
.kpi .k-label { font-size: 11px; color: var(--text-faint); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.kpi .k-value { font-size: 25px; font-weight: 700; letter-spacing: -.03em; margin-top: 6px; line-height: 1.1; }
.kpi .k-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.kpi .k-icon {
  position: absolute; right: 14px; top: 14px; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; background: rgba(31,107,255,.12); color: var(--brand);
}
.kpi .k-icon svg { width: 16px; height: 16px; }
.trend-up { color: var(--ok); } .trend-down { color: var(--danger); }

/* ─────────────── tables ─────────────── */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 700; padding: 10px 14px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--bg-elev);
  position: sticky; top: 0; z-index: 2;
}
table.tbl th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
table.tbl th a:hover { color: var(--text); }
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tbl .mono { font-family: var(--mono); font-size: 12.5px; }
table.tbl a.rowlink { color: var(--text); font-weight: 550; }
table.tbl a.rowlink:hover { color: var(--brand-2); }
.tbl-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: .35; transition: opacity .12s; }
tr:hover .tbl-actions { opacity: 1; }

.empty { padding: 46px 20px; text-align: center; color: var(--text-faint); }
.empty svg { width: 34px; height: 34px; opacity: .35; margin-bottom: 10px; }
.empty h4 { font-size: 14px; color: var(--text-dim); margin-bottom: 4px; }

/* ─────────────── badges & pills ─────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2.5px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 650; letter-spacing: .02em; white-space: nowrap;
  background: var(--surface-3); color: var(--text-dim); border: 1px solid transparent;
}
.badge.dot::before { content:''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.b-blue   { background: rgba(31,107,255,.15);  color: var(--fg-blue); }
.b-green  { background: rgba(16,185,129,.14);  color: var(--fg-green); }
.b-amber  { background: rgba(245,158,11,.18);  color: var(--fg-amber); }
.b-red    { background: rgba(244,63,94,.14);   color: var(--fg-red); }
.b-purple { background: rgba(167,139,250,.18); color: var(--fg-purple); }
.b-cyan   { background: rgba(56,189,248,.16);  color: var(--fg-cyan); }
.b-grey   { background: rgba(148,163,184,.16); color: var(--fg-grey); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; color: #fff; flex: 0 0 auto; letter-spacing: -.02em;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 46px; height: 46px; font-size: 16px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -7px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ─────────────── forms ─────────────── */
.field { margin-bottom: 14px; }
.field label, .lbl {
  display: block; font-size: 11.5px; font-weight: 650; color: var(--text-dim);
  margin-bottom: 5px; letter-spacing: .01em;
}
.field .hint { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=tel], input[type=url], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; background: var(--bg-elev); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r-sm); padding: 8px 11px; font-size: 13.5px; font-family: inherit; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,107,255,.13); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { resize: vertical; min-height: 78px; line-height: 1.6; }
select {
  appearance: none;
  /* the chevron is a data URI, and a CSS variable cannot be interpolated into
     one — so the light theme swaps the whole image rather than the colour. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364708A' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}
[data-theme="light"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2378859C' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 15px; height: 15px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-row.c3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.form-row.c4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 0 0 16px; }
legend { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); font-weight: 700; padding: 0 7px; }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 13px; }
.input-prefix input { padding-left: 42px; }

/* filter bar */
.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px;
}
.filters input, .filters select { width: auto; min-width: 130px; padding: 6.5px 10px; font-size: 12.5px; }
.filters select { padding-right: 28px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 20px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px;
  color: var(--text-dim); cursor: pointer;
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.on { background: rgba(31,107,255,.16); border-color: rgba(31,107,255,.4); color: var(--chip-on-fg); }

/* ─────────────── kanban ─────────────── */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kcol {
  flex: 0 0 272px; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--r-lg); display: flex; flex-direction: column; max-height: calc(100vh - 200px);
}
.kcol-head { padding: 12px 13px 10px; border-bottom: 1px solid var(--line-soft); }
.kcol-head .t { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 650; }
.kcol-head .t .n { margin-left: auto; font-size: 11px; color: var(--text-faint); background: var(--surface-2); padding: 1px 7px; border-radius: 10px; }
.kcol-head .v { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; font-variant-numeric: tabular-nums; }
.kcol-head .bar { height: 2px; border-radius: 2px; margin-top: 8px; background: var(--surface-3); overflow: hidden; }
.kcol-head .bar i { display: block; height: 100%; background: var(--grad); }
.kbody { padding: 9px; overflow-y: auto; flex: 1; min-height: 80px; }
.kbody.drag-over { background: rgba(31,107,255,.06); box-shadow: inset 0 0 0 1px rgba(31,107,255,.35); border-radius: var(--r); }
.kcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 11px; margin-bottom: 8px; cursor: grab; transition: border-color .12s, transform .1s;
}
.kcard:hover { border-color: var(--line-strong); }
.kcard.dragging { opacity: .4; transform: rotate(1.5deg); }
.kcard .kt { font-size: 13px; font-weight: 600; line-height: 1.35; margin-bottom: 7px; }
.kcard .kt a { color: var(--text); }
.kcard .kt a:hover { color: var(--brand-2); }
.kcard .kmeta { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-faint); }
.kcard .kval { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; font-size: 13px; }
.kcard .kfoot { display: flex; align-items: center; gap: 6px; margin-top: 9px; }

/* ─────────────── timeline ─────────────── */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content:''; position: absolute; left: 10px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -22px; top: 3px; width: 21px; height: 21px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center;
}
.tl-dot svg { width: 11px; height: 11px; color: var(--text-dim); }
.tl-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tl-head .who { font-size: 13px; font-weight: 600; }
.tl-head .when { font-size: 11.5px; color: var(--text-faint); margin-left: auto; }
.tl-body { font-size: 13px; color: var(--text-dim); margin-top: 3px; white-space: pre-wrap; line-height: 1.55; }

/* ─────────────── misc ─────────────── */
.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.page-head h2 { font-size: 21px; letter-spacing: -.03em; }
.page-head .sub { color: var(--text-faint); font-size: 13px; margin-top: 3px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a {
  padding: 9px 14px; font-size: 13px; font-weight: 550; color: var(--text-dim);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--nav-active-fg); border-bottom-color: var(--brand); }

.flash {
  padding: 11px 15px; border-radius: var(--r); margin-bottom: 16px; font-size: 13.5px;
  display: flex; align-items: center; gap: 10px; border: 1px solid;
}
.flash svg { width: 17px; height: 17px; flex: 0 0 17px; }
.flash-ok { background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.3); color: var(--fg-green); }
.flash-err { background: rgba(244,63,94,.12); border-color: rgba(244,63,94,.3); color: var(--fg-red); }
.flash-info { background: rgba(31,107,255,.12); border-color: rgba(31,107,255,.3); color: var(--fg-blue); }
.flash-warn { background: rgba(245,158,11,.14); border-color: rgba(245,158,11,.32); color: var(--fg-amber); }
.flash .x { margin-left: auto; cursor: pointer; opacity: .6; }

.muted { color: var(--text-faint); }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.b { font-weight: 650; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-col { display: flex; flex-direction: column; gap: 8px; }
.wrap { flex-wrap: wrap; }
.mt0{margin-top:0}.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mt24{margin-top:24px}
.mb0{margin-bottom:0}.mb8{margin-bottom:8px}.mb12{margin-bottom:12px}.mb16{margin-bottom:16px}.mb24{margin-bottom:24px}
.hr { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

/* progress */
.prog { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--grad); border-radius: 4px; }
.prog.ok i { background: linear-gradient(90deg,#059669,#10B981); }
.prog.warn i { background: linear-gradient(90deg,#D97706,#F59E0B); }
.prog.danger i { background: linear-gradient(90deg,#E11D48,#F43F5E); }

/* modal */
.modal-bg {
  position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(3px);
  z-index: 100; display: none; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  width: min(600px, 100%); box-shadow: var(--shadow-lg); animation: pop .16s ease-out;
}
.modal.wide { width: min(920px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.99); } }
.modal-head { display: flex; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--line-soft); }
.modal-head h3 { font-size: 15px; flex: 1; }
.modal-body { padding: 18px; max-height: 68vh; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 13px 18px; border-top: 1px solid var(--line-soft); }

/* dropdown */
.dd { position: relative; }
.dd-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 5px;
  display: none; z-index: 60;
}
.dd.open .dd-menu { display: block; }
.dd-menu a, .dd-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border-radius: 6px;
  font-size: 13px; color: var(--text); background: none; border: 0; cursor: pointer;
  text-align: left; font-family: inherit;
}
.dd-menu a:hover, .dd-menu button:hover { background: var(--surface-3); color: var(--text); }
.dd-menu svg { width: 15px; height: 15px; opacity: .8; }
.dd-menu .sep { height: 1px; background: var(--line); margin: 5px 0; }
.dd-menu .danger { color: var(--fg-red); }

/* line-item editor */
.items-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-tbl th {
  font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--text-faint);
  font-weight: 700; text-align: left; padding: 0 8px 7px;
}
.items-tbl td { padding: 3px 4px; vertical-align: top; }
.items-tbl input, .items-tbl select, .items-tbl textarea { padding: 7px 9px; font-size: 13px; }
.items-tbl .lt { padding-top: 14px; font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.drag-handle { cursor: grab; color: var(--text-faint); padding-top: 12px; }

.totals-box { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.totals-box .row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.totals-box .row .k { color: var(--text-dim); }
.totals-box .row .v { font-variant-numeric: tabular-nums; font-weight: 550; }
.totals-box .grand {
  display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px;
  padding-top: 11px; border-top: 1px solid var(--line);
}
.totals-box .grand .k { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); font-weight: 700; }
.totals-box .grand .v { font-size: 21px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

/* charts */
.chart { width: 100%; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-dim); margin-top: 10px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

/* login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.auth-wrap::before {
  content: ''; position: absolute; width: 700px; height: 700px; border-radius: 50%;
  background: radial-gradient(circle, rgba(31,107,255,.16), transparent 66%); top: -230px; left: 50%;
  transform: translateX(-50%); pointer-events: none;
}
.auth-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 34px 30px; box-shadow: var(--shadow-lg); position: relative;
}
.auth-card .logo { text-align: center; margin-bottom: 22px; }
.auth-card .logo img { width: 178px; filter: var(--logo-glow); }
.auth-card h1 { font-size: 20px; text-align: center; margin-bottom: 5px; }
.auth-card .sub { text-align: center; color: var(--text-faint); font-size: 13px; margin-bottom: 24px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; }
.demo-creds {
  margin-top: 20px; padding: 12px 14px; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--r); font-size: 11.5px; color: var(--text-faint); line-height: 1.7;
}
.demo-creds b { color: var(--text-dim); }
.demo-creds code { font-family: var(--mono); color: var(--brand-2); cursor: pointer; }

/* public doc view */
.pub { max-width: 860px; margin: 0 auto; padding: 32px 20px 60px; }
.pub-head { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.pub-head img { filter: var(--logo-glow); }

/* print */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border-color: #ddd; }
}

/* responsive */
@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex !important; }
  .g2, .g3, .g4, .g-2-1, .g-1-2, .g-3-2 { grid-template-columns: minmax(0,1fr); }
  .form-row, .form-row.c3, .form-row.c4 { grid-template-columns: minmax(0,1fr); }
  .searchbox { width: 100%; }
  .content { padding: 16px; }
  .topbar { padding: 0 14px; }
}
.menu-btn { display: none; }
@media (max-width: 640px) {
  /* the topbar gets tight: one line for the title, the crumb moves out of the way */
  .topbar { gap: 8px; height: 54px; }
  .topbar h1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw; }
  .topbar .crumb { display: none; }
  .topbar .searchbox { width: 42vw; }
  .topbar .searchbox input { padding: 6px 10px 6px 28px; font-size: 12.5px; }
  .kpi .k-value { font-size: 21px; }
  table.tbl th, table.tbl td { padding: 9px 10px; }
  .page-head h2 { font-size: 18px; }
  .hide-sm { display: none !important; }
}
@media (max-width: 420px) {
  .topbar .searchbox { display: none; }
  .topbar h1 { max-width: 60vw; }
}

/* ─────────────── theme toggle ─────────────── */
/* One button, two glyphs: show the theme you would switch *to*. */
.theme-toggle .t-dark,
.theme-toggle .t-light { display: none; line-height: 0; }
[data-theme="dark"]  .theme-toggle .t-light { display: inline; }
[data-theme="light"] .theme-toggle .t-dark  { display: inline; }
.theme-toggle svg { width: 17px; height: 17px; }

/* Light theme sits on plain white cards, so the heavier dark-theme
   shadows and glows need toning down rather than reversing. */
[data-theme="light"] .btn-primary { box-shadow: 0 1px 2px rgba(11,63,204,.24), 0 4px 14px rgba(31,107,255,.22); }
[data-theme="light"] .kpi::after  { opacity: 1; }
[data-theme="light"] .auth-wrap::before { background: radial-gradient(circle, rgba(31,107,255,.10), transparent 66%); }
[data-theme="light"] .sidebar { box-shadow: inset -1px 0 0 var(--line-soft); }
[data-theme="light"] .nav a.active { background: linear-gradient(90deg, rgba(31,107,255,.13), rgba(31,107,255,.02)); }
[data-theme="light"] table.tbl th { background: var(--surface-2); }
[data-theme="light"] .kcol { background: var(--surface-2); }
[data-theme="light"] .totals-box,
[data-theme="light"] .demo-creds { background: var(--surface-2); }
[data-theme="light"] input[type=text], [data-theme="light"] input[type=email],
[data-theme="light"] input[type=password], [data-theme="light"] input[type=number],
[data-theme="light"] input[type=date], [data-theme="light"] input[type=tel],
[data-theme="light"] input[type=url], [data-theme="light"] input[type=datetime-local],
[data-theme="light"] input[type=search], [data-theme="light"] select,
[data-theme="light"] textarea { background: var(--surface); }
