/* SuperOffice — a closed set of primitives, on the Blue Whale tokens.
 *
 * Same vocabulary as the CRM (--paper / --ink / --line / --accent). TWO families,
 * not three: IBM Plex Sans for everything that is read, IBM Plex Mono for every
 * number, date, username and eyebrow. A figure is set in the same face wherever
 * it appears, so a column of dates lines up and two rows compare at a glance.
 *
 * Archivo used to carry the headings. It is not in BRAND.md's font list, so it
 * failed `jerry qc --brand` — and a display face buying nothing but a slightly
 * tighter H1 is not worth a second family over the wire. Plex Sans 600/700.
 *
 * TYPE: four rendered sizes, all on BRAND.md's scale — 12 eyebrow/column head,
 * 13 controls and meta, 15 body and table, 20 page and dialog titles.
 * RADIUS: three rungs, all Blue Whale's — 12 controls, 18 surfaces, 26 dialog.
 * Pills (999px) and the circular mark (50%) are shapes, not a fourth rung.
 *
 * There is no utility layer here on purpose. Anything not below is a class this
 * app did not need, and adding one is a decision rather than a reflex. */

*, *::before, *::after { box-sizing: border-box; }

/* The primary button's fill-on-hover and its label colour. Light mode: a darker
   step of the same blue, carrying white. Dark mode overrides both — see the foot
   of this file for why the label stops being white there. */
:root { --accent-press: var(--color-accent-deep); --accent-ink: #fff; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: inherit; letter-spacing: -0.022em; margin: 0; }
h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 12px; }
a { text-decoration-thickness: 1px; text-underline-offset: 2px; }

.mono, .num, time, .eyebrow {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
  font-variant-numeric: tabular-nums;
}
.eyebrow {
  font-size: 12px; font-weight: 500; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.muted { color: var(--muted); }
.dim   { color: var(--ink-2); }

/* Everything secondary — a helper under a field, a count, a saved-just-now
   message — is one size and one colour. Replaces eleven inline font-size
   declarations that had drifted across 13px, 13.5px and 14px. */
.meta { font-size: 13px; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

/* ---- shell ------------------------------------------------------------- */

.bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--card);
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.brand span { font-weight: 700; }
.bar .grow { flex: 1 1 auto; min-width: 0; }

main { max-width: 1040px; margin: 0 auto; padding: 28px 20px 72px; }
main.wide { max-width: 1220px; }

.head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.head .grow { flex: 1 1 auto; min-width: 0; }

/* ---- surfaces. ONE level of containment; never a card inside a card. ---- */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.pad { padding: 20px; }

/* ---- controls ---------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  text-decoration: none;
  transition: background .14s ease, border-color .14s ease, transform .14s ease;
}
.btn:hover { background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-press); border-color: var(--accent-press); }
.btn-sm { min-height: 30px; padding: 4px 10px; }
.btn-bad { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-bad:hover { background: var(--bad-soft); }

.field { margin-bottom: 14px; }
.flabel { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
.fin {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--paper); color: var(--ink);
  font: inherit;
}
.fin:focus { border-color: var(--accent); }
input[type="date"].fin { font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border: 1px solid var(--line-2); border-radius: 999px;
  font-size: 13px; cursor: pointer; user-select: none;
}
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-deep); }
.check input { accent-color: var(--accent); margin: 0; }

/* ---- status. Colour never carries the meaning alone — the word is there. -- */

.state {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: "IBM Plex Mono", monospace; font-size: 12px; font-weight: 500;
}
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state.active   { color: var(--ok); }
.state.expiring { color: var(--warn); }
.state.lapsed, .state.suspended, .state.company-suspended { color: var(--bad); }
.state.empty    { color: var(--muted); }
/* Two states on one cell — "off" and "no tools" — need air, not a comma. */
.state + .state { margin-left: 12px; }

/* ---- table ------------------------------------------------------------- */

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th {
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-2);
  font-family: "IBM Plex Mono", monospace; font-size: 12px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--raised); }
td.right, th.right { text-align: right; }
td.indent, th.indent { padding-left: 26px; }

/* A company is a CAPTION over its accounts, not another status row: the accounts
   below carry the state, and repeating it here is the same fact stated twice. */
tr.group th {
  background: var(--raised); color: var(--ink);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em; text-transform: none; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
tr.group td { background: var(--raised); padding: 6px 12px; }
tr.group:hover th, tr.group:hover td { background: var(--raised); }
tr.group th .state { margin-left: 10px; }
td .rowact { display: flex; gap: 6px; justify-content: flex-end; }

/* ---- tool grid --------------------------------------------------------- */

.tools { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.tool {
  display: block; padding: 18px; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .16s cubic-bezier(.16,1,.3,1), box-shadow .16s ease, border-color .16s ease;
}
.tool:hover { transform: translateY(-2px); box-shadow: var(--lift); border-color: var(--line-2); }
.tool h3 { margin: 0; }

.uploader { margin-bottom: 18px; }
.logonow { display: block; max-height: 52px; margin-bottom: 8px; }

/* ---- flashes and empty states ------------------------------------------ */

.note { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.note.bad  { background: var(--bad-soft);  color: var(--bad); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.ok   { background: var(--ok-soft);   color: var(--ok); }

.empty {
  border: 1px dashed var(--line-2); border-radius: var(--radius);
  padding: 36px 24px; text-align: center; color: var(--muted); font-size: 15px;
}

/* ---- sign-in ----------------------------------------------------------- */

/* No card. The form IS the page, and a border drawn around the whole page
   separates it from nothing — one containment level, and this surface spends
   it on nothing. */
.signin { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.signin form { width: 100%; max-width: 340px; }
.signin h1 { margin-bottom: 22px; }
.signin .btn { width: 100%; margin-top: 4px; }
.signin .foot { margin: 16px 0 0; }

/* ---- drawer. One panel, opened over the table, for editing one row. ----- */

dialog {
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 0;
  background: var(--card); color: var(--ink); max-width: 460px; width: calc(100% - 32px);
  box-shadow: var(--lift);
}
dialog::backdrop { background: rgba(var(--scrim), .72); backdrop-filter: blur(3px); }
dialog .pad { padding: 22px; }
dialog h2 { margin-bottom: 4px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.actions .grow { flex: 1 1 auto; }

/* ---- focus. One rule, every focusable thing, including the sign-in fields
 * which had none: .fin only ever styled :focus, and a box-shadow alone is
 * invisible under forced-colors. The outline is the guarantee; the soft ring
 * is the house look sitting behind it. */
.btn:focus-visible,
.fin:focus-visible,
.tool:focus-visible,
a:focus-visible,
summary:focus-visible,
[type="file"]:focus-visible,
#impersonation-bar button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: var(--ring);
}
.check:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: var(--ring); }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ---- theme -------------------------------------------------------------
 * The colours are palette.css's — navy, gold and cream, the builder's own —
 * loaded AFTER this file on every page, and it carries light and dark in one
 * light-dark() block. This file used to hold a separate near-black-and-blue
 * dark theme; it made every page but the builder a different product, so it
 * is gone. Gold is a FILL here, never text on cream (2.15:1): links and the
 * wordmark take --color-accent-deep, which moves with the mode.
 * ------------------------------------------------------------------------- */
a, .brand span { color: var(--color-accent-deep); }

/* ---- the mark -----------------------------------------------------------
 * superoffice-mark.svg — a page on a navy disc. It carries its own ground, so
 * one file serves both themes — no light and dark variant to keep in step.
 * It replaced the real-estate site's house-and-chart mark, which belonged to a
 * different product. Intelus's own mark appears only as "Powered by". */

.signin .mark {
  display: block; width: 56px; height: 56px;
  margin: 0 0 18px; border-radius: 50%;
}
/* A company's own logo on its subdomain's sign-in page: any shape, so no circle. */
.signin .mark.logo {
  width: auto; max-width: 180px; height: 56px; object-fit: contain; border-radius: 0;
}
.brand img {
  width: 26px; height: 26px; border-radius: 50%;
  vertical-align: -6px; margin-right: 9px;
}

/* ---- impersonation strip ------------------------------------------------
 * The owner looking through a customer's window. It is deliberately the
 * loudest thing on the page: a support session that does not announce itself
 * is how a note ends up written into the wrong company's file. */
#impersonation-bar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  flex-wrap: wrap; padding: 9px 16px;
  background: var(--warn-soft); color: var(--warn);
  border-bottom: 1px solid var(--warn);
  font-size: 13px;
}
#impersonation-bar b { font-weight: 600; }
#impersonation-bar button {
  border: 1px solid var(--warn); background: transparent; color: var(--warn);
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 3px 12px; border-radius: 999px; cursor: pointer; min-height: 28px;
}
#impersonation-bar button:hover { background: var(--warn); color: var(--paper); }

/* ---- Intelus's own accounts, inside the one dialog ----------------------
 * This used to be a permanently-parked strip above the table with a chip
 * vocabulary of its own. It is the least-used control in the console, and a
 * band that is always on screen for a job done twice a year is the definition
 * of an inclusion failure. It is now a list in the same dialog every other
 * object here opens, so there is one place to act on an account. */
.stafflist { margin: 14px 0 4px; border-top: 1px solid var(--line); }
.staffrow {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.staffrow b { font-weight: 500; }
.staffrow .grow { flex: 1 1 auto; min-width: 0; }

/* The console's company address: an input that reads as part of the hostname. */
.addr { display: flex; align-items: center; gap: 8px; }
.addr .fin { flex: 1 1 auto; min-width: 0; }
.addr > span { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* The sign-in page's legal line: who runs this, and the two policies. Every
   company address lands here, so it is the one page every customer sees. */
.signin-legal { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px;
  margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); }
.signin-legal .powered-by { display: inline-flex; align-items: center; gap: 7px; }
.signin-legal img { width: 18px; height: 18px; border-radius: 4px; }
