/* GrowthOS Cloud. Slate neutrals, navy primary, Zyntra teal for active and progress, red only for errors, Promovo
   green only in the brand mark. A distributor's workspace swaps --brand / --accent for its own colours. */
:root {
  --bg: #F4F6FA; --surface: #FFFFFF; --line: #E2E8F0; --line-2: #EEF2F7;
  --ink: #0F172A; --ink-2: #334155; --muted: #64748B; --faint: #94A3B8;
  --navy: #0B1324; --teal: #00C2C7; --teal-d: #00A3A8; --red: #DC2626; --green: #16A34A; --amber: #D97706;
  --brand: #0F172A; --accent: #00A3A8; --on-brand: #FFFFFF;
  --r: 10px; --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--sans); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.brand { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger { color: var(--red); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.block { width: 100%; height: 40px; }
.field { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; }
.field small { font-weight: 400; color: var(--muted); }
.field input, .field select, .field textarea { height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 400; }
.field textarea { height: auto; min-height: 80px; padding: 9px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.chk { display: flex; gap: 9px; align-items: flex-start; font-weight: 400; cursor: pointer; }
.chk input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.notice { border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 7%, #fff); padding: 12px 14px; border-radius: 8px; }
.err { color: var(--red); font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill i { width: 7px; height: 7px; border-radius: 99px; background: var(--faint); }
.pill.on i { background: var(--green); } .pill.warn i { background: var(--amber); } .pill.off i { background: var(--red); }

/* sign-in */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 460px) 1fr; }
.auth-form { background: #fff; padding: 48px 44px; display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.auth-side { background: var(--navy); color: #CBD5E1; padding: 56px; display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; }
.auth-side h2 { color: #fff; font-size: 28px; line-height: 1.2; letter-spacing: -.02em; max-width: 520px; }
.auth-side p { max-width: 520px; margin: 0; }
.mark { display: flex; align-items: center; gap: 10px; }
.mark img { width: 34px; height: 34px; }
.mark b { font-size: 18px; letter-spacing: -.01em; } .mark b span { color: var(--teal-d); }
.mark small { display: block; color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 4px; background: var(--line-2); padding: 3px; border-radius: 9px; width: fit-content; }
.tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15,23,42,.08); }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #B4C0D3; padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .mark b { color: #fff; } .side .mark small { color: #8191AB; }
.side.branded { background: var(--brand); }
.side.branded, .side.branded .nav { color: color-mix(in srgb, var(--on-brand) 78%, transparent); }
.ws { display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,.06); border-radius: 10px; padding: 10px; }
.ws img { max-width: 72px; max-height: 34px; background: #fff; border-radius: 6px; padding: 3px; }
.ws b { color: #fff; display: block; font-size: 13px; line-height: 1.25; } .ws small { font-size: 11.5px; }
.nav { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 8px; color: #B4C0D3; text-decoration: none; font-weight: 500; }
.nav:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav.on { background: color-mix(in srgb, var(--accent) 22%, transparent); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-h { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #5B6A86; padding: 0 10px; margin-top: 4px; }
.me { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; display: flex; gap: 10px; align-items: center; }
.me .av { width: 30px; height: 30px; border-radius: 99px; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.me b { color: #fff; display: block; font-size: 12.5px; } .me small { font-size: 11.5px; }
.main { padding: 26px 30px 60px; min-width: 0; }
.page-h { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-h p { margin: 4px 0 0; color: var(--muted); }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 6px; } .crumb a { color: var(--muted); text-decoration: none; } .crumb a:hover { color: var(--ink); }

/* tables */
.table { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.tr { display: grid; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--line-2); min-width: 720px; }
.tr:last-child { border-bottom: 0; }
.tr.th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #FAFBFD; }
.tr.click { cursor: pointer; } .tr.click:hover { background: #FAFBFD; }
.cols-d { grid-template-columns: minmax(220px, 2fr) 120px 110px 110px 120px; }
.cols-p { grid-template-columns: minmax(200px, 1.6fr) 1.2fr 150px 110px 150px; }
.co { display: flex; align-items: center; gap: 10px; min-width: 0; }
.co .lg { width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; background: #fff; overflow: hidden; flex: none; font-weight: 700; font-size: 12px; color: #fff; }
.co .lg img { max-width: 100%; max-height: 100%; object-fit: contain; }
.co .lg.brand { width: auto; min-width: 56px; max-width: 200px; height: 52px; padding: 6px 10px; }
.co .lg.brand img { height: 40px; width: auto; max-width: 180px; max-height: none; }
.auth-form .co { flex-wrap: wrap; }
.co b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .co small { color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font-size: 22px; letter-spacing: -.01em; } .stat span { color: var(--muted); font-size: 12.5px; }
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.subtabs a { padding: 9px 14px; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subtabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
.two { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 18px; align-items: start; }

/* branding preview */
.swatch { display: flex; gap: 8px; align-items: center; }
.swatch input[type=color] { width: 42px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.swatch input[type=text] { flex: 1; }
.preview { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.preview .pv-side { background: var(--pv-brand); padding: 14px; color: color-mix(in srgb, var(--pv-on) 80%, transparent); display: flex; flex-direction: column; gap: 8px; }
.preview .pv-side .ws { background: rgba(255,255,255,.1); }
.preview .pv-nav { height: 28px; border-radius: 7px; padding: 0 9px; display: flex; align-items: center; font-size: 12.5px; }
.preview .pv-nav.on { background: color-mix(in srgb, var(--pv-accent) 26%, transparent); color: var(--pv-on); box-shadow: inset 3px 0 0 var(--pv-accent); }
.preview .pv-body { padding: 14px; display: flex; gap: 8px; align-items: center; }
.logo-drop { border: 1.5px dashed var(--line); border-radius: 10px; padding: 14px; display: flex; gap: 14px; align-items: center; background: #FAFBFD; }
.logo-drop img { max-width: 140px; max-height: 60px; background: #fff; border-radius: 6px; padding: 4px; }

/* roles */
.perm { display: grid; grid-template-columns: 1fr repeat(var(--n), 110px); align-items: center; border-bottom: 1px solid var(--line-2); padding: 9px 16px; min-width: 560px; gap: 8px; }
.perm.th { font-weight: 600; font-size: 12.5px; background: #FAFBFD; }
.perm span:not(:first-child) { text-align: center; }
.switch { position: relative; width: 36px; height: 20px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #CBD5E1; border-radius: 99px; transition: .15s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; background: #fff; border-radius: 99px; transition: .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:disabled + i { opacity: .5; cursor: default; }

/* modal + toast */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-box { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 20px; right: 20px; max-width: 420px; background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(15,23,42,.25); z-index: 60; display: flex; flex-direction: column; gap: 2px; }
.toast.err { background: #7F1D1D; } .toast span { color: #CBD5E1; font-size: 13px; }
.linkbox { display: flex; gap: 6px; } .linkbox input { flex: 1; font-size: 12.5px; }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; } .auth-side { display: none; } .auth-form { padding: 32px 16px; }
  .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; gap: 6px; padding: 10px 16px; }
  .side .nav-h, .side .me { display: none; } .side .mark small { display: none; }
  .main { padding: 18px 16px 48px; } .grid2, .two { grid-template-columns: 1fr; } .stats { grid-template-columns: 1fr 1fr; }
}

/* distributors list with billing columns */
.cols-d2 { grid-template-columns: minmax(220px, 2fr) 100px 90px 110px 130px 140px; min-width: 820px; }
/* features */
.feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.feat-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line-2); cursor: pointer; }
.feat-row:first-of-type { border-top: 0; }
/* invoice editor */
.inv-head, .inv-line { display: grid; grid-template-columns: minmax(0, 1fr) 70px 110px 110px 36px; gap: 8px; align-items: center; }
.inv-head { font-size: 12px; color: var(--muted); font-weight: 600; }
.inv-line { margin-top: 6px; }
.field-in { height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 0; }
.inv-line .amt { text-align: right; font-variant-numeric: tabular-nums; }
.inv-tot { display: flex; justify-content: flex-end; gap: 22px; padding: 10px 0; border-top: 1px solid var(--line); }
.inv-tot b { margin-left: 6px; }
