/* R2 Rebate admin -- the company back office.
   Same bones as the Swartz portals (topbar -> tab-bar -> panel > wrap > surface)
   in the R2 palette, with light and dark both first-class. Style through the
   tokens; never a colour that only reads in one mode. */

:root {
  /* brand constants */
  --navy: #0B1957;
  --navy-2: #16324F;
  --navy-3: #244060;
  --blue: #9ECCFA;
  --tan: #E6D8C7;
  --cream: #F8F3EA;

  /* LIGHT (default). Page is a cool near-white off the grey-blue scale, not
     the cream: cream next to navy reads yellow. Cream and tan stay available
     as accents, not as the ground. */
  --bg: #EEF2F6;
  --bg2: #FFFFFF;
  --bg3: #F5F7FA;
  --fg: #0B1957;
  --fg-dim: #46617F;
  --accent: #0B1957;
  --accent-fg: #FFFFFF;
  --accent-hover: #16324F;
  --accent-soft: #9ECCFA;
  --success: #1E7A46;
  --warn: #B26B00;
  --error: #B3261E;
  --border: #DDE3E6;
  --border-2: #C7D2D8;
  --shadow: 0 1px 3px rgba(11, 25, 87, .08), 0 1px 2px rgba(11, 25, 87, .06);
  --radius: 8px;
  color-scheme: light;
}
/* DARK. The brand navy is an accent here, not the ground: a whole page of
   #0B1957 is loud and every surface fights it. The ground is a deep,
   desaturated navy-black; surfaces step up from it in the same hue. */
:root[data-theme="dark"] {
  --bg: #0B1220;
  --bg2: #121C30;
  --bg3: #1A2740;
  --fg: #E8EDF3;
  --fg-dim: #9FB2C9;
  --accent: #9ECCFA;
  --accent-fg: #0B1957;
  --accent-hover: #B8DBFC;
  --accent-soft: #1F3358;
  --success: #6FCF97;
  --warn: #E6B450;
  --error: #F28B82;
  --border: #24334F;
  --border-2: #2F416A;
  --shadow: 0 1px 3px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; font-size: 14px;
  display: flex; flex-direction: column;
}
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ---- shared card pages (login, activate) ---- */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  padding: 32px 32px 27px; width: 100%; max-width: 420px;
}
.card .brand { font-size: 15px; font-weight: 700; margin-bottom: 20px; }
.card .brand span { color: var(--accent); }
.card h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.card p.subtitle { margin: 0 0 18px; color: var(--fg-dim); font-size: 13px; line-height: 1.5; }
.card button.btn { margin-top: 28px; width: 100%; }
.card .msg { margin: 14px 0 -8px; font-size: 13px; }
.card .msg:empty { display: none; }
.card .msg.err { color: var(--error); }
.step { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-dim); margin-bottom: 6px; }
.qr { background: #fff; border-radius: 8px; padding: 12px; width: fit-content; margin: 14px auto 0; }
.qr img { display: block; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; letter-spacing: .08em;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px;
  word-break: break-all; text-align: center; margin-top: 6px; user-select: all; }

/* ---- forms ---- */
label { display: block; font-size: 13px; margin: 14px 0 6px; color: var(--fg-dim); font-weight: 500; }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="date"],
input[type="url"], input[type="number"], textarea, select {
  width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
  color: var(--fg); padding: 10px 12px; font-size: 14px; font-family: inherit;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(158, 204, 250, .35); }
select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2346617F' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
input[type="file"] { width: 100%; font-size: 13px; color: var(--fg-dim); }
.hint { font-size: 12.5px; color: var(--fg-dim); margin: 6px 0 0; line-height: 1.5; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
@media (max-width: 40rem) { .two, .three { grid-template-columns: 1fr; } }

/* ---- buttons ---- */
button { font-family: inherit; }
button.btn {
  background: var(--accent); color: var(--accent-fg); border: none; border-radius: 6px;
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
button.btn:hover { background: var(--accent-hover); }
button.btn:disabled { opacity: .55; cursor: not-allowed; }
button.btn.secondary { background: var(--bg3); color: var(--fg); border: 1px solid var(--border); }
button.btn.secondary:hover { background: var(--border); }
button.btn.danger { background: transparent; color: var(--error); border: 1px solid var(--border); }
button.btn.danger:hover { background: rgba(179, 38, 30, .08); }
button.btn.small { padding: 7px 13px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 52px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.topbar-brand { font-size: 15px; font-weight: 700; }
.topbar-brand span { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { font-size: 13px; color: var(--fg-dim); }
.icon-btn { padding: 6px 12px; background: none; border: 1px solid var(--border); color: var(--fg-dim);
  font-size: 13px; font-weight: 500; border-radius: 6px; cursor: pointer; }
.icon-btn:hover { background: var(--bg3); color: var(--fg); }

/* ---- tab bar ---- */
.tab-bar { display: flex; gap: 2px; padding: 12px 24px 1px; margin: 0 auto -1px; max-width: 896px; width: 100%;
  background: var(--bg); flex-shrink: 0; overflow-x: auto; scrollbar-width: none; position: relative; z-index: 2; }
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 9px 18px; background: none; border: 1px solid var(--border); border-bottom: none;
  color: var(--fg-dim); font-size: 13px; font-weight: 500; white-space: nowrap;
  border-radius: 8px 8px 0 0; position: relative; bottom: -1px; cursor: pointer;
}
.tab-btn:hover { color: var(--fg); background: var(--bg3); }
.tab-btn.active { background: var(--bg2); color: var(--fg); font-weight: 600; border-bottom: 1px solid var(--bg2); }
.surface { position: relative; z-index: 1; }
.tab-btn .badge { display: inline-block; margin-left: 7px; min-width: 18px; padding: 1px 6px; border-radius: 999px;
  background: var(--accent); color: var(--accent-fg); font-size: 11px; font-weight: 700; text-align: center; }

/* ---- panels ---- */
.page-content { flex: 1; overflow-y: auto; }
.panel { display: none; }
.panel.active { display: block; }
.wrap { max-width: 896px; margin: 0 auto; padding: 0 24px 24px; }
/* Every tab's window is the same height -- 570px, 1.5x what the Sales tab
   measured empty -- so switching tabs does not resize the page. Content that
   outgrows it scrolls inside. Phones get their natural height instead: a
   fixed 570px box on a 660px screen is most of the screen scrolling inside a
   box that also scrolls. */
.surface { background: var(--bg2); border: 1px solid var(--border); border-radius: 0 8px 8px 8px; padding: 20px; box-shadow: var(--shadow);
  height: 570px; overflow-y: auto; }
@media (max-width: 40rem) { .surface { height: auto; overflow-y: visible; } }
@media (max-width: 40rem) {
  .topbar { padding: 0 14px; }
  .tab-bar { padding: 10px 14px 0; }
  .wrap { padding: 0 10px 16px; }
  .surface { padding: 14px; border-radius: 0 8px 8px 8px; }
}

/* ---- vertical rhythm, the same on every tab ----
   header (title + sub + buttons)   -> 18px
   optional toolbar / stats / facts -> 16px
   table or list
   sub-section header               -> 28px above, 12px below */
:root { --gap-head: 18px; --gap-tool: 16px; --gap-sec: 28px; --gap-sec-in: 12px; }
.row { display: flex; gap: 12px; align-items: center; }
.spread { justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; }
.surface > .row.spread { margin-bottom: var(--gap-head); }
h2.section { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.sub { color: var(--fg-dim); font-size: 13px; margin: 0; }
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: var(--gap-sec) 0 var(--gap-sec-in); }
.sec-head.first { margin-top: 0; }
h3.sub-h { font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--fg-dim); margin: 0; }
.empty { color: var(--fg-dim); font-size: 14px; padding: 18px 0; }

/* ---- filters ---- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 var(--gap-tool); align-items: center; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg3);
  color: var(--fg-dim); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.chip.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.filter-lbl { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-dim); margin-right: 2px; }
.filter-gap { width: 36px; }   /* separation between filter groups; shared by To do and Budget so they match */
/* The paid-by chips are rendered into a span so they can be rebuilt from the
   user list; display:contents lets them sit in the toolbar's own flex flow,
   with the same gap as the chips beside them. */
#budget-who { display: contents; }
.filter-count { font-size: 12px; color: var(--fg-dim); margin-left: auto; }

/* ---- tables ---- */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; background: var(--bg3); color: var(--fg-dim); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .05em; padding: 9px 10px; white-space: nowrap; }
td { padding: 10px; border-top: 1px solid var(--border); vertical-align: middle; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.ctr { text-align: center; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg3); }
tr.group td { background: var(--bg3); color: var(--fg-dim); font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; padding: 10px 12px 6px; text-align: center; }
tr.group td b { color: var(--fg); margin-left: 6px; }
.dim { color: var(--fg-dim); }
.strong { font-weight: 600; color: var(--fg); }

/* ---- pills ---- */
.pill { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; text-align: center; }
.pill.active, .pill.live, .pill.signed, .pill.business { background: rgba(30, 122, 70, .14); color: var(--success); }
.pill.waiting, .pill.onboarding, .pill.sent, .pill.at_risk { background: rgba(178, 107, 0, .14); color: var(--warn); }
.pill.on_hold, .pill.prospect, .pill.draft, .pill.idle { background: var(--bg3); color: var(--fg-dim); border: 1px solid var(--border); }
.pill.closed, .pill.churned, .pill.expired, .pill.cancelled { background: rgba(179, 38, 30, .10); color: var(--error); }
.pill.personal { background: rgba(158, 204, 250, .35); color: var(--fg); }
.pill.google { background: rgba(158, 204, 250, .35); color: var(--fg); }
.pill.direct { background: var(--bg3); color: var(--fg-dim); border: 1px solid var(--border); }

/* ---- lists ---- */
/* Fixed columns, so who a ticket is for lines up whether or not it has a due
   date. As a flex row an empty due cell handed its width to the neighbours and
   the assignee column wandered. */
.item { border-top: 1px solid var(--border); padding: 12px 0; display: grid; grid-template-columns: 84px 1fr 200px 150px;
  gap: 12px; align-items: center; cursor: pointer; }
.item:first-child { border-top: none; }
.item:hover { background: var(--bg3); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 6px; }
.item .pill { justify-self: start; }
.item .t { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .m { font-size: 12.5px; color: var(--fg-dim); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .w { font-size: 12px; color: var(--fg-dim); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
@media (max-width: 40rem) {
  .item { grid-template-columns: 84px 1fr; row-gap: 4px; }
  .item .t { white-space: normal; }
  .item .m { grid-column: 2; }
  .item .w { grid-column: 2; text-align: left; }
}
.item.overdue .w { color: var(--error); font-weight: 600; }

/* ---- stats ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 0 0 var(--gap-tool); }
.stat { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.stat .k { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-dim); }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .n { font-size: 12px; color: var(--fg-dim); margin-top: 2px; }

/* ---- facts ---- */
/* Entity and State at 0.85 of an even share; NAICS takes the rest,
   since its label is the long one. */
.facts { display: grid; grid-template-columns: 0.85fr 0.85fr 1.3fr; gap: 10px; margin: 0 0 var(--gap-tool); }
@media (max-width: 40rem) { .facts { grid-template-columns: 1fr; } }
.fact { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.fact .k { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-dim); }
.fact .v { font-size: 15px; font-weight: 600; margin-top: 3px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---- accordion (documents) ---- */
details.cat { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; background: var(--bg2); }
details.cat > summary { cursor: pointer; padding: 12px 14px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 12px; }
details.cat > summary::-webkit-details-marker { display: none; }
details.cat > summary .dim { margin-left: auto; font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right; }
details.cat > summary::after { content: "\25BE"; color: var(--fg-dim); width: 1em; text-align: center; }
details.cat[open] > summary::after { content: "\25B4"; }
details.year { margin: 0 12px 10px; border-left: 3px solid var(--accent-soft); }
details.year > summary { cursor: pointer; padding: 8px 12px; font-weight: 600; font-size: 13px; color: var(--fg-dim); list-style: none; }
details.year > summary::-webkit-details-marker { display: none; }
.doc { display: flex; gap: 10px; align-items: center; padding: 8px 12px 8px 24px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.doc .t { flex: 1 1 220px; font-weight: 500; }
.doc .m { font-size: 12px; color: var(--fg-dim); }

/* ---- modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(11, 25, 87, .45); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
:root[data-theme="dark"] .modal-back { background: rgba(0, 0, 0, .6); }
.modal-back.open { display: flex; }
.modal { position: relative; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  padding: 26px 28px; width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto; }
.modal h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; padding-right: 32px; }
.modal-x { position: absolute; top: 10px; right: 10px; background: none; border: none; color: var(--fg-dim); font-size: 18px; cursor: pointer; padding: 6px 10px; border-radius: 6px; }
.modal-x:hover { background: var(--bg3); color: var(--fg); }
.modal .btn-row { justify-content: flex-end; }
.modal .btn-row .left { margin-right: auto; }
@media (max-width: 40rem) { .modal { padding: 20px 16px; max-height: 96vh; } .modal .btn-row button { flex: 1; } }

/* ---- comments ---- */
.thread { margin-top: 18px; }
.thread h3.sub-h { margin-bottom: 8px; }
.thread .sec-head { margin-top: 0; }
.cmt { border-top: 1px solid var(--border); padding: 12px 0; }
.cmt .h { font-size: 12px; color: var(--fg-dim); margin-bottom: 4px; }
.cmt .h b { color: var(--fg); }
.cmt .b { white-space: pre-wrap; line-height: 1.5; }
.meta-line { font-size: 12.5px; color: var(--fg-dim); margin: 2px 0 14px; }

/* ---- settings ---- */
.field-set { border: 1px solid var(--border); border-radius: 8px; padding: 4px 18px 18px; margin: 16px 0; }
.field-set h3 { font-size: 14px; font-weight: 600; margin: 16px 0 2px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: 8px; }
.seg button { padding: 8px 16px; background: var(--bg3); border: none; color: var(--fg-dim); font-size: 13px; font-weight: 600; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent); color: var(--accent-fg); }

/* ---- upload drop ---- */
.drop { border: 1.5px dashed var(--border-2); border-radius: 8px; padding: 16px; text-align: center; color: var(--fg-dim); font-size: 13px; cursor: pointer; margin-top: 6px; }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--fg); background: var(--bg3); }
.drop b { color: var(--fg); }
.file-tag { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; padding: 6px 10px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.file-tag a { color: var(--accent); }
