/* Admin console.
 *
 * Same warm paper as the tester so it reads as one product, but composed for a
 * different job. The tester is a page full of panels, so its grid helpers look
 * fine there; borrowing them for a single sign-in form produced a lonely box in
 * the top-left corner of an empty screen, which is what this replaces.
 *
 * The one rule that shapes everything below: ACCENT IS STRUCTURE, COLOUR IS
 * STATE. Ink blue marks the things you act on and the things that frame the
 * page. Green, amber and red are reserved strictly for what something IS, never
 * for emphasis, so a red cell always means a problem and never means "look
 * here". Mixing those two jobs is what turns a console into a christmas tree
 * that nobody can read at a glance.
 */

:root {
  --bg-deep: #faf8f3;
  --bg-panel: #fdfcf8;
  --bg-inset: #f3efe6;
  --bg-sunk: #eee9dd;
  --border: #e4dcc9;
  --border-warm: #d6cbb2;
  --text-primary: #16110c;
  --text-dim: #6b6151;
  --text-faint: #7d7364;

  /* Structure and action. Deliberately NOT the tester's green: this is the
     control surface, and it should not be mistaken for the measurement one. */
  --ink: #26324d;
  --ink-hover: #1a2438;
  --ink-wash: #eef0f5;

  --green: #15803d;
  --red: #b91c1c;
  --orange: #aa6408;
  --mono: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg-deep);
  color: var(--text-primary);
  font:
    15px/1.55 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- sign in ----------
   Centered on the viewport. A sign-in screen has exactly one thing to do, and
   putting it where the eye already is costs nothing. */

.signin {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.signin-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-panel);
  border: 1px solid var(--border-warm);
  border-radius: 12px;
  padding: 32px 30px 26px;
  box-shadow:
    0 1px 2px rgb(22 17 12 / 4%),
    0 12px 32px -12px rgb(22 17 12 / 10%);
}

.mark {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 24px;
}
.mark b {
  font-size: 15px;
  letter-spacing: -0.01em;
}
.mark .tag {
  font: 600 10px var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--ink-wash);
  padding: 3px 7px;
  border-radius: 4px;
}

.signin-card h1 {
  font-size: 19px;
  letter-spacing: -0.01em;
  margin: 0 0 22px;
}

/* ---------- fields ---------- */

.field {
  display: block;
  margin-bottom: 16px;
}
.field > span {
  display: block;
  font:
    600 11px system-ui,
    sans-serif;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

input[type="email"],
input[type="text"],
input[type="number"] {
  width: 100%;
  font:
    14px system-ui,
    sans-serif;
  padding: 10px 12px;
  border: 1px solid var(--border-warm);
  border-radius: 7px;
  background: var(--bg-deep);
  color: var(--text-primary);
}
input:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--ink-wash);
}
input::placeholder {
  color: var(--text-faint);
}

textarea {
  width: 100%;
  font: 13px/1.55 var(--mono);
  padding: 10px 12px;
  border: 1px solid var(--border-warm);
  border-radius: 7px;
  background: var(--bg-panel);
  color: var(--text-primary);
  resize: vertical;
}
textarea:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--ink-wash);
}
textarea::placeholder {
  color: var(--text-faint);
}
input[type="file"] {
  width: 100%;
  font: 13px system-ui, sans-serif;
  color: var(--text-dim);
}

/* A wide field inside a formrow takes the whole row, so the bulk textarea
   sits on its own line above the file, label and button. */
.formrow .field.wide {
  flex: 1 1 100%;
}

/* ---------- buttons ---------- */

button {
  font:
    600 13px system-ui,
    sans-serif;
  padding: 10px 16px;
  border-radius: 7px;
  border: 1px solid var(--border-warm);
  background: var(--bg-inset);
  color: var(--text-primary);
  cursor: pointer;
}
button:hover:not(:disabled) {
  background: var(--bg-sunk);
}
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ink-wash);
}
button.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  width: 100%;
  padding: 11px 16px;
}
button.primary:hover:not(:disabled) {
  background: var(--ink-hover);
}
button.tiny {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 5px;
}
button.danger {
  color: var(--red);
  border-color: #e8cdcd;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- status ---------- */

.status {
  font-size: 13px;
  color: var(--text-dim);
  margin: 14px 0 0;
  min-height: 1em;
}
.status:empty {
  margin: 0;
  min-height: 0;
}
.status.ok {
  color: var(--green);
}
.status.err {
  color: var(--red);
}

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

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 0;
  margin-bottom: 22px;
  background: color-mix(in srgb, var(--bg-deep) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .mark {
  margin: 0;
}
.grow {
  flex: 1;
}
.whoami {
  font: 12.5px var(--mono);
  color: var(--text-dim);
}

section {
  margin-bottom: 34px;
}
.eyebrow {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font:
    600 11px system-ui,
    sans-serif;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding-bottom: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.eyebrow .count {
  font-family: var(--mono);
  color: var(--text-faint);
  letter-spacing: 0;
  text-transform: none;
}

/* ---------- spend meter ----------
   The one number worth putting above everything else: how close today is to the
   cap that holds the bill down. */

.meter {
  background: var(--bg-panel);
  border: 1px solid var(--border-warm);
  border-radius: 10px;
  padding: 16px 18px;
}
.meter-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.meter-value {
  font: 600 22px var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.meter-of {
  font-size: 13px;
  color: var(--text-dim);
}
.meter-pct {
  margin-left: auto;
  font: 600 12px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.meter-track {
  height: 7px;
  background: var(--bg-sunk);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 12px;
}
.meter-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--green);
  transition: width 0.4s ease;
}
.meter-fill.warn {
  background: var(--orange);
}
.meter-fill.hot {
  background: var(--red);
}
.meter-note {
  font-size: 12px;
  color: var(--text-faint);
  margin: 9px 0 0;
}

/* ---------- forms in a row ---------- */

.formrow {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  background: var(--bg-panel);
  border: 1px solid var(--border-warm);
  border-radius: 10px;
  padding: 16px 18px;
}
.formrow .field {
  margin: 0;
  flex: 1 1 170px;
}
.formrow button {
  flex: none;
}

/* ---------- tables ---------- */

.tablewrap {
  overflow-x: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-warm);
  border-radius: 10px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  padding: 10px 14px;
  font:
    600 10.5px system-ui,
    sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border-warm);
  white-space: nowrap;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}
tbody tr:last-child td {
  border-bottom: none;
}
tbody tr:hover td {
  background: color-mix(in srgb, var(--bg-inset) 55%, transparent);
}

.mono {
  font-family: var(--mono);
}
.dim {
  color: var(--text-dim);
}
.small {
  font-size: 12.5px;
}
.nowrap {
  white-space: nowrap;
}

/* ---------- state pills ----------
   State is a shape as well as a color, so it survives a greyscale print and a
   color-blind reader. */

.pill {
  display: inline-block;
  font:
    600 11px system-ui,
    sans-serif;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}
.pill.ok {
  color: var(--green);
  border-color: #bfe0c9;
  background: #f0f8f2;
}
.pill.bad {
  color: var(--red);
  border-color: #e8cdcd;
  background: #fdf3f3;
}
.pill.warn {
  color: var(--orange);
  border-color: #ecd8b4;
  background: #fdf7ec;
}
.pill.mute {
  color: var(--text-dim);
  border-color: var(--border-warm);
  background: var(--bg-inset);
}

.code {
  font: 600 13px var(--mono);
  letter-spacing: 0.02em;
  background: var(--ink-wash);
  color: var(--ink);
  padding: 3px 7px;
  border-radius: 5px;
  user-select: all;
}

.empty.err {
  color: var(--red);
}
.empty {
  padding: 22px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* New codes, laid out to be selected and pasted straight into a mail merge. */
.codeblock {
  background: var(--bg-panel);
  border: 1px solid var(--border-warm);
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 12px;
}
.codeblock pre {
  font: 13px/1.7 var(--mono);
  white-space: pre-wrap;
  user-select: all;
  margin: 8px 0 0;
  color: var(--ink);
}

a {
  color: var(--ink);
}

@media (max-width: 560px) {
  .shell {
    padding: 0 14px 48px;
  }
  .formrow {
    flex-direction: column;
    align-items: stretch;
  }
  .formrow button {
    width: 100%;
  }
  .meter-pct {
    margin-left: 0;
  }
}

/* ---------- signing-in state ----------
   A magic link that lands on a login form reads as failure. This is shown
   instead, from the first paint, whenever the URL carries a sign-in code. */

.signin-card + .signin-card {
  margin-top: 0;
}
.spinner {
  width: 22px;
  height: 22px;
  margin: 4px 0 2px;
  border: 2px solid var(--bg-sunk);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

/* The hidden attribute must actually hide.
 *
 * [hidden] is a low-specificity presentation hint, so ANY rule that sets
 * display beats it. Two elements here carry one: .camgrid is display:grid and
 * label is display:flex. The result was that the account panel showed the
 * signed-OUT form and the signed-IN controls at the same time, and the stream
 * URL field was visible when it should not have been. Both looked like broken
 * state logic; the JavaScript was correct and the CSS was quietly ignoring it.
 *
 * !important is right here rather than lazy: this is a browser default being
 * restored, and nothing should ever out-rank "this element is hidden".
 */
[hidden] {
  display: none !important;
}

/* research results */
.restitle {
  font-size: 13px;
  margin: 18px 0 6px;
}
.resbar {
  display: inline-block;
  width: 120px;
  height: 8px;
  margin-right: 8px;
  border-radius: 999px;
  background: rgb(0 0 0 / 8%);
  overflow: hidden;
  vertical-align: middle;
}
.resbar > span {
  display: block;
  height: 100%;
  width: 0;
  background: currentColor;
}
.inlinecheck {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
