/* AutoSpec dashboard. One stylesheet, no build step. */

:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #16181d;
  --text-muted: #6b727e;
  --text-faint: #9aa1ad;

  --accent: #2f5bd8;
  --accent-hover: #2749ad;
  --accent-soft: #eaf0fe;

  --success: #17794a;
  --success-soft: #e6f4ec;
  --warning: #91600b;
  --warning-soft: #fdf1dc;
  --danger: #b3261e;
  --danger-soft: #fdecea;

  --sidebar-bg: #14171d;
  --sidebar-text: #b9c0cc;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: #21262f;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(16, 20, 28, .06), 0 4px 12px rgba(16, 20, 28, .05);
  --sidebar-w: 232px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1116;
    --surface: #171a21;
    --surface-2: #1c2029;
    --border: #272c36;
    --border-strong: #363d4a;
    --text: #e7e9ee;
    --text-muted: #9aa3b2;
    --text-faint: #6d7686;
    --accent: #6b93ff;
    --accent-hover: #85a7ff;
    --accent-soft: #1b2440;
    --success: #5fd39a;
    --success-soft: #14291f;
    --warning: #e0b25f;
    --warning-soft: #2a2213;
    --danger: #f2867d;
    --danger-soft: #2d1917;
    --sidebar-bg: #0b0d11;
    --sidebar-hover: #1a1e26;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.011em; }
h1 { font-size: 21px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }

/* ---------- layout ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  padding: 18px 18px 16px;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -.01em;
}
.sidebar__brand:hover { text-decoration: none; }
.sidebar__brand-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  margin-bottom: 8px;
}

.sidebar__section {
  padding: 14px 18px 5px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #5d6675;
  font-weight: 600;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 18px;
  color: var(--sidebar-text);
  font-size: 13.5px;
}
.sidebar nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar nav a.is-active {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  box-shadow: inset 2px 0 0 var(--accent);
}
.sidebar nav a .count {
  font-size: 11px; color: #6d7686; font-variant-numeric: tabular-nums;
}

.sidebar__foot {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid #22262f;
  font-size: 12px;
}
.sidebar__user { color: #dfe3ea; word-break: break-all; }
.sidebar__roles { color: #6d7686; margin-top: 2px; }
.sidebar__foot a { color: #8f98a7; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar form { flex: 1; max-width: 460px; }
.topbar input[type=search] {
  width: 100%;
  padding: 7px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
}
.topbar input[type=search]:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.content { padding: 22px 24px 60px; max-width: 1240px; width: 100%; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.page-head__meta { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.page-actions form, td.actions form { display: inline-flex; margin: 0; }
/* A table cell stays a table cell, so the row keeps its vertical centring; the
   buttons live in a flex row inside it. Aligning an inline-flex button to a
   text baseline instead leaves it a couple of pixels high. */
.actions__row { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }

/* ---------- breadcrumbs ---------- */

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
          font-size: 12.5px; color: var(--text-muted); margin-bottom: 10px; }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { color: var(--text-faint); }
.crumbs .current { color: var(--text); font-weight: 500; }

/* ---------- cards, tables ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 16px; }
.grid-2 > .card + .card { margin-top: 0; }
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.card__body { padding: 16px; }
.card__foot { padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); font-weight: 600; padding: 9px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  white-space: nowrap;
}
tbody td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.row-title { font-weight: 500; }
.row-sub { color: var(--text-muted); font-size: 12.5px; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  /* An <a> inherits line-height 1.5, a <button> defaults to `normal`. Pin both,
     and pin the height, so a link and a button in the same row match. */
  height: 32px; padding: 0 12px; line-height: 1;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit;
  white-space: nowrap; vertical-align: middle; text-align: center;
  appearance: none; -webkit-appearance: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; border-color: var(--text-faint); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.92); color: #fff; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--sm { height: 26px; padding: 0 9px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.link-danger { color: var(--danger); }

/* ---------- logos ---------- */

.logo-col { width: 44px; }
.logo-thumb {
  width: 28px; height: 28px; object-fit: contain; display: block;
  border-radius: 5px; background: var(--surface-2); padding: 2px;
}
.logo-thumb--empty {
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  color: var(--text-faint); border: 1px solid var(--border); padding: 0;
}
.logo-large {
  width: 48px; height: 48px; object-fit: contain;
  border-radius: 8px; background: var(--surface-2); padding: 4px;
  border: 1px solid var(--border);
}
.page-head__with-logo { display: flex; align-items: flex-start; gap: 14px; }

.logo-field { display: flex; align-items: flex-start; gap: 18px; }
.logo-field__controls { flex: 1; min-width: 0; }
.logo-preview {
  width: 84px; height: 84px; flex: 0 0 84px;
  display: grid; place-items: center; padding: 6px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2);
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview__empty { font-size: 11.5px; color: var(--text-faint); }
.logo-remove { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; }
.logo-remove input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }

.field input[type=file] {
  width: 100%; font-size: 13px; font-family: inherit; color: var(--text);
  padding: 7px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface);
}
.field input[type=file]::file-selector-button {
  font: inherit; font-size: 12.5px; font-weight: 500; margin-right: 10px;
  padding: 4px 10px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
}

/* ---------- badges ---------- */

.badge {
  display: inline-block; padding: 2px 7px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500; line-height: 1.45;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.badge--ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge--warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge--danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge--accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

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

/* ---------- stats ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat:hover { border-color: var(--border-strong); text-decoration: none; }
.stat__label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 600; }
.stat__value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; color: var(--text); font-variant-numeric: tabular-nums; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

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

.fieldset { border: 0; margin: 0; padding: 0; }
.fieldset + .fieldset { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 18px; }
.fieldset__legend {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); font-weight: 600; margin-bottom: 12px;
}
/* One field per row. Side by side columns make a form hard to follow. */
.field-grid { display: grid; grid-template-columns: 1fr; gap: 16px; max-width: 620px; }
.field--wide { grid-column: auto; }

.field label { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 4px; }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=number], .field input[type=date], .field select, .field textarea {
  width: 100%; padding: 7px 10px; font-size: 13.5px; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.field textarea { min-height: 84px; resize: vertical; }
.field textarea.mono { font-family: var(--mono); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.field .error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.field--invalid input, .field--invalid select, .field--invalid textarea { border-color: var(--danger); }
.field--check { display: flex; align-items: center; gap: 8px; }
.field--check label { margin: 0; }
.field--check input { width: 15px; height: 15px; }

.form-actions {
  display: flex; gap: 8px; align-items: center;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}
.form-actions .spacer { flex: 1; }

/* ---------- flashes ---------- */

.flashes { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 10px 14px; border-radius: var(--radius); font-size: 13.5px;
  border: 1px solid transparent;
}
.flash--success { background: var(--success-soft); color: var(--success); }
.flash--warning { background: var(--warning-soft); color: var(--warning); }
.flash--danger, .flash--error { background: var(--danger-soft); color: var(--danger); }
.flash--info { background: var(--accent-soft); color: var(--accent); }

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

.empty { padding: 44px 20px; text-align: center; color: var(--text-muted); }
.empty h2 { color: var(--text); margin-bottom: 6px; }
.empty p { margin: 0 0 16px; }

/* ---------- pagination ---------- */

.pager { display: flex; align-items: center; gap: 4px; }
.pager a, .pager span {
  padding: 4px 9px; border-radius: var(--radius-sm); font-size: 13px;
  color: var(--text-muted); border: 1px solid transparent;
}
.pager a:hover { background: var(--surface); border-color: var(--border); text-decoration: none; }
.pager .is-current { background: var(--accent); color: #fff; font-weight: 500; }

/* ---------- spec sheet ---------- */

.specs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 24px; }
.spec { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.spec__label { color: var(--text-muted); font-size: 13px; }
.spec__value { font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }
.spec--empty .spec__value { color: var(--text-faint); font-weight: 400; }

pre.json {
  margin: 0; padding: 12px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--mono); font-size: 12.5px;
  overflow-x: auto; color: var(--text);
}

.key-reveal {
  font-family: var(--mono); font-size: 13.5px; word-break: break-all;
  padding: 12px 14px; background: var(--surface-2);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
}

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters input[type=search], .filters select {
  padding: 6px 10px; font-size: 13px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}

/* ---------- auth pages ---------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background:
    radial-gradient(900px 500px at 50% -5%, var(--accent-soft), transparent 70%),
    var(--bg);
}

.auth__card {
  width: 100%;
  max-width: 396px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 34px 32px 28px;
  box-shadow: 0 1px 2px rgba(16, 20, 28, .05), 0 18px 44px -12px rgba(16, 20, 28, .14);
}

.auth__head { margin-bottom: 26px; }
.auth__brand {
  font-size: 12px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 14px;
}
.auth__title { font-size: 21px; font-weight: 600; letter-spacing: -.02em; margin: 0; }
.auth__sub { color: var(--text-muted); margin: 5px 0 0; font-size: 13.5px; }

.auth__alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.auth__alert {
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px;
  background: var(--danger-soft); color: var(--danger);
}

.auth__field { margin-bottom: 16px; }
.auth__field label {
  display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 6px; color: var(--text);
}
.auth input[type=text], .auth input[type=email], .auth input[type=password] {
  width: 100%; height: 40px; padding: 0 12px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.auth input::placeholder { color: var(--text-faint); }
.auth input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth__field--invalid input { border-color: var(--danger); }
.auth__error { font-size: 12px; color: var(--danger); margin-top: 5px; }

.auth__remember {
  display: flex; align-items: center; gap: 9px;
  margin: 20px 0 24px; font-size: 13px; color: var(--text-muted); cursor: pointer;
  user-select: none;
}
.auth__remember span { line-height: 1.3; }
.auth__remember input[type=checkbox] {
  width: 15px; height: 15px; margin: 0; flex: 0 0 15px; accent-color: var(--accent);
}

.auth__submit {
  width: 100%; height: 40px; padding: 0 14px;
  font-size: 14px; font-weight: 600; font-family: inherit; line-height: 1;
  background: var(--accent); color: #fff; border: 0; border-radius: var(--radius-sm);
  cursor: pointer; appearance: none; -webkit-appearance: none;
}
.auth__submit:hover { background: var(--accent-hover); }
.auth__submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.auth__links {
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 13px;
}
.auth__foot {
  margin: 26px 0 0; padding-top: 18px; border-top: 1px solid var(--border);
  text-align: center; font-size: 12.5px; color: var(--text-faint);
}
.auth__links + .auth__foot { margin-top: 12px; padding-top: 0; border-top: 0; }

/* Flask-Security-Too's own pages (change password, and anything else its
   default templates render) use `fs-div` wrappers and bare inputs. Give them
   the same rhythm rather than leaving them unstyled. */
.auth .fs-div { margin-bottom: 16px; }
.auth h1, .auth h2 { font-size: 21px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 20px; }
.auth h3 { font-size: 13px; color: var(--text-muted); margin: 14px 0; }
.auth .fs-div label { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 6px; }
.auth input[type=submit] {
  width: 100%; height: 40px; margin-top: 6px; padding: 0 14px;
  font-size: 14px; font-weight: 600; font-family: inherit; line-height: 1;
  background: var(--accent); color: #fff; border: 0; border-radius: var(--radius-sm);
  cursor: pointer; appearance: none; -webkit-appearance: none;
}
.auth input[type=submit]:hover { background: var(--accent-hover); }
.auth .fs-error-msg { color: var(--danger); font-size: 12.5px; }
.auth ul { margin: 0; padding: 0; list-style: none; }
.auth hr { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }
.auth .fs-gap { margin-top: 16px; }

@media (max-width: 760px) {
  .sidebar { display: none; }
  .content { padding: 16px; }
}

/* Checkbox lists: fuels, features, bodies. Wraps, one line per few ticks. */
.field ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.field ul li { display: flex; align-items: center; gap: 6px; }
.field ul li label { display: inline; margin: 0; font-weight: 400; font-size: 13.5px; }
.field ul li input { width: 15px; height: 15px; margin: 0; }

/* Section index at the top of the long version form. */
.group-index { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 14px; font-size: 13px; }
.group-index a { color: var(--text-muted); text-decoration: none; }
.group-index a:hover { color: var(--accent); }
.fieldset[id] { scroll-margin-top: 16px; }

/* Repeating rows: motors, figures per test cycle. */
.fieldset > .hint { font-size: 12px; color: var(--text-muted); margin: -6px 0 10px; max-width: 620px; }
.rows-table { width: auto; min-width: 0; }
.rows-table th { padding: 0 10px 6px 0; }
.rows-table td { padding: 0 10px 8px 0; border: 0; vertical-align: top; }
.rows-table select, .rows-table input {
  padding: 6px 8px; font-size: 13px; font-family: inherit; width: 100%; min-width: 96px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.rows-table input { max-width: 110px; }
.rows-table .field--invalid select, .rows-table .field--invalid input { border-color: var(--danger); }
.rows-table .error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* Version detail: one block per group. */
.spec-group + .spec-group { margin-top: 18px; }
.spec-group__title {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); font-weight: 600; margin: 0 0 4px;
}
