/* claudebox design system.
   Idea: a machine's front panel. Ink-navy header/footer like a rack faceplate, sodium-amber as the
   single "lit" accent, status pills with LED dots. Type: Unbounded (display), Golos Text (text).
   Scale: 1.25 (major third) from 17px. Colors are tokens; dark theme via prefers-color-scheme. */

:root {
  --paper: #f2f4f7;
  --surface: #ffffff;
  --sunken: #e8ecf2;
  --ink: #16203a;
  --ink-2: #4a5570;
  --line: #d3d9e3;
  --line-strong: #aeb8c9;
  --panel: #16203a;
  --panel-ink: #e9edf5;
  --panel-ink-2: #a8b3c9;
  --sodium: #f0a81c;
  --sodium-strong: #d48f05;
  --on-sodium: #241800;
  --link: #2a4cc4;
  --focus: #2a4cc4;

  --ok: #1d8a59;
  --wait: #b67a00;
  --work: #2f5bd3;
  --stop: #c0392b;
  --off: #8a93a6;

  --ok-bg: #e3f4ec;
  --wait-bg: #fbf0d6;
  --work-bg: #e5ebfb;
  --stop-bg: #fbe5e2;
  --off-bg: #eceef2;

  --font-text: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Unbounded", "Golos Text", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Consolas", "Liberation Mono", monospace;

  --fs-sm: 0.8125rem;   /* 13 */
  --fs-base: 1.0625rem; /* 17 */
  --fs-md: 1.25rem;     /* 20 */
  --fs-lg: 1.5625rem;   /* 25 */
  --fs-xl: 1.9375rem;   /* 31 */
  --fs-2xl: 2.4375rem;  /* 39 */

  --r-sm: 6px;
  --r-md: 10px;
  --gutter: 16px;
  --space: 24px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1528;
    --surface: #151e36;
    --sunken: #101830;
    --ink: #e6ebf5;
    --ink-2: #9aa6bf;
    --line: #27324f;
    --line-strong: #3a4769;
    --panel: #090f1f;
    --panel-ink: #e6ebf5;
    --panel-ink-2: #8e9ab4;
    --sodium: #f5b83d;
    --sodium-strong: #ffc85c;
    --on-sodium: #1f1500;
    --link: #8fa8ff;
    --focus: #8fa8ff;

    --ok: #42c48a;
    --wait: #f0b43c;
    --work: #7d9bff;
    --stop: #ff7a6b;
    --off: #7c879e;

    --ok-bg: #12301f;
    --wait-bg: #33270b;
    --work-bg: #172449;
    --stop-bg: #3a1714;
    --off-bg: #1c243a;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--fs-base);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: auto;
}
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }

@media (min-width: 720px) {
  h1 { font-size: var(--fs-2xl); }
  h2 { font-size: var(--fs-xl); }
}

p { margin: 0 0 1em; }
p, li { max-width: 72ch; }

a { color: var(--link); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

code,
kbd,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

code {
  background: var(--sunken);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

pre {
  margin: 0 0 1em;
  padding: 12px 14px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.5;
  white-space: pre;
}
pre code { background: none; padding: 0; }

hr { border: 0; border-top: 1px solid var(--line); margin: var(--space) 0; }

img, svg { max-width: 100%; }

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 10;
  background: var(--sodium);
  color: var(--on-sodium);
  padding: 8px 12px;
  border-radius: var(--r-sm);
}
.skip:focus { left: 8px; }

.wrap {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.wrap--wide { max-width: 1320px; }

@media (min-width: 720px) {
  :root { --gutter: 24px; }
}

.main {
  flex: 1;
  padding-block: 32px 64px;
}

/* ---------- header: the faceplate ---------- */

.top {
  background: var(--panel);
  color: var(--panel-ink);
  border-bottom: 3px solid var(--sodium);
}

.top__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  flex-wrap: wrap;
  padding-block: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--panel-ink);
  text-decoration: none;
}
.brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.mark { flex: none; display: block; }
.mark__body { fill: #1f2b4d; stroke: #3a4a78; stroke-width: 1; }
.mark__screen { fill: #0b1226; stroke: var(--sodium); stroke-width: 2; }
.mark__cursor { fill: var(--sodium); }
.mark__stand { fill: #5d6c94; }

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.nav__link {
  color: var(--panel-ink-2);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 0.9375rem;
  font-weight: 500;
}
.nav__link:hover { color: var(--panel-ink); background: rgba(255, 255, 255, 0.06); }
.nav__link[aria-current="page"] {
  color: var(--panel-ink);
  box-shadow: inset 0 -2px 0 var(--sodium);
  border-radius: 0;
}
.nav__logout { margin: 0; display: inline; }
.nav__link--button {
  background: none;
  border: 0;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
}

/* ---------- footer ---------- */

.foot {
  background: var(--panel);
  color: var(--panel-ink-2);
  font-size: var(--fs-sm);
  padding-block: 24px;
}
.foot__row { display: grid; gap: 6px; }
.foot__row p { margin: 0; }
.foot__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--panel-ink);
}

/* ---------- headings & text helpers ---------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: var(--space);
}
.page-head h1 { margin-bottom: 0.2em; }
/* Page and card titles can be an account name like "a_very_long_name_20": no break points, so allow any.
   min-width: 0 lets the flex item shrink to the phone width instead of pushing the page sideways. */
.page-head > div { min-width: 0; }
.page-head h1,
.card__title { overflow-wrap: anywhere; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.lead { font-size: var(--fs-md); color: var(--ink-2); margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

.prose { max-width: 70ch; }
.prose h2 { margin-top: 1.6em; }

.stack > * + * { margin-top: var(--space); }
.stack--tight > * + * { margin-top: 12px; }
.cluster { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}

.section { margin-top: 48px; }
.section:first-child { margin-top: 0; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: var(--sodium);
  color: var(--on-sodium);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: var(--sodium-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn--secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn--secondary:hover { background: var(--sunken); }

.btn--quiet {
  background: transparent;
  color: var(--link);
  border-color: transparent;
  padding-inline: 8px;
}
.btn--quiet:hover { background: var(--sunken); }

.btn--danger {
  background: var(--surface);
  color: var(--stop);
  border-color: var(--stop);
}
.btn--danger:hover { background: var(--stop-bg); }

.btn--small { min-height: 36px; padding: 6px 12px; font-size: 0.9375rem; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

/* Forms that hold a single button sit inline in tables and clusters. */
.inline-form { display: inline; margin: 0; }

/* ---------- forms ---------- */

.form { display: grid; gap: 18px; max-width: 520px; }

.field { display: grid; gap: 6px; }
.field__label { font-weight: 600; font-size: 0.9375rem; }
.field__hint { margin: 0; font-size: var(--fs-sm); color: var(--ink-2); }
.field__error { margin: 0; font-size: var(--fs-sm); color: var(--stop); font-weight: 500; }

.input,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
}
textarea { min-height: 96px; resize: vertical; font-family: var(--font-mono); font-size: 0.9375rem; }
input::placeholder, textarea::placeholder { color: var(--ink-2); opacity: 0.7; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--focus); }
.field--error input, .field--error select, .field--error textarea { border-color: var(--stop); }

/* Radio/checkbox choices as selectable tiles (e.g. order term). */
.choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); border: 0; padding: 0; margin: 0; }
.choices legend { font-weight: 600; font-size: 0.9375rem; margin-bottom: 6px; padding: 0; }
.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--sodium-strong); box-shadow: inset 0 0 0 1px var(--sodium-strong); }
.choice input { margin-top: 4px; accent-color: var(--sodium-strong); }

.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { margin-top: 5px; accent-color: var(--sodium-strong); }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px;
}
.card > :last-child { margin-bottom: 0; }
.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
}
.card__title { font-family: var(--font-display); font-weight: 500; font-size: var(--fs-md); margin: 0; }
.card__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.card--accent { border-top: 3px solid var(--sodium); }

/* Key–value list for access data and details. */
.kv {
  display: grid;
  grid-template-columns: minmax(100px, max-content) 1fr;
  gap: 8px 16px;
  margin: 0;
}
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; min-width: 0; }

.secret {
  font-family: var(--font-mono);
  background: var(--sunken);
  border: 1px dashed var(--line-strong);
  border-radius: 4px;
  padding: 2px 8px;
  user-select: all;
  word-break: break-all;
}

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.table th,
.table td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.table th {
  font-weight: 600;
  color: var(--ink-2);
  background: var(--sunken);
  white-space: nowrap;
}
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; }
.table .actions { white-space: nowrap; text-align: right; }

/* ---------- status badges: LED + label ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 2px 10px 2px 8px;
  border-radius: 999px;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  background: var(--off-bg);
  color: var(--ink);
}
.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--off);
  flex: none;
}
.badge--ok { background: var(--ok-bg); }
.badge--ok::before { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.badge--wait { background: var(--wait-bg); }
.badge--wait::before { background: var(--wait); }
.badge--work { background: var(--work-bg); }
.badge--work::before { background: var(--work); }
.badge--stop { background: var(--stop-bg); }
.badge--stop::before { background: var(--stop); }
.badge--off { color: var(--ink-2); }

/* ---------- flash messages ---------- */

.flash {
  margin-bottom: var(--space);
  padding: 12px 16px;
  border-radius: var(--r-sm);
  border-left: 4px solid var(--work);
  background: var(--work-bg);
}
.flash--ok { border-left-color: var(--ok); background: var(--ok-bg); }
.flash--error { border-left-color: var(--stop); background: var(--stop-bg); }

/* ---------- empty state ---------- */

.empty {
  padding: 32px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  text-align: left;
}
.empty__title { font-weight: 600; margin-bottom: 6px; }
.empty__body > :last-child { margin-bottom: 0; }

/* ---------- error pages ---------- */

.oops { padding-block: 24px; max-width: 46ch; }
.oops__code {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(4rem, 18vw, 8rem);
  line-height: 1;
  color: var(--sodium-strong);
  margin: 0 0 12px;
  letter-spacing: -0.04em;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
