/* SevenC re-skin — consumes the brand tokens from sevenc-tokens.css.
   The legacy palette vars below are remapped onto the --sc-* semantic
   tokens so existing rules inherit the brand. Surface-sensitive accents
   read --sc-accent directly and rely on .sc-on-dark wrappers. */
:root {
  --brand: var(--sc-ink);          /* dark surfaces: header, section heads, toast */
  --brand-light: var(--sc-cream-2);
  --accent: var(--sc-accent);       /* light default = lime-dark; flips on .sc-on-dark */
  --bg: var(--sc-bg);
  --card: var(--sc-bg-raised);
  --text: var(--sc-fg);
  --muted: var(--sc-fg-muted);
  --border: var(--sc-divider);
  --radius: var(--sc-radius-lg);
  --shadow: var(--sc-shadow-sm);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sc-font-sans);
  background: var(--sc-bg);
  color: var(--sc-fg);
  font-size: var(--sc-fs-base);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--sc-ink);
  color: var(--sc-fg);            /* under .sc-on-dark resolves to light text */
  box-shadow: var(--sc-shadow-md);
  border-bottom: 2px solid var(--sc-lime);
}
.brand { display: flex; align-items: center; gap: 18px; }
.brand-logo { display: flex; flex-direction: column; gap: 5px; }
.logo-wordmark { height: 30px; width: auto; display: block; }
.brand-logo .sc-tagline { font-size: 11px; line-height: 1; }
.brand-divider { width: 1px; align-self: stretch; background: var(--sc-divider); margin: 3px 0; }
.brand-app h1 { margin: 0; font-family: var(--sc-font-sans); font-size: 18px; font-weight: 900; letter-spacing: var(--sc-ls-tight); }
.tagline { margin: 3px 0 0; font-size: 12px; color: var(--sc-fg-2); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: none;
  background: var(--sc-accent);
  color: var(--sc-accent-ink);    /* ink text on lime — the brand pairing */
  padding: 8px 14px;
  border-radius: var(--sc-radius-md);
  font-family: var(--sc-font-sans);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.12s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--sc-divider);
  color: var(--sc-fg);
}
.btn-ghost:hover { filter: none; background: var(--sc-track); }

.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  max-width: 1240px;
  margin: 20px auto;
  padding: 0 24px;
  align-items: start;
}

.card {
  background: var(--sc-bg-raised);
  border: 1px solid var(--sc-divider);
  border-radius: var(--radius);
  box-shadow: var(--sc-shadow-sm);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 12px; font-family: var(--sc-font-sans); font-weight: 900; font-size: 15px; color: var(--sc-fg); }

.grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: var(--sc-fs-xs); font-weight: 700;
  letter-spacing: var(--sc-ls-wide); text-transform: uppercase;
  color: var(--sc-fg-muted);
}
input[type="text"], input[type="date"] {
  border: 1px solid var(--sc-divider);
  border-radius: var(--sc-radius-sm);
  padding: 8px 10px;
  font-family: var(--sc-font-sans);
  font-size: 14px;
  text-transform: none; letter-spacing: normal;
  color: var(--sc-fg);
  background: var(--sc-bg-raised);
}
input:focus { outline: 2px solid var(--sc-accent); outline-offset: -1px; }

.section { margin-bottom: 18px; }
/* Rotating KPI accent: lime -> orange -> purple -> muted */
#sections .section:nth-of-type(4n + 1) { --sec-accent: var(--sc-lime); }
#sections .section:nth-of-type(4n + 2) { --sec-accent: var(--sc-orange); }
#sections .section:nth-of-type(4n + 3) { --sec-accent: var(--sc-purple); }
#sections .section:nth-of-type(4n + 4) { --sec-accent: var(--sc-fg-muted); }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 10px 14px;
  background: var(--sc-ink);
  color: var(--sc-text-light-1);
  border-left: 4px solid var(--sec-accent, var(--sc-lime));
  border-radius: var(--radius) var(--radius) 0 0;
}
.section-head h2 { margin: 0; font-family: var(--sc-font-sans); font-weight: 900; color: var(--sc-text-light-1); font-size: 15px; }
.section-head .section-sub { font-size: 11px; color: var(--sc-text-light-2); font-style: italic; margin-left: 8px; }
.section-head .section-subtotal { font-family: var(--sc-font-mono); font-weight: 500; font-size: 14px; color: var(--sc-lime); }

/* Fixed layout + a shared colgroup so every section table uses the SAME
   column grid, keeping COST / QTY / LINE TOTAL aligned vertically down the page. */
table.lines { width: 100%; table-layout: fixed; border-collapse: collapse; background: var(--sc-bg-raised); border: 1px solid var(--sc-divider); border-top: none; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
table.lines .col-product { width: auto; }   /* flexible — fills remaining width */
table.lines .col-cost  { width: 110px; }
table.lines .col-qty   { width: 120px; }
table.lines .col-total { width: 120px; }
table.lines th, table.lines td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--sc-divider); }
table.lines th { background: var(--sc-cream-2); color: var(--sc-fg-2); font-size: var(--sc-fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: var(--sc-ls-wide); }
table.lines tr:last-child td { border-bottom: none; }
table.lines td.num, table.lines th.num { text-align: right; }
table.lines td.qty-col, table.lines th.qty-col { text-align: center; }
/* Currency values never break across two lines (e.g. "R 1,250"). */
table.lines .money, table.lines .line-total { white-space: nowrap; }
table.lines .product-name { font-weight: 700; }
table.lines .tier-badge { display: inline-block; margin-left: 8px; font-size: 11px; background: var(--sc-lime-soft); color: var(--sc-lime-dark); border-radius: var(--sc-radius-pill); padding: 2px 8px; font-weight: 700; }
.note { color: var(--sc-fg-muted); font-size: 11.5px; margin-top: 3px; }

/* Slider toggle for per-product price exceptions (e.g. tenant-to-tenant). */
.opt-toggle { display: inline-flex; align-items: center; gap: 8px; margin-top: 7px; cursor: pointer; font-size: 11.5px; color: var(--sc-lime-dark); font-weight: 700; }
.opt-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch { position: relative; width: 38px; height: 20px; background: var(--sc-track); border: 1px solid var(--sc-divider); border-radius: var(--sc-radius-pill); transition: background 0.15s ease; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: var(--sc-bg-raised); border-radius: 50%; transition: transform 0.15s ease; box-shadow: 0 1px 2px rgba(11,21,14,0.3); }
.opt-toggle input:checked + .switch { background: var(--sc-accent); border-color: var(--sc-accent); }
.opt-toggle input:checked + .switch::after { transform: translateX(18px); }
.opt-toggle input:focus + .switch { outline: 2px solid var(--sc-accent); outline-offset: 2px; }
tr.alt-line { background: rgba(226, 90, 41, 0.08); }
tr.alt-line.active-line { background: rgba(226, 90, 41, 0.14); }
.qty-input {
  width: 90px; text-align: right;
  border: 1px solid var(--sc-divider); border-radius: var(--sc-radius-sm); padding: 7px 9px;
  font-family: var(--sc-font-mono); font-size: 14px; color: var(--sc-fg);
  background: var(--sc-bg-raised);
}
.qty-input:focus { outline: 2px solid var(--sc-accent); outline-offset: -1px; }
.line-total { font-family: var(--sc-font-mono); font-weight: 500; font-variant-numeric: tabular-nums; }
tr.active-line { background: rgba(193, 207, 52, 0.12); }

.sidebar { position: sticky; top: 84px; }
.summary { border-top: 3px solid var(--sc-lime); }
.summary h2 { margin-bottom: 6px; }
.total-big { font-family: var(--sc-font-display); font-size: var(--sc-fs-3xl); font-weight: 900; color: var(--sc-lime-dark); letter-spacing: var(--sc-ls-tight); font-variant-numeric: tabular-nums; margin-bottom: 12px; }
.vat-toggle { flex-direction: row; align-items: center; gap: 8px; font-size: 12px; color: var(--sc-fg); cursor: pointer; margin-bottom: 10px; text-transform: none; letter-spacing: normal; font-weight: 500; }
.vat-toggle input { width: 16px; height: 16px; accent-color: var(--sc-lime-dark); }
.vat-block { border-top: 1px solid var(--sc-divider); padding-top: 10px; margin-bottom: 10px; }
.vat-block .row, .subtotals .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.vat-block .row span:last-child, .subtotals .row span:last-child { font-family: var(--sc-font-mono); }
.vat-block .row.total { font-weight: 700; color: var(--sc-fg); border-top: 1px solid var(--sc-divider); margin-top: 4px; padding-top: 8px; }
.vat-block .row.total span:last-child { color: var(--sc-lime-dark); }
.summary h3 { font-size: var(--sc-fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: var(--sc-ls-wide); color: var(--sc-fg-muted); margin: 12px 0 6px; }
.subtotals .row { color: var(--sc-fg); }
.subtotals .row span:last-child { font-variant-numeric: tabular-nums; font-weight: 500; }

.drawer { position: fixed; inset: 0; background: rgba(11, 21, 14, 0.5); z-index: 40; display: flex; justify-content: flex-end; }
/* An explicit display above overrides the UA [hidden] rule, so restore it. */
.drawer[hidden] { display: none; }
.drawer-panel { width: 420px; max-width: 92vw; height: 100%; background: var(--sc-bg-raised); box-shadow: -4px 0 20px rgba(11,21,14,0.25); padding: 20px; overflow-y: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.drawer-head h2 { font-family: var(--sc-font-sans); font-weight: 900; }
.drawer-x { border: none; background: var(--sc-cream-2); color: var(--sc-fg); width: 34px; height: 34px; border-radius: var(--sc-radius-md); font-size: 22px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.drawer-x:hover { background: var(--sc-track); }
.quote-list { list-style: none; margin: 0; padding: 0; }
.quote-list li { border: 1px solid var(--sc-divider); border-radius: var(--sc-radius-md); padding: 12px; margin-bottom: 10px; }
.quote-list .ql-title { font-weight: 900; color: var(--sc-lime-dark); }
.quote-list .ql-owner { font-weight: 500; font-size: 12px; color: var(--sc-fg-muted); }
.quote-list .ql-meta { font-size: 12px; color: var(--sc-fg-muted); margin: 2px 0 8px; }
.quote-list .ql-actions { display: flex; gap: 6px; }
.quote-list .ql-actions button { font-size: 12px; padding: 5px 10px; }
.btn-danger { background: var(--sc-orange); color: var(--sc-white); }

.appfooter { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 22px 24px 30px; color: var(--sc-fg-muted); font-size: var(--sc-fs-xs); font-weight: 700; letter-spacing: var(--sc-ls-wide); text-transform: uppercase; }
.appfooter .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--sc-lime-dark); flex: none; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--sc-ink); color: var(--sc-text-light-1); padding: 12px 20px; border-radius: var(--sc-radius-md); box-shadow: var(--sc-shadow-lg); z-index: 60; font-size: 13px; border-left: 3px solid var(--sc-lime); }

/* Header identity controls (sit in the dark .sc-on-dark topbar) */
.header-sep { width: 1px; align-self: stretch; background: var(--sc-divider); margin: 2px 2px; }
.user-chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; color: var(--sc-fg); letter-spacing: var(--sc-ls-wide); text-transform: uppercase; padding: 0 4px; }

/* ---- Login page ---- */
.auth-wrap { max-width: 420px; margin: 60px auto; padding: 0 24px; }
.auth-card { display: flex; flex-direction: column; gap: 14px; }
.auth-card h2 { margin: 0; font-family: var(--sc-font-sans); font-weight: 900; color: var(--sc-fg); font-size: 20px; }
.auth-sub { margin: 0; color: var(--sc-fg-muted); font-size: 13px; }
.auth-card label { text-transform: none; letter-spacing: normal; font-weight: 700; font-size: 12px; color: var(--sc-fg-2); }
.auth-card input { border: 1px solid var(--sc-divider); border-radius: var(--sc-radius-sm); padding: 9px 11px; font-family: var(--sc-font-sans); font-size: 14px; background: var(--sc-bg-raised); color: var(--sc-fg); }
.auth-card input:focus { outline: 2px solid var(--sc-accent); outline-offset: -1px; }
.auth-submit { margin-top: 4px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.login-error { background: rgba(226, 90, 41, 0.10); border-left: 3px solid var(--sc-orange); color: var(--sc-fg); padding: 9px 12px; border-radius: var(--sc-radius-sm); font-size: 13px; }

/* ---- Admin / user management ---- */
.admin-wrap { max-width: 1000px; margin: 24px auto; padding: 0 24px; }
.admin-table { table-layout: auto; }
.admin-table .badge { display: inline-block; font-size: 11px; font-weight: 700; border-radius: var(--sc-radius-pill); padding: 2px 8px; }
.admin-table .badge-on { background: var(--sc-lime-soft); color: var(--sc-lime-dark); }
.admin-table .badge-off { background: var(--sc-cream-2); color: var(--sc-fg-muted); }
.admin-table .you { color: var(--sc-fg-muted); font-weight: 400; font-size: 11px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inline-form { display: inline-flex; gap: 4px; margin: 0; }
.reset-form input { width: 120px; border: 1px solid var(--sc-divider); border-radius: var(--sc-radius-sm); padding: 4px 7px; font-size: 12px; }
.btn-sm { font-size: 12px; padding: 5px 10px; }
.add-user-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.add-user-form label { display: flex; flex-direction: column; gap: 5px; font-size: var(--sc-fs-xs); font-weight: 700; letter-spacing: var(--sc-ls-wide); text-transform: uppercase; color: var(--sc-fg-muted); }
.add-user-form input, .add-user-form select { border: 1px solid var(--sc-divider); border-radius: var(--sc-radius-sm); padding: 8px 10px; font-family: var(--sc-font-sans); font-size: 14px; text-transform: none; letter-spacing: normal; background: var(--sc-bg-raised); color: var(--sc-fg); }
.flash { padding: 9px 12px; border-radius: var(--sc-radius-sm); font-size: 13px; margin-bottom: 12px; }
.flash-ok { background: var(--sc-lime-soft); color: var(--sc-lime-dark); border-left: 3px solid var(--sc-lime-dark); }
.flash-err { background: rgba(226, 90, 41, 0.10); color: var(--sc-fg); border-left: 3px solid var(--sc-orange); }

/* Admin tabs (Users | Pricing) */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--sc-divider); }
.admin-tab { padding: 9px 16px; font-size: 13px; font-weight: 700; letter-spacing: var(--sc-ls-wide); text-transform: uppercase; color: var(--sc-fg-muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.admin-tab:hover { color: var(--sc-fg); }
.admin-tab.active { color: var(--sc-fg); border-bottom-color: var(--sc-lime-dark); }

/* Pricing editor */
.rate-table colgroup col:nth-child(3), .rate-table colgroup col:nth-child(4) { width: 160px; }
.rate-table .rate-group td { background: var(--sc-cream-2); color: var(--sc-fg); font-weight: 900; font-size: 12px; text-transform: uppercase; letter-spacing: var(--sc-ls-wide); }
.rate-key { color: var(--sc-fg-muted); font-size: 12px; }
.rate-prefix { color: var(--sc-fg-muted); }
.rate-input { width: 100px; text-align: right; border: 1px solid var(--sc-divider); border-radius: var(--sc-radius-sm); padding: 6px 8px; font-family: var(--sc-font-mono); font-size: 14px; background: var(--sc-bg-raised); color: var(--sc-fg); }
.rate-input:focus { outline: 2px solid var(--sc-accent); outline-offset: -1px; }
.rate-action { white-space: nowrap; }
.rate-status { font-size: 12px; font-weight: 700; margin-left: 6px; }
.rate-status.ok { color: var(--sc-lime-dark); }
.rate-status.err { color: var(--sc-orange); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .grid-4 { grid-template-columns: 1fr; }
  .brand { gap: 12px; }
}
