/* MYBD India — Billing Portal UI (Phase 1: HTML/CSS)
   Service lines are colour-coded after process inks:
   Printing = Cyan, Design = Magenta, Corporate Gifts = Yellow, Technology = Key */

@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700;800&display=swap');

:root {
  --paper: #F4F5F7;
  --surface: #FFFFFF;
  --ink: #161A22;
  --ink-2: #454B59;
  --muted: #6B7182;
  --line: #E2E5EB;
  --line-2: #EEF0F4;
  --brand: #2447D6;
  --brand-dark: #1A36A8;
  --brand-tint: #EBEFFD;

  --cyan: #0A86AD;   --cyan-tint: #E3F4FA;
  --magenta: #BE1E73; --magenta-tint: #FBE7F1;
  --yellow: #9A7300; --yellow-tint: #FFF5D1; --yellow-ink: #F2C200;
  --key: #2B303B;    --key-tint: #E9EAEE;

  --ok: #177A45;   --ok-tint: #E4F5EA;
  --warn: #A5530B; --warn-tint: #FDF0E1;
  --bad: #B42318;  --bad-tint: #FDECEA;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --sidebar: 256px;
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 22px 22px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: #fff; border: 1px solid var(--line); position: relative; overflow: hidden; flex: none; }
.brand-mark span { position: absolute; width: 14px; height: 14px; border-radius: 50%; mix-blend-mode: multiply; }
.brand-mark span:nth-child(1) { background: #3FC1E8; top: 7px; left: 6px; }
.brand-mark span:nth-child(2) { background: #F062A8; top: 7px; left: 15px; }
.brand-mark span:nth-child(3) { background: #FFD83D; top: 15px; left: 10.5px; }
.brand b { display: block; font-size: 17px; color: var(--brand); letter-spacing: -0.01em; }
.brand small { color: var(--muted); font-size: 12.5px; }

.nav { padding: 14px 12px; flex: 1; }
.nav-group { margin-bottom: 16px; }
.nav-group p { font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 12px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--line-2); color: var(--ink); }
.nav a.active { background: var(--brand-tint); color: var(--brand); font-weight: 600; }
.nav a .count { margin-left: auto; font-size: 12px; background: var(--line-2); color: var(--muted); padding: 1px 8px; border-radius: 99px; }
.nav a.active .count { background: #fff; color: var(--brand); }

.sidebar-foot { border-top: 1px solid var(--line); padding: 16px 18px; display: flex; align-items: center; gap: 12px; }
.avatar { width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.avatar.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; }
.avatar.c { background: var(--cyan); } .avatar.m { background: var(--magenta); } .avatar.y { background: var(--yellow); } .avatar.k { background: var(--key); }
.sidebar-foot b { display: block; font-size: 14px; }
.sidebar-foot small { color: var(--muted); font-size: 12.5px; }
.sidebar-foot .logout { margin-left: auto; color: var(--muted); padding: 6px; border-radius: 6px; }
.sidebar-foot .logout:hover { background: var(--line-2); color: var(--ink); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 32px; position: sticky; top: 0; z-index: 5;
}
.search { flex: 1; max-width: 420px; display: flex; align-items: center; gap: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 12px; height: 38px; color: var(--muted); }
.search input { border: 0; background: transparent; font: inherit; color: var(--ink); width: 100%; outline: none; }
.topbar .spacer { flex: 1; }
.org-switch { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 10px; font-size: 14px; font-weight: 500; }
.role-pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--brand-tint); color: var(--brand); }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--r-sm); color: var(--ink-2); border: 1px solid transparent; position: relative; }
.icon-btn:hover { background: var(--line-2); }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--magenta); border: 2px solid #fff; }

.content { padding: 28px 32px 48px; max-width: 1400px; width: 100%; }

/* Mobile nav (CSS-only toggle) */
#nav-toggle { display: none; }
.scrim { display: none; }
.menu-btn { display: none; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.page-head p { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a:hover { color: var(--brand); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  height: 40px; padding: 0 16px; border-radius: var(--r-sm);
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  white-space: nowrap;
}
.btn:hover { border-color: #C9CDD6; background: #FAFBFC; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn.block { width: 100%; }

/* ---------- Cards & panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line-2); }
.panel-head h2 { font-size: 16px; font-weight: 700; }
.panel-head p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.panel-body { padding: 22px; }
.link { color: var(--brand); font-weight: 600; font-size: 14px; }
.link:hover { text-decoration: underline; }

.grid { display: grid; gap: 20px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.stack > * + * { margin-top: 20px; }

/* ---------- Dashboard: money strip ---------- */
.money-strip { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 20px; }
.money-strip > div { padding: 22px 24px; border-left: 1px solid var(--line-2); }
.money-strip > div:first-child { border-left: 0; }
.money-strip label { font-size: 13px; color: var(--muted); font-weight: 500; }
.money-strip .big { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; margin: 6px 0 4px; }
.money-strip .lead .big { font-size: 38px; }
.money-strip small { font-size: 13px; color: var(--muted); }
.up { color: var(--ok); font-weight: 600; }
.down { color: var(--bad); font-weight: 600; }

/* Service mix bar — the signature element */
.mix { display: flex; height: 12px; border-radius: 99px; overflow: hidden; gap: 3px; margin: 18px 0 16px; }
.mix span { display: block; }
.mix .c { background: var(--cyan); } .mix .m { background: var(--magenta); } .mix .y { background: var(--yellow-ink); } .mix .k { background: var(--key); }
.mix-legend { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 20px; }
.mix-legend > div { display: flex; gap: 10px; align-items: flex-start; }
.mix-legend b { display: block; font-size: 14px; }
.mix-legend small { color: var(--muted); font-size: 13px; }

.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; margin-top: 5px; }
.swatch.c { background: var(--cyan); } .swatch.m { background: var(--magenta); } .swatch.y { background: var(--yellow-ink); } .swatch.k { background: var(--key); }

/* ---------- Service tags ---------- */
.svc { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 3px 9px 3px 7px; border-radius: 99px; white-space: nowrap; }
.svc::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.svc.c { color: var(--cyan); background: var(--cyan-tint); }
.svc.m { color: var(--magenta); background: var(--magenta-tint); }
.svc.y { color: var(--yellow); background: var(--yellow-tint); }
.svc.y::before { background: var(--yellow-ink); box-shadow: 0 0 0 1px var(--yellow); }
.svc.k { color: var(--key); background: var(--key-tint); }

/* ---------- Status badges ---------- */
.badge { display: inline-flex; align-items: center; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge.paid, .badge.accepted, .badge.active { background: var(--ok-tint); color: var(--ok); }
.badge.sent, .badge.partial { background: var(--brand-tint); color: var(--brand); }
.badge.overdue, .badge.declined { background: var(--bad-tint); color: var(--bad); }
.badge.due, .badge.pending, .badge.expiring { background: var(--warn-tint); color: var(--warn); }
.badge.draft, .badge.cancelled, .badge.inactive { background: var(--line-2); color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 13px; color: var(--muted); padding: 11px 16px; background: #F9FAFB; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 14px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tbody tr:hover td { background: #FAFBFD; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.doc-no { font-weight: 600; color: var(--ink); white-space: nowrap; }
td.muted { white-space: nowrap; }
.doc-no:hover { color: var(--brand); }
.cell-client b { display: block; font-weight: 600; }
.cell-client small { color: var(--muted); font-size: 12.5px; }
.muted { color: var(--muted); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions a { padding: 6px; border-radius: 6px; color: var(--muted); }
.row-actions a:hover { background: var(--line-2); color: var(--ink); }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px; }
.tabs a { padding: 6px 12px; border-radius: 5px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.tabs a.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(22,26,34,.08); }
.tabs a span { color: var(--muted); font-weight: 500; margin-left: 4px; }
.toolbar .search { height: 36px; max-width: 280px; }
.toolbar .spacer { flex: 1; }
.select { height: 36px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 32px 0 12px; font: inherit; font-size: 14px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236B7182' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center; appearance: none; color: var(--ink); }

.page-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.page-tabs a { padding: 10px 0 12px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.page-tabs a.on { color: var(--ink); border-color: var(--brand); font-weight: 600; }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }
.field label .opt { font-weight: 400; color: var(--muted); }
.input, .field select, .field textarea {
  width: 100%; height: 40px; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 0 12px; font: inherit; font-size: 14px; background: var(--surface); color: var(--ink);
}
.field select { appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236B7182' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; padding-right: 32px; }
.field textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; }
.input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.input-group { display: flex; }
.input-group .addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line); border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); background: var(--paper); color: var(--muted); font-size: 14px; }
.input-group .input { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

.section-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.section-sub { font-size: 13.5px; color: var(--muted); margin-bottom: 18px; }
hr.sep { border: 0; border-top: 1px solid var(--line-2); margin: 24px 0; }

/* Toggle switch (CSS-only) */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.switch:last-child { border-bottom: 0; }
.switch b { display: block; font-size: 14px; font-weight: 600; }
.switch small { color: var(--muted); font-size: 13px; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: #D5D9E0; position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(16px); }

/* ---------- Document builder (quote / invoice) ---------- */
.builder-head { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 18px; }
.line-items th, .line-items td { padding: 10px 10px; }
.line-items td { vertical-align: top; }
.line-items .input { height: 36px; }
.line-items .desc small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.rail-c { box-shadow: inset 4px 0 var(--cyan); } .rail-m { box-shadow: inset 4px 0 var(--magenta); } .rail-y { box-shadow: inset 4px 0 var(--yellow-ink); } .rail-k { box-shadow: inset 4px 0 var(--key); }
.line-items td.desc, .line-items th:first-child { padding-left: 18px; }
.add-line { display: flex; gap: 8px; padding: 14px 16px; border-top: 1px dashed var(--line); flex-wrap: wrap; align-items: center; }
.add-line span { font-size: 13.5px; color: var(--muted); margin-right: 4px; }
.add-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px dashed; border-radius: 99px; font-size: 13px; font-weight: 600; background: #fff; cursor: pointer; font-family: inherit; }
.add-chip.c { color: var(--cyan); } .add-chip.m { color: var(--magenta); } .add-chip.y { color: var(--yellow); } .add-chip.k { color: var(--key); }
.add-chip:hover { border-style: solid; }

.totals { font-size: 14px; }
.totals .row { display: flex; justify-content: space-between; padding: 7px 0; }
.totals .row span:first-child { color: var(--ink-2); }
.totals .grand { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; font-size: 18px; font-weight: 800; }
.totals .grand span:first-child { color: var(--ink); }
.words { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.sticky-side { position: sticky; top: 88px; }

/* ---------- Printed document (invoice sheet) ---------- */
.sheet {
  background: #fff; border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 1px 0 var(--line), 0 12px 32px -18px rgba(22,26,34,.25);
  padding: 44px 48px; max-width: 880px; margin: 0 auto; position: relative;
}
.sheet .reg { position: absolute; width: 18px; height: 18px; }
.sheet .reg::before, .sheet .reg::after { content: ""; position: absolute; background: #C9CDD6; }
.sheet .reg::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.sheet .reg::after { top: 50%; left: 0; right: 0; height: 1px; }
.sheet .reg.tl { top: 12px; left: 12px; } .sheet .reg.tr { top: 12px; right: 12px; }
.sheet .reg.bl { bottom: 12px; left: 12px; } .sheet .reg.br { bottom: 12px; right: 12px; }
.cmyk-bar { display: flex; gap: 0; height: 6px; margin: -44px -48px 36px; border-radius: 4px 4px 0 0; overflow: hidden; }
.cmyk-bar span { flex: 1; }
.cmyk-bar span:nth-child(1) { background: #3FC1E8; } .cmyk-bar span:nth-child(2) { background: #F062A8; }
.cmyk-bar span:nth-child(3) { background: #FFD83D; } .cmyk-bar span:nth-child(4) { background: var(--key); }

.sheet-top { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.sheet-top h2 { font-size: 22px; color: var(--brand); letter-spacing: -0.01em; }
.sheet-top .from { font-size: 13px; color: var(--ink-2); line-height: 1.6; margin-top: 6px; }
.doc-title { text-align: right; }
.doc-title h3 { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; }
.doc-title dl { display: grid; grid-template-columns: auto auto; gap: 3px 16px; font-size: 13px; margin: 10px 0 0; justify-content: end; }
.doc-title dt { color: var(--muted); } .doc-title dd { margin: 0; font-weight: 600; text-align: right; }
.parties { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 24px; font-size: 13.5px; }
.parties h4 { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.parties p { line-height: 1.6; color: var(--ink-2); }
.parties b { color: var(--ink); }
.sheet table th { background: transparent; border-bottom: 1.5px solid var(--ink); padding: 10px 8px; color: var(--ink); }
.sheet table td { padding: 12px 8px; }
.sheet .group-row td { padding-top: 18px; padding-bottom: 6px; font-weight: 700; font-size: 13px; border-bottom: 0; }
.sheet-foot { display: grid; grid-template-columns: 1fr 300px; gap: 32px; margin-top: 24px; }
.sheet-foot .terms { font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
.sheet-foot .terms h4 { font-size: 13px; margin: 0 0 6px; color: var(--ink); }
.bank { background: var(--paper); border-radius: var(--r-sm); padding: 14px 16px; margin-top: 16px; font-size: 12.5px; display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; }
.bank dt { color: var(--muted); } .bank dd { margin: 0; font-weight: 600; }
.sign { margin-top: 40px; text-align: right; font-size: 12.5px; color: var(--muted); }
.sign b { display: block; color: var(--ink); font-size: 13.5px; margin-top: 36px; border-top: 1px solid var(--line); padding-top: 8px; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: -6px; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: 5px; width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); }
.timeline li.done::after { background: var(--brand); }
.timeline b { display: block; font-weight: 600; }
.timeline small { color: var(--muted); }

/* ---------- Key-value list ---------- */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

/* ---------- Service catalog ---------- */
.cat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.cat-card .cat-top { padding: 18px 20px; display: flex; gap: 14px; align-items: center; border-bottom: 1px solid var(--line-2); }
.cat-ink { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none; }
.cat-ink.c { background: var(--cyan); } .cat-ink.m { background: var(--magenta); } .cat-ink.y { background: var(--yellow-ink); color: var(--ink); } .cat-ink.k { background: var(--key); }
.cat-top h3 { font-size: 16px; }
.cat-top p { font-size: 13px; color: var(--muted); }
.cat-top .btn { margin-left: auto; }
.cat-card ul { list-style: none; margin: 0; padding: 0; }
.cat-card li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.cat-card li:last-child { border-bottom: 0; }
.cat-card li small { display: block; color: var(--muted); font-size: 12.5px; }
.cat-card li .price { text-align: right; font-weight: 600; white-space: nowrap; }
.cat-card li .price small { font-weight: 400; }

/* ---------- Roles matrix ---------- */
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix .module td { background: #F9FAFB; font-weight: 700; font-size: 13px; text-align: left; }
.tick { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--ok-tint); color: var(--ok); }
.tick.no { background: var(--line-2); color: #B3B8C3; }
.tick.own { background: var(--warn-tint); color: var(--warn); font-size: 11px; font-weight: 700; width: auto; padding: 0 6px; }
.role-card { padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.role-card h3 { font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.role-card p { font-size: 13px; color: var(--muted); margin: 6px 0 12px; min-height: 40px; }
.role-card .people { display: flex; }
.role-card .people .avatar { border: 2px solid #fff; margin-left: -6px; }
.role-card .people .avatar:first-child { margin-left: 0; }

/* ---------- Empty / notes ---------- */
.note { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); background: var(--brand-tint); color: var(--brand-dark); font-size: 13.5px; }
.note.warn { background: var(--warn-tint); color: var(--warn); }

.upload { border: 1.5px dashed var(--line); border-radius: var(--r-md); padding: 22px; display: flex; gap: 16px; align-items: center; }
.upload .logo-prev { width: 64px; height: 64px; border-radius: 12px; background: var(--brand); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-art { background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art .dots { position: absolute; right: -120px; bottom: -120px; width: 520px; height: 520px; }
.auth-art .dots span { position: absolute; width: 300px; height: 300px; border-radius: 50%; mix-blend-mode: screen; opacity: .85; }
.auth-art .dots span:nth-child(1) { background: #0A86AD; left: 0; top: 40px; }
.auth-art .dots span:nth-child(2) { background: #BE1E73; left: 150px; top: 40px; }
.auth-art .dots span:nth-child(3) { background: #9A7300; left: 75px; top: 170px; }
.auth-art h2 { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; max-width: 12ch; position: relative; }
.auth-art ul { list-style: none; padding: 0; margin: 24px 0 0; position: relative; max-width: 34ch; color: #C9CDD6; }
.auth-art li { padding: 6px 0; }
.auth-form { display: grid; place-items: center; padding: 48px 24px; background: var(--surface); }
.auth-form .box { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 28px 0 6px; }
.auth-form .box > p { color: var(--muted); margin-bottom: 28px; }
.auth-form .field { margin-bottom: 16px; }
.login-as { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 24px; }
.login-as a { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px; }
.login-as a b { display: block; font-size: 13.5px; }
.login-as a:hover { border-color: var(--brand); }
.login-as small { color: var(--muted); }

/* ---------- Client portal ---------- */
.portal-top { background: var(--surface); border-bottom: 1px solid var(--line); }
.portal-top .in { max-width: 1080px; margin: 0 auto; padding: 16px 24px; display: flex; align-items: center; gap: 16px; }
.portal-top .who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.portal-wrap { max-width: 1080px; margin: 0 auto; padding: 32px 24px 56px; }
.portal-hello { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; margin-bottom: 24px; }
.due-card { background: var(--ink); color: #fff; border-radius: var(--r-lg); padding: 26px 28px; }
.due-card label { color: #AEB4C2; font-size: 13.5px; }
.due-card .big { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; margin: 4px 0 8px; }
.due-card p { color: #C9CDD6; font-size: 14px; margin-bottom: 18px; }
.due-card .btn { background: #fff; color: var(--ink); border-color: #fff; }
.due-card .btn.outline { background: transparent; color: #fff; border-color: #4A5060; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .money-strip { grid-template-columns: 1fr 1fr; }
  .money-strip > div:nth-child(3) { border-left: 0; }
  .money-strip > div:nth-child(n+3) { border-top: 1px solid var(--line-2); }
  .g-main { grid-template-columns: 1fr; }
  .sticky-side { position: static; }
  .builder-head { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  #nav-toggle:checked ~ .app .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  #nav-toggle:checked ~ .app .scrim { display: block; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(22,26,34,.4); z-index: 20; }
  .menu-btn { display: grid; }
  .topbar { padding: 0 16px; }
  .topbar .org-switch, .topbar .search { display: none; }
  .content { padding: 22px 16px 40px; }
  .g-2, .g-3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .portal-hello { grid-template-columns: 1fr; }
  .sheet { padding: 28px 22px; }
  .cmyk-bar { margin: -28px -22px 24px; }
  .sheet-top, .sheet-foot { grid-template-columns: 1fr; flex-direction: column; }
  .doc-title { text-align: left; }
  .doc-title dl { justify-content: start; }
  .parties { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 600px) {
  .g-4, .money-strip, .form-grid, .builder-head, .mix-legend { grid-template-columns: 1fr; }
  .money-strip > div { border-left: 0 !important; border-top: 1px solid var(--line-2); }
  .money-strip > div:first-child { border-top: 0; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Print: only the document ---------- */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .page-head, .no-print, .scrim { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .sheet { border: 0; box-shadow: none; max-width: none; padding: 0; }
  .sheet .reg, .cmyk-bar { display: none; }
}

/* ---------- Phase 2: live data states ---------- */
[hidden] { display: none !important; }
.kpi-num { font-size: 24px; font-weight: 800; margin-top: 4px; letter-spacing: -0.02em; }
.empty-cell { text-align: center; color: var(--muted); padding: 36px 16px !important; }
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state h2 { font-size: 18px; margin-bottom: 6px; }
.empty-state p { color: var(--muted); margin-bottom: 18px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn.loading::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
tr.clickable { cursor: pointer; }

#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r-md); font-size: 14px; box-shadow: 0 8px 24px -8px rgba(22,26,34,.4); }
.toast.error { background: var(--bad); }

dialog { border: 0; border-radius: var(--r-lg); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 24px 60px -20px rgba(22,26,34,.45); color: var(--ink); }
dialog.wide { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(22,26,34,.45); }
.dialog-body { padding: 24px; max-height: calc(100vh - 64px); overflow-y: auto; }
.dialog-body h2 { font-size: 19px; margin-bottom: 6px; }
.dialog-body > .muted, .dialog-body > .section-sub { margin-bottom: 18px; font-size: 14px; }
.dialog-body .field { margin-bottom: 14px; }
.dialog-body .form-grid .field { margin-bottom: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.check-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.check-grid label { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: 14px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; margin: 0; color: var(--ink); }

.line-items .pick { width: 100%; margin-top: 6px; }
.line-items .desc-input { margin-top: 6px; height: 32px !important; font-size: 13px; color: var(--ink-2); }
.matrix select { height: 30px; font-size: 13px; padding: 0 26px 0 8px; background-position: right 8px center; }
.pay-row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 8px 0; border-top: 1px solid var(--line-2); }
.pay-row small { display: block; color: var(--muted); }
.sheet .sheet-note { font-size: 12.5px; color: var(--ink-2); margin-top: 10px; white-space: pre-line; }
@media (max-width: 600px) { .check-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .toolbar .search { max-width: none; flex: 1 1 100%; } .toolbar .select { flex: 1; } }
