/* ============================================================
   TheTechGear-BizSuite-lite — design system
   Six accent themes × light/dark appearance
   ============================================================ */

/* Self-hosted UI font. Served from this site on purpose: a few Windows
   machines resolve the system font stack to a symbol font and render the
   whole page as dingbats, so text must not depend on installed fonts. */
@font-face {
  font-family: "BizSuite Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "BizSuite Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --font: "Segoe UI", "BizSuite Sans", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --display: "Segoe UI", "BizSuite Sans", system-ui, sans-serif;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --sidebar-w: 266px;
  --shadow-sm: 0 2px 8px rgba(6, 8, 20, .16);
  --shadow: 0 18px 50px -22px rgba(6, 8, 20, .55);
  --shadow-lg: 0 40px 80px -30px rgba(6, 8, 20, .7);
  --brand: #7c5cff;
  --brand-2: #22d3ee;
  --accent: #f472b6;
  --brand-soft: rgba(124, 92, 255, .16);
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;

  /* Side-rail surface tokens — overridden by html[data-rail="…"] below.
     Defaults mirror the page panel so "Auto" looks exactly like before. */
  --rail-fg: var(--text);
  --rail-fg-dim: var(--text-dim);
  --rail-muted: var(--muted);
  --rail-surface: var(--surface);
  --rail-surface-2: var(--surface-3);
  --rail-border: var(--border);
  --rail-hover: var(--hover);
  --rail-active-bg: linear-gradient(90deg, color-mix(in srgb, var(--brand) 24%, transparent), color-mix(in srgb, var(--brand) 6%, transparent));
  --rail-active-fg: var(--text);
  --rail-active-ring: color-mix(in srgb, var(--brand) 28%, transparent);
  --rail-active-icon: var(--brand-2);
}

html[data-theme="aurora"] { --brand: #7c5cff; --brand-2: #22d3ee; --accent: #f472b6; }
html[data-theme="ember"]   { --brand: #ff6a3d; --brand-2: #ffc247; --accent: #fb7185; }
html[data-theme="forest"]  { --brand: #12b981; --brand-2: #a3e635; --accent: #2dd4bf; }
html[data-theme="ocean"]   { --brand: #3b82f6; --brand-2: #22d3ee; --accent: #818cf8; }
html[data-theme="orchid"]  { --brand: #d946ef; --brand-2: #fb923c; --accent: #f43f5e; }
html[data-theme="ink"]     { --brand: #334155; --brand-2: #64748b; --accent: #94a3b8; }

html[data-mode="dark"] {
  --bg: #080a14;
  --bg-grad: radial-gradient(1200px 700px at 85% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 60%),
             radial-gradient(900px 600px at -10% 20%, color-mix(in srgb, var(--brand-2) 12%, transparent), transparent 55%),
             #080a14;
  --surface: rgba(20, 23, 42, .82);
  --surface-solid: #121528;
  --surface-2: #171b31;
  --surface-3: #1d2240;
  --border: rgba(255, 255, 255, .085);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #eef0ff;
  --text-dim: #c3c8e2;
  --muted: #9299ba;
  --sidebar-bg: linear-gradient(180deg, #10132a 0%, #0b0e1d 55%, #0a0c19 100%);
  --field-bg: rgba(9, 11, 24, .55);
  --hover: rgba(255, 255, 255, .05);
  --active: rgba(255, 255, 255, .08);
  --table-stripe: rgba(255, 255, 255, .018);
  --scroll: #2a2f52;
}

html[data-mode="light"] {
  --bg: #f5f6fb;
  --bg-grad: radial-gradient(1100px 600px at 90% -10%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 60%),
             radial-gradient(800px 500px at 0% 10%, color-mix(in srgb, var(--brand-2) 10%, transparent), transparent 55%),
             #f5f6fb;
  --surface: rgba(255, 255, 255, .86);
  --surface-solid: #ffffff;
  --surface-2: #f4f5fb;
  --surface-3: #eceef8;
  --border: rgba(18, 22, 45, .09);
  --border-strong: rgba(18, 22, 45, .18);
  --text: #14172b;
  --text-dim: #3c4260;
  --muted: #6d7390;
  --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #f7f8fe 100%);
  --field-bg: #ffffff;
  --hover: rgba(20, 23, 43, .045);
  --active: rgba(20, 23, 43, .07);
  --table-stripe: rgba(20, 23, 43, .018);
  --scroll: #cbd0e4;
  --shadow: 0 18px 44px -26px rgba(20, 23, 43, .35);
  --shadow-lg: 0 40px 90px -40px rgba(20, 23, 43, .4);
}

/* ---------- Side-rail appearances (independent of accent + mode) ---------- */
/* Ink — deep blue-graphite with a lit active pill. */
html[data-rail="ink"] {
  --sidebar-bg: linear-gradient(180deg, #161c33 0%, #0d1122 55%, #090c18 100%);
  --rail-fg: #f4f6ff;
  --rail-fg-dim: #b9c1dd;
  --rail-muted: #8a93b3;
  --rail-surface: rgba(255, 255, 255, .055);
  --rail-surface-2: rgba(255, 255, 255, .14);
  --rail-border: rgba(255, 255, 255, .095);
  --rail-hover: rgba(255, 255, 255, .07);
  --rail-active-bg: linear-gradient(100deg, color-mix(in srgb, var(--brand) 62%, #0b0f1e), color-mix(in srgb, var(--brand) 22%, transparent));
  --rail-active-fg: #ffffff;
  --rail-active-ring: rgba(255, 255, 255, .16);
  --rail-active-icon: #ffffff;
}
/* Brand — the accent colour poured into a deep gradient. */
html[data-rail="brand"] {
  --sidebar-bg: linear-gradient(180deg, color-mix(in srgb, var(--brand) 52%, #08051a) 0%, color-mix(in srgb, var(--brand) 26%, #0a0620) 48%, color-mix(in srgb, var(--brand) 10%, #08051a) 100%);
  --rail-fg: #f7f5ff;
  --rail-fg-dim: color-mix(in srgb, #ffffff 74%, var(--brand));
  --rail-muted: color-mix(in srgb, #ffffff 46%, var(--brand));
  --rail-surface: rgba(255, 255, 255, .09);
  --rail-surface-2: rgba(255, 255, 255, .18);
  --rail-border: rgba(255, 255, 255, .14);
  --rail-hover: rgba(255, 255, 255, .12);
  --rail-active-bg: linear-gradient(135deg, color-mix(in srgb, var(--brand) 78%, #000) 0%, var(--brand) 58%, color-mix(in srgb, var(--brand) 72%, var(--brand-2)) 100%);
  --rail-active-fg: #ffffff;
  --rail-active-ring: rgba(255, 255, 255, .3);
  --rail-active-icon: #ffffff;
}
/* Paper — crisp white rail in either mode. */
html[data-rail="paper"] {
  --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #f6f7fd 100%);
  --rail-fg: #14172b;
  --rail-fg-dim: #4a5070;
  --rail-muted: #79809d;
  --rail-surface: #ffffff;
  --rail-surface-2: #e9ecf7;
  --rail-border: rgba(18, 22, 45, .1);
  --rail-hover: rgba(20, 23, 43, .05);
  --rail-active-bg: linear-gradient(90deg, color-mix(in srgb, var(--brand) 16%, transparent), color-mix(in srgb, var(--brand) 4%, transparent));
  --rail-active-fg: #14172b;
  --rail-active-ring: color-mix(in srgb, var(--brand) 32%, transparent);
  --rail-active-icon: var(--brand);
}
html[data-rail="paper"] .sidebar { box-shadow: var(--shadow-sm); }
html[data-rail="paper"] .brand-text small em { color: var(--brand); }
html[data-rail="ink"] .sidebar::before,
html[data-rail="brand"] .sidebar::before { opacity: 1; }
html[data-rail="paper"] .sidebar::before { opacity: .55; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-grad);
  background-attachment: fixed;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 650; letter-spacing: -.02em; margin: 0; }
p { margin: 0; }
::selection { background: color-mix(in srgb, var(--brand) 35%, transparent); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--rail-border);
  color: var(--rail-fg);
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}
.sidebar::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(320px 200px at 20% 0%, color-mix(in srgb, var(--brand) 18%, transparent), transparent 70%);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 6px 8px; position: relative; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff; box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--brand) 75%, transparent);
}
.brand-mark .ico { width: 21px; height: 21px; }
.brand-mark.admin { background: linear-gradient(140deg, #f59e0b, #ef4444); box-shadow: 0 8px 24px -8px rgba(239, 68, 68, .6); }
.brand-mark.brand-logo { padding: 0; overflow: hidden; background: transparent; box-shadow: none; }
.brand-mark.brand-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--display); font-size: 15px; letter-spacing: -.01em; }
.brand-text small { color: var(--rail-muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.brand-text small em { font-style: normal; color: var(--brand-2); font-weight: 700; }
.side-org {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  background: var(--rail-surface); border: 1px solid var(--rail-border); border-radius: 14px;
  position: relative;
}
.side-org strong { display: block; font-size: 12.5px; color: var(--rail-fg); }
.side-org small { color: var(--rail-muted); font-size: 11px; }
.org-avatar {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(140deg, color-mix(in srgb, var(--brand) 28%, transparent), color-mix(in srgb, var(--brand-2) 22%, transparent));
  color: var(--rail-fg); font-weight: 700; font-size: 12px; letter-spacing: .02em;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
}
.org-avatar.admin { color: #fbbf24; border-color: rgba(245, 158, 11, .35); background: rgba(245, 158, 11, .1); }
.org-avatar.admin .ico { width: 17px; height: 17px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; position: relative; flex: 1; }
/* While the page boots the link list stays hidden until its saved scroll
   position is applied, otherwise it flashes at the top first. */
html[data-nav-boot] .side-nav { visibility: hidden; }
.nav-group {
  font-size: 10px; text-transform: uppercase; letter-spacing: .13em; color: var(--rail-muted);
  padding: 15px 10px 5px; font-weight: 700; opacity: .85;
}
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 11px;
  color: var(--rail-fg-dim); font-size: 13px; font-weight: 500; transition: .18s ease; position: relative;
}
.nav-link .ico { width: 18px; height: 18px; opacity: .8; transition: .18s; }
.nav-link:hover { background: var(--rail-hover); color: var(--rail-fg); }
.nav-link:hover .ico { opacity: 1; }
.nav-link.active {
  background: var(--rail-active-bg);
  color: var(--rail-active-fg); font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--rail-active-ring), 0 10px 22px -14px rgba(0, 0, 0, .6);
}
.nav-link.active::before {
  content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 4px 4px 0;
  background: linear-gradient(var(--brand), var(--brand-2));
}
.nav-link.active .ico { opacity: 1; color: var(--rail-active-icon); }
.nav-link.locked { opacity: .55; }
.nav-lock { margin-left: auto; display: inline-flex; }
.nav-lock .ico { width: 13px; height: 13px; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 99px; display: grid; place-items: center; padding: 0 5px;
}
.side-foot { position: relative; }
.plan-meter {
  background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 16%, transparent), transparent 70%), var(--rail-surface);
  border: 1px solid var(--rail-border); border-radius: var(--radius); padding: 12px;
  color: var(--rail-fg);
}
.plan-meter-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; font-weight: 600; }
.meter { height: 5px; border-radius: 99px; background: var(--rail-surface-2); margin: 9px 0 10px; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.side-cta {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  padding: 8px; border-radius: 9px; font-size: 11.5px; font-weight: 600;
  background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--rail-fg);
  border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); transition: .18s;
}
.side-cta:hover { background: color-mix(in srgb, var(--brand) 30%, transparent); }
.side-note { color: var(--rail-muted); font-size: 11px; margin: 8px 0 10px; line-height: 1.45; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 18px 28px 14px;
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid transparent;
}
.topbar-title h1 { font-size: 21px; }
.topbar-title p { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.content { padding: 6px 28px 34px; width: 100%; max-width: 1560px; margin: 0 auto; }
.app-footer {
  margin-top: auto; padding: 16px 28px; display: flex; justify-content: space-between; gap: 12px;
  color: var(--muted); font-size: 11.5px; border-top: 1px solid var(--border);
}
.app-footer a { color: var(--brand-2); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.menu-btn { display: none; }
.mobile-scrim { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 11px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 12.5px;
  cursor: pointer; transition: .18s ease; white-space: nowrap; line-height: 1.2;
}
.btn:hover { transform: translateY(-1px); background: var(--surface-3); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn .ico { width: 16px; height: 16px; }
.btn-primary {
  background: linear-gradient(120deg, var(--brand), color-mix(in srgb, var(--brand) 55%, var(--brand-2)));
  border-color: transparent; color: #fff;
  box-shadow: 0 10px 26px -12px color-mix(in srgb, var(--brand) 80%, transparent);
}
.btn-primary:hover { background: linear-gradient(120deg, color-mix(in srgb, var(--brand) 90%, #fff), var(--brand-2)); }
.btn-accent { background: linear-gradient(120deg, var(--accent), var(--brand)); border-color: transparent; color: #fff; }
.btn-danger { background: color-mix(in srgb, var(--danger) 16%, transparent); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: #ff8080; }
html[data-mode="light"] .btn-danger { color: #b91c1c; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 11.5px; border-radius: 9px; }
.btn-xs { padding: 4px 8px; font-size: 11px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
  cursor: pointer; transition: .18s; position: relative;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.icon-btn .ico { width: 18px; height: 18px; }
.dot-badge {
  position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 99px; background: var(--danger); color: #fff; font-size: 9.5px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg);
}

/* ---------- Cards / layout ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(10px);
  overflow: hidden;
}
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 14.5px; }
.card-head p { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.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: 1.8fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 1.8fr; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.mt0 { margin-top: 0; } .mt1 { margin-top: 8px; } .mt2 { margin-top: 16px; } .mt3 { margin-top: 24px; }
.mb1 { margin-bottom: 8px; } .mb2 { margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.xs { font-size: 10.5px; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 700; }
.gradient-text {
  background: linear-gradient(100deg, var(--brand), var(--brand-2) 70%, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat {
  position: relative; padding: 16px 17px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  overflow: hidden; transition: .2s ease;
}
.stat:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 30%, var(--border)); }
.stat::after {
  content: ""; position: absolute; width: 130px; height: 130px; right: -40px; top: -55px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand) 20%, transparent), transparent 70%);
}
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-label { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.stat-ico {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand-2);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
}
.stat-ico .ico { width: 17px; height: 17px; }
.stat-ico.green { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.stat-ico.amber { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.stat-ico.red { background: color-mix(in srgb, var(--danger) 14%, transparent); color: #ff7a7a; border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.stat-ico.pink { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.stat-value { font-family: var(--display); font-size: 24px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.stat-sub { color: var(--muted); font-size: 11px; margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.trend { font-weight: 700; font-size: 11px; }
.trend.up { color: var(--ok); } .trend.down { color: #ff7a7a; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 99px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
  border: 1px solid transparent;
}
.badge-success { background: color-mix(in srgb, var(--ok) 14%, transparent); color: #4ade80; border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.badge-warning { background: color-mix(in srgb, var(--warn) 14%, transparent); color: #fbbf24; border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.badge-danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: #ff8080; border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.badge-info { background: color-mix(in srgb, var(--info) 14%, transparent); color: #67d8ff; border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.badge-muted { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
html[data-mode="light"] .badge-success { color: #15803d; }
html[data-mode="light"] .badge-warning { color: #a16207; }
html[data-mode="light"] .badge-danger { color: #b91c1c; }
html[data-mode="light"] .badge-info { color: #0369a1; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; padding: 10px 14px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { display: flex; gap: 4px; justify-content: flex-end; }
.table .doc-link { font-weight: 650; color: var(--text); }
.table .doc-link:hover { color: var(--brand-2); }
.table-compact td { padding: 8px 10px; }
.table select { min-width: 110px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 11.5px; font-weight: 600; color: var(--text-dim); }
.field .req { color: var(--brand-2); margin-left: 2px; }
.field .hint { color: var(--muted); font-size: 10.5px; }
.field-error { color: #ff8f8f; font-size: 10.5px; }
html[data-mode="light"] .field-error { color: #b91c1c; }
input[aria-invalid="true"] { border-color: color-mix(in srgb, var(--danger) 55%, transparent); }
input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
input[type="datetime-local"], input[type="time"], input[type="month"], input[type="week"],
input[type="search"], input[type="tel"], input[type="file"], input[type="url"], select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--field-bg); color: var(--text); outline: none; font-size: 12.5px;
  transition: border .16s, box-shadow .16s; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px;
}
input:focus, select:focus, textarea:focus {
  border-color: color-mix(in srgb, var(--brand) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent);
}
textarea { min-height: 76px; resize: vertical; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input[type="file"] { padding: 7px; font-size: 11.5px; }
/* Keep the native calendar/clock button usable on themed date fields. */
input[type="date"], input[type="datetime-local"], input[type="time"], input[type="month"], input[type="week"] { appearance: auto; }
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { opacity: .75; cursor: pointer; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); cursor: pointer; }
.check input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--brand); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }

/* Maintenance window: live countdown card in the platform console. */
.maintenance-hero { padding: 18px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2, rgba(127,127,127,.06)); }
.maintenance-clock { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; font-size: 34px; font-weight: 700; letter-spacing: 1px; line-height: 1.15; margin: 4px 0 2px; }
.maintenance-hero .meter { max-width: 420px; }
.form-error { color: #ff8f8f; font-size: 11.5px; }
.filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end;
  padding: 14px 18px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 35%, transparent);
}
.filters .field > label { font-size: 10.5px; }

/* ---------- Banners / flash ---------- */
.global-banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 15px; border-radius: 13px;
  margin-bottom: 14px; border: 1px solid var(--border); background: var(--surface);
  font-size: 12.5px;
}
.global-banner > .ico { width: 20px; height: 20px; flex: 0 0 auto; }
.global-banner > div { flex: 1; min-width: 0; }
.global-banner strong { display: block; font-size: 12.5px; }
.global-banner span { color: var(--muted); font-size: 11.5px; display: block; }
.global-banner.warning { background: color-mix(in srgb, var(--warn) 9%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.global-banner.warning > .ico { color: var(--warn); }
.global-banner.danger { background: color-mix(in srgb, var(--danger) 9%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.global-banner.danger > .ico { color: #ff7a7a; }
.global-banner.maintenance { background: color-mix(in srgb, var(--info) 9%, var(--surface)); border-color: color-mix(in srgb, var(--info) 28%, transparent); }
.global-banner.maintenance > .ico { color: var(--info); }
.flash {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--border); font-size: 12.5px;
  animation: slideDown .35s ease;
}
.flash .ico { width: 17px; height: 17px; flex: 0 0 auto; }
.flash span { flex: 1; }
.flash-close { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }
.flash-success { border-color: color-mix(in srgb, var(--ok) 30%, transparent); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }
.flash-success .ico { color: #4ade80; }
.flash-error { border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.flash-error .ico { color: #ff7a7a; }
.flash-warning { border-color: color-mix(in srgb, var(--warn) 30%, transparent); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); }
.flash-warning .ico { color: var(--warn); }
.flash-info .ico { color: var(--info); }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Dropdowns ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; z-index: 80;
  background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 8px; display: none;
  animation: pop .16s ease;
}
.dropdown.open .dropdown-menu { display: block; }
/* A card clips its children for rounded corners, which also cut off a dropdown
   menu hanging below the card, and its own stacking context sits below the next
   card. While a menu is open, let the card overflow and paint above its
   siblings so the menu is visible and clickable. */
.card:has(.dropdown.open) { overflow: visible; position: relative; z-index: 20; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.dropdown-menu a { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 9px; font-size: 12.5px; color: var(--text-dim); }
.dropdown-menu a:hover { background: var(--hover); color: var(--text); }
.dropdown-menu a .ico { width: 16px; height: 16px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 4px 9px 4px 4px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--border); cursor: pointer; color: var(--text);
}
.user-chip:hover { border-color: var(--border-strong); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: linear-gradient(140deg, var(--brand), var(--brand-2)); color: #fff; flex: 0 0 auto;
}
.avatar-lg { width: 40px; height: 40px; font-size: 13px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.user-meta strong { font-size: 11.5px; }
.user-meta small { color: var(--muted); font-size: 10px; }
.user-menu { min-width: 245px; }
.user-menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-menu-head strong { display: block; font-size: 12.5px; }
.user-menu-head small { color: var(--muted); font-size: 10.5px; }
.notif-menu { min-width: 330px; width: min(390px, 90vw); padding: 0; overflow: hidden; }
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 12.5px; }
.notif-list { max-height: min(65vh, 420px); overflow-y: auto; overscroll-behavior: contain; }
.notif-item { display: flex; flex-direction: column; gap: 7px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.notif-item:hover { background: var(--hover); }
.notif-item-link { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 !important; }
.notif-copy { display: block; min-width: 0; }
.notif-item strong { display: block; font-size: 11.5px; }
.notif-item small { color: var(--muted); font-size: 10.5px; }
.notif-read { align-self: flex-start; padding: 3px 7px; border: 1px solid var(--border); border-radius: 7px; background: transparent; color: var(--brand-2); font: inherit; font-size: 10px; cursor: pointer; }
.notif-read:hover { background: var(--hover); border-color: var(--border-strong); }
.notif-read:disabled { opacity: .55; cursor: wait; }
.notif-read-all { align-self: center; white-space: nowrap; }
.notif-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 auto; }
.notif-ico.danger { background: color-mix(in srgb, var(--danger) 13%, transparent); color: #ff8080; }
.notif-ico.warn { background: color-mix(in srgb, var(--warn) 13%, transparent); color: var(--warn); }
.empty-sm { padding: 22px; text-align: center; color: var(--muted); font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-sm .ico { width: 22px; height: 22px; color: var(--ok); }
.appearance-menu { min-width: 262px; padding: 12px; }
.appearance-label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; margin: 4px 0 8px; }
.swatches { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 12px; }
.swatch { display: flex; align-items: center; gap: 7px; background: none; border: 1px solid var(--border); border-radius: 9px; padding: 6px 8px; font-size: 11px; cursor: pointer; color: var(--text-dim); }
.swatch:hover { background: var(--hover); }
.swatch span { width: 14px; height: 14px; border-radius: 50%; display: block; }
.swatch-aurora span { background: linear-gradient(135deg, #7c5cff, #22d3ee); }
.swatch-ember span { background: linear-gradient(135deg, #ff6a3d, #ffc247); }
.swatch-forest span { background: linear-gradient(135deg, #12b981, #a3e635); }
.swatch-ocean span { background: linear-gradient(135deg, #3b82f6, #22d3ee); }
.swatch-orchid span { background: linear-gradient(135deg, #d946ef, #fb923c); }
.swatch-ink span { background: linear-gradient(135deg, #1e293b, #94a3b8); }
.swatch.active { border-color: color-mix(in srgb, var(--brand) 55%, transparent); background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--text); }
.swatch span { border: 1px solid rgba(255, 255, 255, .22); }
.rail-auto span { background: linear-gradient(135deg, #ffffff 0 48%, #10132a 48% 100%); }
.rail-ink span { background: linear-gradient(135deg, #2b3350, #0a0d18); }
.rail-brand span { background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.rail-paper span { background: #ffffff; border-color: rgba(18, 22, 45, .22); }
.rails { margin-bottom: 12px; }
.mode-row { display: flex; gap: 6px; }
.mode-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px; border-radius: 9px; border: 1px solid var(--border); background: none; cursor: pointer; font-size: 11px; color: var(--text-dim); }
.mode-btn.active { background: color-mix(in srgb, var(--brand) 14%, transparent); border-color: color-mix(in srgb, var(--brand) 40%, transparent); color: var(--text); }
.appearance-hint { color: var(--muted); font-size: 10px; margin: 0; line-height: 1.4; }
.mode-btn .ico { width: 14px; height: 14px; }

/* ---------- Send document ---------- */
.send-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 14px; width: fit-content; }
.send-tab { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 0; background: none; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.send-tab .ico { width: 14px; height: 14px; }
.send-tab.active { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm); }
.attach-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; border: 1px dashed color-mix(in srgb, var(--brand) 40%, transparent); background: color-mix(in srgb, var(--brand) 8%, transparent); font-size: 11.5px; color: var(--text-dim); }
.attach-chip .ico { width: 14px; height: 14px; color: var(--brand-2); }
.attach-chip strong { color: var(--text); font-weight: 600; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; margin-bottom: 18px; width: fit-content; max-width: 100%; }
.tab { padding: 8px 14px; border-radius: 9px; font-size: 12px; font-weight: 600; color: var(--muted); transition: .16s; }
.tab:hover { color: var(--text); background: var(--hover); }
.tab.active { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 25%, transparent); }

/* ---------- License pill, banner ---------- */
.license-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 99px;
  font-size: 11px; font-weight: 600; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-dim); white-space: nowrap;
}
.license-pill .ico { color: var(--brand-2); }
.license-pill.expiring { border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: #fbbf24; }
.license-pill.expiring .ico { color: var(--warn); }
.license-pill.expired { border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: #ff8f8f; }
.license-pill.expired .ico { color: var(--danger); }
.license-pill.active .ico { color: var(--ok); }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 6, 16, .65); backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center; padding: 5vh 18px 24px; z-index: 200; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 100%; max-width: 640px; background: var(--surface-solid); border: 1px solid var(--border-strong);
  border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .2s ease; overflow: hidden;
}
.modal.wide { max-width: 880px; }
.modal.narrow { max-width: 440px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15px; }
.modal-head p { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.modal-body { padding: 18px; max-height: 68vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 18px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 40%, transparent); }
.modal-close { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; }
.clear-data-section { padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.clear-data-section + .clear-data-section { margin-top: 14px; }
.clear-data-section-all { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: color-mix(in srgb, var(--danger) 5%, var(--surface-2)); }
.clear-data-section-head { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 12px; }
.clear-data-section-head h3 { font-size: 14px; }
.clear-data-section-head p { margin-top: 3px; color: var(--muted); font-size: 11.5px; }
.clear-data-step { flex: 0 0 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; background: color-mix(in srgb, var(--brand) 15%, transparent); color: var(--brand-2); font-size: 12px; font-weight: 700; }
.clear-data-section-all .clear-data-step { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* First sign-in appearance onboarding */
.appearance-choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 12px; }
.appearance-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); cursor: pointer; text-align: left; }
.appearance-choice:hover, .appearance-choice:focus-visible { border-color: var(--brand); }
.appearance-choice svg { width: 20px; height: 20px; color: var(--brand-2); }
.appearance-choice strong { font-size: 14px; }
.appearance-choice small { color: var(--muted); font-size: 11.5px; }
.appearance-hint { display: flex; gap: 7px; align-items: flex-start; margin-top: 4px; font-size: 11.5px; color: var(--muted); }
@media (max-width: 520px) { .appearance-choice-row { grid-template-columns: 1fr; } }
.confirm-icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: color-mix(in srgb, var(--danger) 14%, transparent); color: #ff8080; margin-bottom: 12px; }

/* ---------- Dashboard charts & misc ---------- */
.chart-card .card-body { padding-top: 8px; }
.chart { width: 100%; height: 220px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.chart-tip { font-size: 10px; fill: var(--muted); }
.chart-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.quick-action {
  display: flex; align-items: center; gap: 9px; padding: 11px; border-radius: 11px;
  border: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  font-size: 12px; font-weight: 600; transition: .16s;
}
.quick-action:hover { border-color: color-mix(in srgb, var(--brand) 35%, transparent); transform: translateY(-1px); background: color-mix(in srgb, var(--brand) 8%, var(--surface-2)); }
.quick-action .ico { width: 16px; height: 16px; color: var(--brand-2); }
.list-clean { list-style: none; margin: 0; padding: 0; }
.list-clean li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.list-clean li:last-child { border-bottom: 0; }
.list-clean .spacer { flex: 1; }
.avatar-sm { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); font-size: 10.5px; font-weight: 700; flex: 0 0 auto; }
.progress { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.progress.warn span { background: linear-gradient(90deg, var(--warn), #fb923c); }
.progress.danger span { background: linear-gradient(90deg, var(--danger), #f43f5e); }
.usage-row { display: flex; flex-direction: column; gap: 6px; padding: 9px 0; }
.usage-row .row { font-size: 11.5px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 46px 20px; color: var(--muted); gap: 4px; }
.empty-state .ico-xl { width: 40px; height: 40px; opacity: .35; margin-bottom: 8px; }
.empty-state h3 { font-size: 14px; color: var(--text); }
.empty-state p { font-size: 12px; max-width: 340px; }
.empty-state .btn { margin-top: 12px; }
.ico { width: 18px; height: 18px; flex: 0 0 auto; vertical-align: middle; }
.ico-xs { width: 13px; height: 13px; }
.ico-sm { width: 15px; height: 15px; }
.ico-xl { width: 40px; height: 40px; }
.avatar-preview { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; border: 1px solid var(--border); background: var(--surface-2); }
.thumb { width: 46px; height: 46px; border-radius: 9px; object-fit: cover; border: 1px solid var(--border); cursor: pointer; }
.pill-row { display: flex; flex-wrap: wrap; gap: 5px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 7px 12px; font-size: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
/* Two label/value pairs per row so wide detail cards fill the space. */
.kv-2 { grid-template-columns: 130px minmax(0, 1fr) 130px minmax(0, 1fr); column-gap: 24px; }
.kv-2 dd.span-wide { grid-column: 2 / -1; }
/* Long free text (notes) gets its own full-width row, label above the value,
   so the label can never drift into the right-hand value column. */
.kv-2 .kv-full { grid-column: 1 / -1; }
.kv-2 dd.kv-full { margin-top: -4px; }
@media (max-width: 740px) {
  .kv-2 { grid-template-columns: 130px minmax(0, 1fr); }
  .kv-2 dd.span-wide { grid-column: auto; }
}
.callout { display: flex; gap: 9px; padding: 11px 13px; border-radius: 11px; background: color-mix(in srgb, var(--info) 8%, transparent); border: 1px solid color-mix(in srgb, var(--info) 22%, transparent); font-size: 11.5px; color: var(--text-dim); }
.callout .ico { color: var(--info); }
.callout.warn { background: color-mix(in srgb, var(--warn) 8%, transparent); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.callout.warn .ico { color: var(--warn); }
.pagination { display: flex; gap: 4px; padding: 12px 16px; align-items: center; }
.page { min-width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 11.5px; color: var(--muted); border: 1px solid transparent; }
.page:hover { background: var(--hover); color: var(--text); }
.page.active { background: color-mix(in srgb, var(--brand) 15%, transparent); color: var(--text); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.page-dots { color: var(--muted); padding: 0 4px; }

/* ---------- Document builder ---------- */
.doc-lines { width: 100%; border-collapse: collapse; }
.doc-lines th { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.doc-lines td { padding: 5px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc-lines input, .doc-lines select { padding: 7px 8px; font-size: 12px; }
.doc-lines .line-amount { font-variant-numeric: tabular-nums; font-weight: 650; padding-top: 13px; text-align: right; }
.doc-lines .remove-line { color: var(--muted); background: none; border: 0; cursor: pointer; padding: 8px 4px; }
.doc-lines .remove-line:hover { color: #ff8080; }
/* Estimate quotations show the "to" price only in estimate mode. */
.doc-lines .col-price-max { display: none; }
body.doc-estimate .doc-lines .col-price-max { display: table-cell; }
.doc-totals { margin-left: auto; width: min(100%, 340px); display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.doc-totals .row { justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.doc-totals .row.grand { border-bottom: 0; border-top: 1px solid var(--border-strong); margin-top: 4px; padding-top: 10px; font-size: 15px; font-weight: 700; }
.doc-totals .row.grand b { font-family: var(--display); color: var(--brand-2); }
.doc-save-bar {
  position: sticky; bottom: 12px; z-index: 30; display: flex; align-items: center; gap: 14px;
  margin-top: 16px; padding: 12px 16px; border: 1px solid var(--border-strong); border-radius: 14px;
  background: color-mix(in srgb, var(--surface-solid) 94%, transparent);
  backdrop-filter: blur(10px); box-shadow: var(--shadow-lg);
}
/* One line only: wrapping pushed Total onto a second row and made the bar
   look oversized. Items shrink instead of wrapping. The totals start from the
   left and the save button stays on the right. */
.doc-save-totals { display: flex; align-items: center; gap: 26px; margin-left: 0; flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; justify-content: flex-start; }
.doc-save-totals > div { display: flex; flex-direction: column; gap: 2px; font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.doc-save-totals b { font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--text); font-variant-numeric: tabular-nums; }
.doc-save-totals .grand b { font-family: var(--display); font-size: 18px; color: var(--brand-2); }
.doc-save-totals .doc-save-input-group { min-width: 0; }
.doc-save-input-group label { font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.doc-save-input { width: 84px; min-height: 30px; padding: 5px 7px; font-size: 12px; }
.doc-save-input.doc-save-discount { width: 110px; }
.doc-save-bar .btn { flex: 0 0 auto; margin-left: auto; }
/* On a phone the save bar stays one compact line: the two amount inputs and
   the total, with the save button beside them. Subtotal and tax are already
   listed in the Document summary card above, so they are dropped here. */
@media (max-width: 740px) {
  .doc-save-bar { flex-wrap: nowrap; align-items: center; bottom: 6px; gap: 8px; padding: 8px 10px; border-radius: 12px; }
  .doc-save-totals {
    width: auto; flex: 1 1 auto; min-width: 0; margin-left: 0; gap: 8px;
    flex-wrap: nowrap; align-items: center;
  }
  .doc-save-totals > .doc-save-stat { display: none; }
  .doc-save-totals .doc-save-input-group { min-width: 0; flex: 1 1 0; }
  .doc-save-input-group label { font-size: 8.5px; letter-spacing: 0; }
  .doc-save-input, .doc-save-input.doc-save-discount { width: 100%; min-height: 28px; padding: 4px 6px; font-size: 12px; }
  .doc-save-totals .grand { flex: 0 0 auto; }
  .doc-save-totals .grand b { font-size: 16px; }
  .doc-save-bar .btn { width: auto; flex: 0 0 auto; min-height: 32px; padding: 6px 12px; font-size: 12px; white-space: nowrap; }
}
@media (max-width: 400px) {
  .doc-save-bar { flex-wrap: wrap; }
  .doc-save-totals { flex-basis: 100%; }
  .doc-save-bar .btn { width: 100%; }
}
.party-picker { position: relative; }
.item-picker { position: relative; }
.item-picker-input { padding-right: 26px !important; }
.item-picker-pop {
  position: fixed; z-index: 260; max-height: 280px; overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
.item-picker-pop[hidden] { display: none; }
.item-picker-list { display: flex; flex-direction: column; }
.item-picker-opt {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  padding: 8px 11px; background: none; border: 0; border-bottom: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 12px;
}
.item-picker-opt:last-child { border-bottom: 0; }
.item-picker-opt:hover, .item-picker-opt:focus-visible { background: var(--hover); }
.item-picker-opt small { color: var(--muted); font-size: 10px; }
.item-picker-opt.create-new { color: var(--brand-2); font-weight: 600; }
.item-picker-empty { padding: 9px 11px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); }
.party-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface-solid);
  border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); z-index: 20;
  max-height: 210px; overflow-y: auto; display: none;
}
.party-results.open { display: block; }
.party-results button { display: flex; width: 100%; text-align: left; padding: 8px 11px; background: none; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 12px; flex-direction: column; }
.party-results button:hover { background: var(--hover); }
.party-results small { color: var(--muted); font-size: 10px; }
.party-results .create-new { color: var(--brand-2); font-weight: 600; }

/* ---------- Print / document preview ---------- */
.doc-paper {
  position: relative;
  background: #ffffff; color: #111827; border-radius: 12px; padding: 9mm 9mm 17mm;
  max-width: 210mm; min-height: 295mm; margin: 0 auto; box-shadow: 0 20px 60px -30px rgba(0,0,0,.5);
  font-size: 12px;
}
.doc-paper h1, .doc-paper h2, .doc-paper h3 { color: #111827; }
.doc-paper .paper-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 2px solid #6d28d9; padding-bottom: 16px; margin-bottom: 18px; }
/* Logo and business name share the top line; address lines hang under the name. */
.doc-paper .paper-brand { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.doc-paper .paper-logo { width: 54px; height: 54px; object-fit: contain; border-radius: 10px; flex: 0 0 auto; }
.doc-paper .paper-brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.doc-paper .paper-brand-text h2 { margin: 0; line-height: 1.15; font-size: 19px; letter-spacing: -.02em; }
.doc-paper .paper-brand-line { font-size: 10.5px; line-height: 1.45; color: #4b5563; max-width: 340px; }
/* Right-hand block stays on the right, but its four lines share one left edge. */
.doc-paper .paper-head-right { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; flex: 0 0 auto; }
.doc-paper .paper-title { font-size: 22px; letter-spacing: .08em; text-transform: uppercase; color: #6d28d9; text-align: left; }
.doc-paper .paper-no { font-size: 12px; font-weight: 700; color: #111827; }
.doc-paper .paper-date { font-size: 11px; color: #4b5563; }
.doc-paper .paper-meta { font-size: 11px; color: #4b5563; }
.doc-paper .paper-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 18px; }
.doc-paper .paper-label { font-size: 9px; text-transform: uppercase; letter-spacing: .1em; color: #6b7280; font-weight: 700; margin-bottom: 3px; }
.doc-paper .paper-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 10px 0 16px; font-size: 11px; }
.doc-paper .paper-table th, .doc-paper .paper-table td { overflow-wrap: anywhere; word-break: break-word; }
.doc-paper .paper-table th { background: #f3e8ff; color: #4c1d95; text-align: left; padding: 7px 8px; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.doc-paper .paper-table td { padding: 7px 8px; border-bottom: 1px solid #e5e7eb; }
.doc-paper .paper-table .num { text-align: right; }
.doc-paper .paper-totals { width: 290px; margin-left: auto; font-size: 11.5px; }
.doc-paper .paper-totals .row { display: flex; justify-content: space-between; padding: 4px 0; }
.doc-paper .paper-totals .grand { border-top: 1.5px solid #6d28d9; margin-top: 4px; padding-top: 7px; font-size: 15px; font-weight: 700; color: #4c1d95; }
/* Details column keeps its right-hand position but every line starts on one left edge. */
.doc-paper .paper-details-wrap { text-align: right; }
.doc-paper .paper-details { display: inline-block; text-align: left; }
.doc-paper .paper-details .row { display: flex; align-items: baseline; gap: 6px; font-size: 10.5px; line-height: 1.55; color: #4b5563; }
.doc-paper .paper-details .row strong { color: #111827; font-weight: 600; }
.doc-paper .paper-close { display: block; }
.doc-paper .paper-foot { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; font-size: 10px; color: #4b5563; }
.doc-paper .foot-card { border: 1px solid #e5e7eb; border-radius: 6px; overflow: hidden; background: #fff; }
.doc-paper .foot-card-head { background: #f5f3ff; color: #4c1d95; font-size: 9.5px; font-weight: 700; letter-spacing: .03em; padding: 5px 10px; }
.doc-paper .foot-card-body { padding: 7px 10px; font-size: 9.5px; line-height: 1.5; }
.doc-paper .terms-accept { margin-top: 6px; color: #6b7280; }
.doc-paper .foot-row { display: flex; gap: 10px; align-items: stretch; }
.doc-paper .foot-bank { flex: 1 1 56%; }
.doc-paper .foot-qr { flex: 1 1 44%; }
.doc-paper .bank-rows { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; align-items: baseline; }
.doc-paper .bank-rows span { color: #6b7280; }
.doc-paper .bank-rows strong { color: #111827; font-weight: 600; }
.doc-paper .qr-inner { display: flex; gap: 12px; align-items: center; padding: 7px 10px; height: 100%; box-sizing: border-box; }
.doc-paper .foot-qr img { width: 70px; height: 70px; object-fit: contain; flex: 0 0 auto; }
.doc-paper .qr-title { color: #111827; font-weight: 700; font-size: 9.5px; }
.doc-paper .qr-sub { color: #6b7280; font-size: 9px; }
.doc-paper .foot-decl { border-left: 3px solid #6d28d9; }
.doc-paper .paper-signatures { display: flex; justify-content: space-between; align-items: flex-end; gap: 48px; margin-top: 30px; }
.doc-paper .paper-signatures .sig-col { flex: 1 1 0; max-width: 42%; }
.doc-paper .paper-signatures .sig-right { text-align: center; }
.doc-paper .paper-signatures .sig-for { font-size: 10px; font-weight: 700; color: #111827; margin-bottom: 6px; }
.doc-paper .paper-signatures img { max-height: 44px; display: block; margin: 0 auto 4px; }
.doc-paper .paper-signatures .sig-line { border-top: 1px solid #9ca3af; padding-top: 5px; font-size: 9.5px; color: #4b5563; text-align: center; }
/* Site URL sits in the page footer, pinned to the bottom of the sheet. */
.doc-paper .paper-url {
  position: absolute; left: 9mm; right: 9mm; bottom: 7mm;
  border-top: 1px solid #ede9fe; padding-top: 6px;
  text-align: center; font-size: 10px; letter-spacing: .02em; color: #8b879c;
}
.doc-paper .paper-url a { color: inherit; text-decoration: none; }
.doc-paper .print-tag { display: inline-block; background: #f3e8ff; color: #5b21b6; padding: 2px 7px; border-radius: 4px; font-size: 9px; font-weight: 700; letter-spacing: .06em; }
/* Half A4: the paper is exactly the top half of the sheet, with a centre cut line. */
.doc-paper.is-half { height: 148mm; min-height: 148mm; max-height: 148mm; overflow: hidden; }
.doc-paper.is-half::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; border-top: 1.4px dashed #98a2b3; }
/* Half sheet: tighter rhythm so the details block still fits above the cut. */
.doc-paper.is-half { padding: 6mm 6mm 9mm; }
.doc-paper.is-half .paper-url { left: 6mm; right: 6mm; bottom: 3.5mm; padding-top: 3px; font-size: 8.5px; }
.doc-paper.is-half .paper-head { padding-bottom: 10px; margin-bottom: 10px; }
.doc-paper.is-half .paper-logo { width: 42px; height: 42px; }
.doc-paper.is-half .paper-brand-text h2 { font-size: 16px; }
.doc-paper.is-half .paper-brand-line { font-size: 9.5px; line-height: 1.35; }
.doc-paper.is-half .paper-title { font-size: 18px; }
.doc-paper.is-half .paper-grid { margin-bottom: 8px; gap: 12px; }
.doc-paper.is-half .paper-details .row { font-size: 9.5px; line-height: 1.4; }
.doc-paper.is-half .paper-table { margin: 6px 0 8px; }
.doc-paper.is-half .paper-table th, .doc-paper.is-half .paper-table td { padding: 4px 6px; }
.doc-paper.is-half .paper-close { display: flex; gap: 14px; align-items: flex-start; }
.doc-paper.is-half .paper-foot { order: -1; flex: 1 1 auto; min-width: 0; margin-top: 0; gap: 5px; }
.doc-paper.is-half .paper-totals { flex: 0 0 200px; width: 200px; margin-left: 0; font-size: 10px; }
.doc-paper.is-half .paper-totals .row { padding: 2px 0; }
.doc-paper.is-half .paper-totals .grand { font-size: 13px; margin-top: 2px; padding-top: 5px; }
.doc-paper.is-half .foot-card-head { padding: 4px 8px; font-size: 8.5px; }
.doc-paper.is-half .foot-card-body { padding: 5px 8px; font-size: 8.5px; line-height: 1.4; }
.doc-paper.is-half .foot-qr img { width: 48px; height: 48px; }
.doc-paper.is-half .qr-inner { gap: 8px; padding: 5px 8px; }
.doc-paper.is-half .qr-title { font-size: 8.5px; }
.doc-paper.is-half .qr-sub { font-size: 8px; }
.doc-paper.is-half .paper-signatures { display: none; }
.print-only { display: none; }
@media print {
  body { background: #fff !important; color: #111; }
  .sidebar, .topbar, .app-footer, .global-banner, .page-actions, .no-print, .flash, .mobile-scrim { display: none !important; }
  .main { display: block; }
  .content { padding: 0; max-width: none; }
  .doc-paper { box-shadow: none; border-radius: 0; max-width: none; padding: 0 0 9mm; }
  .doc-paper .paper-url { left: 0; right: 0; bottom: 0; }
  .doc-paper.is-half { height: 148mm; max-height: 148mm; overflow: hidden; }
  .print-only { display: block; }
  a[href]::after { content: ""; }
  .card { border: 1px solid #ddd; box-shadow: none; }
}

/* ---------- Auth / login ---------- */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
  background: var(--bg-grad);
}
.auth-art {
  position: relative; overflow: hidden; padding: 52px; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(700px 500px at 15% 15%, color-mix(in srgb, var(--brand) 55%, transparent), transparent 65%),
    radial-gradient(600px 500px at 85% 80%, color-mix(in srgb, var(--brand-2) 40%, transparent), transparent 60%),
    linear-gradient(150deg, #0b0d20, #151033 55%, #071424);
  color: #fff;
}
.auth-art::after {
  content: ""; position: absolute; inset: 0; opacity: .25;
  background-image: linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse at 30% 30%, #000, transparent 75%);
}
.auth-brand { display: flex; align-items: center; gap: 11px; position: relative; z-index: 2; }
.auth-brand .brand-mark { width: 42px; height: 42px; }
.auth-hero { position: relative; z-index: 2; margin: 40px 0; }
.auth-hero h1 { font-size: clamp(32px, 4.4vw, 48px); line-height: 1.06; letter-spacing: -.035em; max-width: 520px; }
.auth-hero h1 em { font-style: normal; background: linear-gradient(100deg, #fff, var(--brand-2) 60%, #fff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-hero p { color: rgba(255,255,255,.68); max-width: 430px; margin-top: 16px; font-size: 13.5px; line-height: 1.65; }
.auth-features { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.auth-feature { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 99px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); font-size: 11px; }
.auth-feature .ico { width: 13px; height: 13px; color: var(--brand-2); }

/* Subscription plans + support number in the auth art panel */
.auth-plans {
  margin-top: 22px; padding: 13px 16px 14px; max-width: 340px;
  border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14);
}
.auth-plans-lead { margin: 0 0 8px; font-size: 11.5px; font-weight: 600; color: rgba(255,255,255,.9); }
.auth-plans-lead strong { color: #a5f3fc; font-weight: 800; }
.auth-plan-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.auth-plan-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 11.5px; color: rgba(255,255,255,.74); padding: 5px 0; border-bottom: 1px dashed rgba(255,255,255,.12); }
.auth-plan-list li:last-child { border-bottom: 0; }
.auth-plan-list strong { color: #fff; font-size: 12px; font-weight: 700; }
.auth-plan-list .auth-plan-amount { color: #a5f3fc; font-weight: 800; }
.auth-plan-list strong small { font-size: 9.5px; font-weight: 500; color: rgba(255,255,255,.55); margin-left: 1px; }
.auth-plans-support { margin: 9px 0 0; font-size: 11px; color: rgba(255,255,255,.74); display: flex; align-items: center; gap: 6px; }
.auth-plans-support a { color: #a5f3fc; font-weight: 700; text-decoration: none; }
.auth-plans-support .ico { width: 13px; height: 13px; color: #a5f3fc; }

/* Dashboard amount privacy ("View Amount") */
.amt-mask { display: none; }
.amounts-masked .amt-value { display: none; }
.amounts-masked .amt-mask { display: inline; user-select: none; }

/* Bulk selection on registers */
.bulk-form { display: none; }
.check-cell { width: 34px; }
.check-cell input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }
.auth-art-foot { position: relative; z-index: 2; display: flex; gap: 18px; font-size: 10.5px; color: rgba(255,255,255,.45); flex-wrap: wrap; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 36px 28px; }
.auth-card { width: 100%; max-width: 410px; }

/* The signup form is intentionally long. Keep its sales panel within the
   viewport while the form column remains the page's scrollable content. */
@media (min-width: 981px) {
  .auth.signup-layout { align-items: start; }
  .auth.signup-layout .auth-art {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    justify-content: flex-start;
  }
  .auth.signup-layout .auth-hero {
    margin: clamp(74px, 12vh, 148px) 0 0;
    max-width: 590px;
  }
  .auth.signup-layout .auth-art-foot { margin-top: auto; }
  .auth.signup-layout .auth-panel {
    align-items: flex-start;
    min-height: 100vh;
  }
}
.auth-card h2 { font-size: 24px; }
.auth-card > p { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); margin: 20px 0; }
.auth-tab { padding: 9px; border-radius: 9px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); border: 0; background: none; cursor: pointer; }
.auth-tab.active { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm); }
.auth-form { display: flex; flex-direction: column; gap: 13px; }
.auth-form .btn { padding: 11px; }
.auth-meta { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted); }
.auth-meta a { color: var(--brand-2); font-weight: 600; }
.auth-consent { display: flex; align-items: flex-start; gap: 8px; font-size: 11.5px; line-height: 1.5; color: var(--text-dim); cursor: pointer; }
.auth-consent input { width: 15px; height: 15px; margin-top: 1px; flex: 0 0 auto; accent-color: var(--brand); }
.auth-consent a { color: var(--brand-2); font-weight: 600; }
.auth-legal { width: 100%; max-width: 880px; }
.auth-legal .card { text-align: left; }
.legal-body { font-size: 13px; line-height: 1.8; color: var(--text-dim); }
.legal-body h3 { margin: 18px 0 6px; color: var(--text); font-size: 15px; }
.legal-body p { margin: 0 0 10px; }
.faq-item { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.faq-item:last-child { border-bottom: 0; }
.faq-item summary { cursor: pointer; font-weight: 600; font-size: 12.5px; list-style: none; display: flex; gap: 8px; align-items: center; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; margin-left: auto; color: var(--muted); font-weight: 400; }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { margin: 8px 0 0; font-size: 12px; color: var(--muted); line-height: 1.7; }


.auth-error { background: color-mix(in srgb, var(--danger) 10%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); color: #ff9f9f; border-radius: 10px; padding: 9px 11px; font-size: 11.5px; }
.auth-notice { background: color-mix(in srgb, var(--info) 10%, transparent); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); border-radius: 10px; padding: 10px 11px; font-size: 11.5px; color: var(--text-dim); word-break: break-all; }
html[data-mode="light"] .auth-error { color: #b91c1c; }

/* Private platform-console sign-in */
.admin-auth {
  min-height: 100vh; display: grid; place-items: center; padding: 28px 18px; position: relative; overflow: hidden;
  background:
    radial-gradient(700px 460px at 20% 10%, color-mix(in srgb, #ef4444 24%, transparent), transparent 62%),
    radial-gradient(620px 420px at 82% 84%, color-mix(in srgb, #f59e0b 18%, transparent), transparent 60%),
    linear-gradient(155deg, #0a0c18, #14101c 55%, #0a0c18);
}
.admin-auth-glow {
  position: absolute; inset: 0; pointer-events: none; opacity: .3;
  background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse at 45% 35%, #000, transparent 78%);
}
.admin-auth-card {
  position: relative; width: 100%; max-width: 388px; padding: 30px 28px 24px;
  border-radius: 20px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(18, 20, 34, .82); backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 40px 90px -40px rgba(0,0,0,.8); color: #eef0ff;
}
.admin-auth-card .field label { color: #c3c8e2; }
.admin-auth-card input {
  background: rgba(8, 10, 20, .6); border: 1px solid rgba(255,255,255,.14); color: #fff;
}
.admin-auth-card input:focus { border-color: rgba(239, 68, 68, .55); box-shadow: 0 0 0 3px rgba(239, 68, 68, .14); }
.admin-auth-card .auth-form { margin-top: 18px; }
.admin-auth-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.admin-auth-brand strong { display: block; font-family: var(--display); font-size: 16px; letter-spacing: -.01em; }
.admin-auth-brand small { color: #9aa1bf; font-size: 11px; }
.admin-auth-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 18px; font-size: 10.5px; color: #8b93b0; }
.admin-auth-foot a { color: #fbbf24; font-weight: 600; }
.admin-auth .flash { margin: 12px 0; }

/* Print size selector (Business Profile) */
.print-size { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 5px 0 7px; }
.print-size-opt {
  display: flex; align-items: center; gap: 9px; padding: 10px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; transition: .16s;
}
.print-size-opt:hover { border-color: var(--border-strong); }
.print-size-opt input { width: 15px; height: 15px; accent-color: var(--brand); flex: 0 0 auto; }
.print-size-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.print-size-body strong { font-size: 12px; }
.print-size-body .hint { margin: 0; font-size: 10px; }
.print-size-prev {
  width: 24px; height: 32px; border-radius: 4px; margin-left: auto; flex: 0 0 auto; position: relative;
  border: 1px solid var(--border-strong); background: var(--surface-solid);
}
.print-size-prev::after { content: ""; position: absolute; left: 4px; right: 4px; top: 30%; height: 2px; border-radius: 2px; background: var(--border-strong); box-shadow: 0 4px 0 var(--border-strong), 0 8px 0 var(--border-strong); }
.print-size-prev.half::after { top: 50%; height: 0; border-top: 1px dashed var(--muted); background: none; box-shadow: none; }
.print-size-opt:has(input:checked) { border-color: color-mix(in srgb, var(--brand) 55%, transparent); background: color-mix(in srgb, var(--brand) 10%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 25%, transparent); }
.print-size-opt:has(input:checked) .print-size-prev { border-color: color-mix(in srgb, var(--brand) 60%, transparent); }

/* ---------- QR & payment ---------- */
.qr-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px; border-radius: 16px; background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 12%, transparent), var(--surface-2)); border: 1px solid var(--border); }
.qr-card img, .qr-card canvas { width: 190px; height: 190px; background: #fff; border-radius: 12px; padding: 8px; }
.qr-fallback { width: 190px; height: 190px; display: grid; place-items: center; background: #fff; border-radius: 12px; color: #4c1d95; text-align: center; font-size: 10px; padding: 12px; }
.amount-display { font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -.03em; }
.amount-display small { font-size: 11px; color: var(--muted); font-weight: 500; display: block; letter-spacing: 0; }
.payment-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: center; }
.payment-row:last-child { border-bottom: 0; }
.payment-doc { width: 44px; height: 44px; border-radius: 9px; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1, .g-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .mobile-scrim { display: block; position: fixed; inset: 0; background: rgba(3,5,14,.55); z-index: 35; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 14px 18px 10px; }
  .content { padding: 4px 18px 28px; }
  .user-meta { display: none; }
  .license-pill span { display: none; }
  .license-pill { padding: 7px; }
  .app-footer { padding: 14px 18px; flex-direction: column; gap: 4px; }
}
@media (max-width: 740px) {
  .stats, .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-grid, .form-grid.three, .form-grid.four { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
  .doc-paper { padding: 20px 16px; }
  .doc-paper .paper-head, .doc-paper .paper-grid, .doc-paper .paper-foot { flex-direction: column; display: block; }
  .doc-paper .paper-title, .doc-paper .paper-meta { text-align: left; }
  .doc-paper .paper-totals { width: 100%; }
  .doc-paper .terms { max-width: 100%; }
  .topbar-title h1 { font-size: 17px; }
  .top-actions { gap: 5px; }
  .icon-btn { width: 34px; height: 34px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .notif-menu { min-width: min(330px, 92vw); }
}
@media (max-width: 480px) {
  .filters { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
  .content { padding: 4px 13px 24px; }
  .topbar { padding: 12px 13px 8px; }
  .stat-value { font-size: 21px; }
}

/* ------------------------------------------------------- mobile form pass */
/* Keep app forms in two readable columns on a phone instead of stretching one
   field across the whole screen. Auth forms stay single-column. */
@media (max-width: 740px) {
  body.app .form-grid,
  body.admin .form-grid,
  body.app .form-grid.three,
  body.admin .form-grid.three,
  body.app .form-grid.four,
  body.admin .form-grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
  }
  body.app .span-2,
  body.admin .span-2,
  body.app .span-3,
  body.admin .span-3,
  body.app .span-full,
  body.admin .span-full { grid-column: 1 / -1; }

  body.app .field > label,
  body.admin .field > label { font-size: 12px; }

  /* 16px avoids the automatic zoom iOS applies to smaller form controls. */
  body.app input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  body.app select,
  body.app textarea,
  body.admin input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  body.admin select,
  body.admin textarea {
    font-size: 16px;
    min-height: 44px;
    padding: 10px 11px;
  }
  body.app select,
  body.admin select { padding-right: 30px; }
  body.app textarea,
  body.admin textarea { min-height: 92px; }
  body.app input[type="file"],
  body.admin input[type="file"] { font-size: 12px; min-height: 44px; padding: 8px; }

  body.app .btn,
  body.admin .btn { min-height: 42px; padding-left: 14px; padding-right: 14px; }
  body.app .btn-sm,
  body.admin .btn-sm { min-height: 36px; }
  body.app .btn-xs,
  body.admin .btn-xs { min-height: 30px; }
  body.app .check,
  body.admin .check { min-height: 30px; font-size: 12.5px; }
  body.app .check input[type="checkbox"],
  body.app .check input[type="radio"],
  body.admin .check input[type="checkbox"],
  body.admin .check input[type="radio"] { width: 18px; height: 18px; }

  body.app .page-actions .btn,
  body.admin .page-actions .btn { flex: 1 1 auto; }

  body.app .modal-backdrop,
  body.admin .modal-backdrop { padding: 10px 10px 20px; }
  body.app .modal,
  body.admin .modal { max-width: 100%; border-radius: 15px; }
  body.app .modal-head,
  body.admin .modal-head { padding: 13px 14px; align-items: flex-start; }
  body.app .modal-close,
  body.admin .modal-close { padding: 2px 6px; font-size: 24px; }
  body.app .modal-body,
  body.admin .modal-body { padding: 14px; max-height: 72vh; }
  body.app .modal-foot,
  body.admin .modal-foot { padding: 11px 14px; flex-wrap: wrap; }
  body.app .modal-foot .btn,
  body.admin .modal-foot .btn { flex: 1 1 auto; }

  body.app .card-head,
  body.admin .card-head { flex-wrap: wrap; padding: 14px; }
  body.app .card-body,
  body.admin .card-body { padding: 14px; }
  body.app .card-foot,
  body.admin .card-foot { flex-wrap: wrap; padding: 11px 14px; }

  body.app .doc-lines { min-width: 720px; }
  body.app .doc-lines input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  body.app .doc-lines select { font-size: 14px; min-height: 38px; padding: 7px 8px; }
  /* Rate needs room for five digits plus decimals, otherwise it clips mid-number. */
  body.app .doc-lines .line-price,
  body.app .doc-lines .line-price-max { min-width: 96px; }
  body.app .doc-lines .line-qty { min-width: 58px; }
  body.app .doc-lines .line-tax,
  body.app .doc-lines .line-discount-pct { min-width: 72px; }
  /* The spinner arrows eat a third of a narrow mobile box; drop them there and
     keep the full width for the digits. */
  body.app .doc-lines input[type="number"]::-webkit-outer-spin-button,
  body.app .doc-lines input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
  body.app .doc-lines input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
  body.app .table-wrap { -webkit-overflow-scrolling: touch; }
  body.app .table th { padding: 8px 10px; }
  body.app .table td { padding: 10px; }
}

@media (max-width: 320px) {
  body.app .form-grid,
  body.admin .form-grid,
  body.app .form-grid.three,
  body.admin .form-grid.three,
  body.app .form-grid.four,
  body.admin .form-grid.four { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- trials */
.global-banner.info {
  background: color-mix(in srgb, var(--info) 9%, var(--surface));
  border-color: color-mix(in srgb, var(--info) 30%, transparent);
}
.global-banner.info > .ico { color: var(--info); }
.license-pill.trial { border-color: color-mix(in srgb, var(--info) 40%, transparent); color: #67e8f9; }
.license-pill.trial .ico { color: var(--info); }
.license-pill.locked { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: #ff8f8f; }
.license-pill.locked .ico { color: var(--danger); }
/* Light surfaces need dark ink for status pills — pale cyan/amber vanish on white. */
html[data-mode="light"] .license-pill { color: var(--text-dim); }
html[data-mode="light"] .license-pill.trial { color: #0369a1; background: #e0f2fe; border-color: #7dd3fc; }
html[data-mode="light"] .license-pill.expiring { color: #a16207; background: #fef9c3; border-color: #fde68a; }
html[data-mode="light"] .license-pill.expired,
html[data-mode="light"] .license-pill.locked { color: #b91c1c; background: #fee2e2; border-color: #fca5a5; }
html[data-mode="light"] .license-pill.active { color: #15803d; background: #dcfce7; border-color: #86efac; }

.auth-signup {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-top: 18px; padding: 12px 13px; border-radius: 12px;
  border: 1px dashed var(--border-strong); background: var(--surface-2);
}
.auth-signup strong { display: block; font-size: 12.5px; }
.auth-signup span { display: block; font-size: 11px; color: var(--muted); }
.auth-signup .btn { flex: 0 0 auto; }

.signup-location-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }

@media (max-width: 740px) {
  .signup-location-row { grid-template-columns: 1fr; }
}

.signup-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.signup-plan {
  display: flex; gap: 9px; align-items: flex-start; cursor: pointer;
  padding: 10px 11px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface-2); transition: border-color .15s, background .15s;
}
.signup-plan:hover { border-color: var(--border-strong); }
.signup-plan.selected { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }
.signup-plan input { margin-top: 3px; accent-color: var(--brand); }
.signup-plan-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.signup-plan-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.signup-plan-price { width: fit-content; padding: 3px 6px; border-radius: 6px; background: color-mix(in srgb, var(--brand-2) 12%, var(--surface-2)); font-size: 11.5px; font-weight: 800; color: var(--brand-2); }
.signup-plan.selected .signup-plan-price { background: color-mix(in srgb, var(--brand-2) 18%, var(--surface)); }
.signup-plan small { font-size: 10.5px; color: var(--muted); line-height: 1.35; }
@media (max-width: 560px) {
  .signup-plans { grid-template-columns: 1fr; }
  .auth-signup { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   Light-mode clarity — visible borders, separators and section
   backgrounds. Bordered is the default; Accent Style is opt-in
   from Settings → Appearance.
   ============================================================ */
html[data-mode="light"] {
  --border: rgba(18, 22, 45, .14);
  --border-strong: rgba(18, 22, 45, .26);
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef0f7;
  --field-bg: #ffffff;
  --hover: rgba(20, 23, 43, .05);
  --active: rgba(20, 23, 43, .08);
}
html[data-mode="light"] .card,
html[data-mode="light"] .stat {
  box-shadow: 0 1px 2px rgba(16, 20, 40, .05), 0 16px 34px -30px rgba(16, 20, 40, .55);
}
html[data-mode="light"] .card-head { background: #fbfbfe; border-bottom-color: var(--border); }
html[data-mode="light"] .card-foot { background: #fbfbfe; border-top-color: var(--border); }
html[data-mode="light"] .table th { background: #f4f5fa; border-bottom: 1px solid var(--border-strong); }
html[data-mode="light"] .table td { border-bottom-color: #e9ebf3; }
html[data-mode="light"] .table tbody tr:nth-child(even) { background: #fcfcfe; }
html[data-mode="light"] .table tbody tr:hover { background: var(--hover); }
html[data-mode="light"] .filters { background: #fafbfe; border-bottom-color: var(--border-strong); }
html[data-mode="light"] .topbar { background: rgba(255, 255, 255, .92); border-bottom: 1px solid var(--border); }
html[data-mode="light"] .app-footer { border-top-color: var(--border-strong); }
html[data-mode="light"] .sidebar { border-right-color: var(--border-strong); }
html[data-mode="light"] .tabs { background: #fff; border-color: var(--border-strong); }
html[data-mode="light"] .doc-save-bar { background: rgba(255, 255, 255, .97); }
html[data-mode="light"] .modal-foot { background: #fafbfe; border-top-color: var(--border); }
html[data-mode="light"] .empty-state { background: #fafbfe; border: 1px dashed var(--border-strong); border-radius: var(--radius); }
html[data-mode="light"] .divider { background: var(--border-strong); opacity: .55; }
html[data-mode="light"] .list-clean li { border-bottom-color: #eceef5; }
html[data-mode="light"] .doc-totals .row { border-bottom-color: var(--border); }
html[data-mode="light"] .kv { border-radius: 10px; }
html[data-mode="light"] .field > label { color: #2b3050; }
html[data-mode="light"] .hint { color: #6d7390; }

/* Native date/time controls (placeholder, calendar icon) follow the theme. */
html[data-mode="dark"] { color-scheme: dark; }
html[data-mode="light"] { color-scheme: light; }

/* Accent Style — softer borders with the accent washed into cards. */
html[data-style="accent"] .card,
html[data-style="accent"] .stat {
  border-color: color-mix(in srgb, var(--brand) 22%, var(--border));
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 7%, var(--surface-solid)), var(--surface-solid) 58%);
  box-shadow: 0 18px 42px -32px color-mix(in srgb, var(--brand) 55%, transparent);
}
html[data-style="accent"] .card-head {
  background: color-mix(in srgb, var(--brand) 9%, transparent);
  border-bottom-color: color-mix(in srgb, var(--brand) 18%, var(--border));
}
html[data-style="accent"] .card-foot {
  background: color-mix(in srgb, var(--brand) 5%, transparent);
  border-top-color: color-mix(in srgb, var(--brand) 14%, var(--border));
}
html[data-style="accent"] .table th { background: color-mix(in srgb, var(--brand) 8%, transparent); }
html[data-style="accent"] .filters { background: color-mix(in srgb, var(--brand) 4%, var(--surface-2)); }
html[data-style="accent"] .tabs { border-color: color-mix(in srgb, var(--brand) 20%, var(--border)); }
html[data-mode="light"][data-style="accent"] {
  --border: color-mix(in srgb, var(--brand) 18%, rgba(18, 22, 45, .1));
  --border-strong: color-mix(in srgb, var(--brand) 32%, rgba(18, 22, 45, .12));
  --surface-2: color-mix(in srgb, var(--brand) 4%, #f7f8fc);
  --surface-3: color-mix(in srgb, var(--brand) 8%, #eef0f7);
}
html[data-mode="light"][data-style="accent"] .card-head { background: color-mix(in srgb, var(--brand) 7%, #fff); }
html[data-mode="light"][data-style="accent"] .card-foot { background: color-mix(in srgb, var(--brand) 4%, #fbfbfe); }

/* ---------- Document activity history ---------- */
.history-list { display: flex; flex-direction: column; }
.history-item { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.history-item:last-child { border-bottom: 0; }
.history-head { display: flex; align-items: center; gap: 7px; font-size: 11.5px; flex-wrap: wrap; }
.history-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--info); flex: 0 0 auto; }
.history-dot.created { background: var(--ok); }
.history-dot.updated { background: var(--info); }
.history-dot.cancelled { background: var(--danger); }
.history-dot.restored,
.history-dot.payment { background: var(--warn); }
.history-dot.converted { background: var(--brand); }
.history-actor { color: var(--muted); font-size: 10.5px; }
.history-when { margin-left: auto; color: var(--muted); font-size: 10.5px; white-space: nowrap; }
.history-summary { font-size: 11.5px; color: var(--text-dim); margin: 0; }
.history-changes { list-style: none; margin: 2px 0 0; padding: 0; display: grid; gap: 4px; }
.history-changes li {
  display: grid; grid-template-columns: minmax(96px, 132px) 1fr; gap: 8px;
  padding: 6px 9px; border-radius: 8px; background: var(--surface-2);
  border: 1px solid var(--border); font-size: 11px;
}
.history-changes .hlabel { color: var(--muted); font-weight: 600; }
.history-values { display: flex; flex-wrap: wrap; gap: 5px; align-items: baseline; white-space: pre-line; }
.history-old { color: #b91c1c; text-decoration: line-through; opacity: .85; }
.history-new { color: #15803d; font-weight: 650; }
html[data-mode="dark"] .history-old { color: #ff9a9a; }
html[data-mode="dark"] .history-new { color: #6ee7a8; }
.history-arrow { color: var(--muted); }
@media (max-width: 640px) {
  .history-changes li { grid-template-columns: 1fr; gap: 2px; }
}

/* Licence-locked features: visible, greyed out and clickable to the upgrade page. */
.tab.locked, .quick-action.locked, .btn.locked { opacity: .5; filter: grayscale(1); cursor: not-allowed; }
.tab.locked:hover, .quick-action.locked:hover, .btn.locked:hover { opacity: .6; }
.tab.locked svg, .quick-action.locked svg, .btn.locked svg { opacity: .9; }

/* ------------------------------------------- mobile document view pass */
/* On a phone the sticky header and the action buttons used to eat most of the
   screen before the invoice/quotation/purchase content started. Keep the bar
   one line tall, let the buttons scroll sideways and tighten the totals. */
@media (max-width: 740px) {
  body.app .topbar { gap: 8px; padding: 7px 12px 6px; }
  body.app .topbar-title { min-width: 0; flex: 1; }
  body.app .topbar-title h1 {
    font-size: 15px; line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  body.app .topbar-title p { display: none; }
  body.app .topbar .license-pill { display: none; }
  body.app .topbar .icon-btn { width: 30px; height: 30px; border-radius: 9px; }
  body.app .topbar .icon-btn .ico { width: 16px; height: 16px; }

  body.app .page-actions {
    flex-wrap: nowrap; overflow-x: auto; gap: 6px; margin: 2px 0 12px;
    padding-bottom: 2px; scrollbar-width: none;
  }
  body.app .page-actions::-webkit-scrollbar { display: none; }
  body.app .page-actions .btn {
    flex: 0 0 auto; min-height: 32px; padding: 5px 10px; font-size: 11.5px;
  }

  body.app .doc-totals { width: 100%; gap: 0; font-size: 11.5px; }
  body.app .doc-totals .row { padding: 3px 0; }
  body.app .doc-totals .row.grand { font-size: 13.5px; padding-top: 7px; margin-top: 2px; }

  body.app .global-banner { flex-wrap: wrap; gap: 8px; padding: 10px 12px; margin-bottom: 10px; }
  body.app .global-banner strong { font-size: 12px; }
  body.app .global-banner span { font-size: 11px; }
  body.app .global-banner > .btn { flex: 1 1 100%; min-height: 32px; }
}
