/* Lot Radar shell. Tokens are named by meaning; the dark theme is its own set
   of values, not an inversion. Neutrals lean slightly warm; one accent for
   actions and the current place (#C8401A of the agreed Stitch screens, a
   lighter shade on dark surfaces for 4.5:1); status colours are a separate set.
   Type: IBM Plex Sans for the working text and figures, Onest for headings. */

:root {
  color-scheme: light;
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Onest", "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --color-bg: #f6f5f2;
  --color-surface: #ffffff;
  --color-surface-raised: #ffffff;
  --color-sidebar: #1c1b19;
  --color-border: rgba(40, 34, 24, 0.10);
  --color-text: #1d1b17;
  --color-text-secondary: rgba(29, 27, 23, 0.72);
  --color-text-muted: rgba(29, 27, 23, 0.56);
  --color-brand: #c8401a;
  --color-action-primary: #c8401a;
  --color-action-primary-hover: #a8360f;
  --color-action-on-primary: #ffffff;
  --color-selected: rgba(200, 64, 26, 0.10);
  --color-focus: #c8401a;

  --color-feedback-success: #2e7d32;
  --color-feedback-warning: #a15c00;
  --color-feedback-danger: #b3261e;
  --color-feedback-info: #1f5fa8;

  --radius: 8px;
  --radius-small: 6px;
  --sidebar-width: 216px;
  --sidebar-collapsed-width: 56px;
  --topbar-height: 52px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #171614;
  --color-surface: #1f1e1b;
  --color-surface-raised: #272522;
  --color-sidebar: #131210;
  --color-border: rgba(255, 248, 235, 0.09);
  --color-text: #ece9e3;
  --color-text-secondary: rgba(236, 233, 227, 0.74);
  --color-text-muted: rgba(236, 233, 227, 0.56);
  --color-action-primary: #e8714a;
  --color-action-primary-hover: #f29470;
  --color-action-on-primary: #1a0d08;
  --color-selected: rgba(232, 113, 74, 0.16);
  --color-focus: #f29470;
  --color-feedback-success: #7cc283;
  --color-feedback-warning: #e3a64f;
  --color-feedback-danger: #f08a80;
  --color-feedback-info: #86b4ec;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-bg: #171614;
    --color-surface: #1f1e1b;
    --color-surface-raised: #272522;
    --color-sidebar: #131210;
    --color-border: rgba(255, 248, 235, 0.09);
    --color-text: #ece9e3;
    --color-text-secondary: rgba(236, 233, 227, 0.74);
    --color-text-muted: rgba(236, 233, 227, 0.56);
    --color-action-primary: #e8714a;
    --color-action-primary-hover: #f29470;
    --color-action-on-primary: #1a0d08;
    --color-selected: rgba(232, 113, 74, 0.16);
    --color-focus: #f29470;
    --color-feedback-success: #7cc283;
    --color-feedback-warning: #e3a64f;
    --color-feedback-danger: #f08a80;
    --color-feedback-info: #86b4ec;
  }
}

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

html, body { margin: 0; height: 100%; }

body {
  font: 400 14px/1.5 var(--font-ui);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-action-primary); }
code { font-family: var(--font-mono); font-size: 13px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 18px; line-height: 1.3; }
h3 { font-size: 15px; line-height: 1.35; margin-top: 20px; }
.muted { color: var(--color-text-muted); }

:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ───── shell ───── */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100%;
  transition: grid-template-columns 0.15s ease;
}
.sidebar-collapsed .app { grid-template-columns: var(--sidebar-collapsed-width) 1fr; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  background: var(--color-sidebar);
  overflow: hidden;
  /* the sidebar is dark in both themes (agreed Stitch screens): its own text tokens */
  color-scheme: dark;
  --color-text: #ece9e3;
  --color-text-secondary: rgba(236, 233, 227, 0.74);
  --color-text-muted: rgba(236, 233, 227, 0.56);
  --color-border: rgba(255, 248, 235, 0.10);
  --color-selected: rgba(255, 248, 235, 0.08);
  --color-action-primary: #e8714a;
  --color-focus: #f29470;
  color: var(--color-text);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; white-space: nowrap; }
.brand-mark {
  display: inline-grid; place-items: center; flex: none;
  width: 24px; height: 24px; border-radius: var(--radius-small);
  background: var(--color-brand); color: #ffffff;
  font-size: 11px; font-weight: 500; letter-spacing: 0.02em;
}
.brand-name { font-family: var(--font-display); font-weight: 500; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 9px;
  border: 0; border-radius: var(--radius-small);
  background: none; color: var(--color-text-secondary);
  font: inherit; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.nav-link:hover { background: var(--color-selected); color: var(--color-text); }
.nav-link[aria-current="page"] { background: var(--color-selected); color: var(--color-text); box-shadow: inset 2px 0 0 var(--color-action-primary); }
.nav-link[aria-current="page"] .icon { color: var(--color-action-primary); }

.sidebar-toggle .icon { transition: transform 0.15s ease; }
.sidebar-collapsed .sidebar-toggle .icon { transform: rotate(180deg); }
.sidebar-collapsed .nav-label, .sidebar-collapsed .brand-name { display: none; }
.sidebar-collapsed .brand { padding-left: 8px; }

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

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-height); padding: 0 20px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.page-title { font-size: 16px; }
.scope { color: var(--color-text-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.user { color: var(--color-text-secondary); font-size: 13px; }

.icon-button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 8px;
  border: 0; border-radius: var(--radius-small);
  background: none; color: var(--color-text-secondary);
  font: inherit; font-size: 13px; cursor: pointer;
}
.icon-button:hover { background: var(--color-selected); color: var(--color-text); }

.content { padding: 20px; flex: 1; }

/* ───── states ───── */

.empty-state {
  max-width: 760px;
  padding: 24px;
  background: var(--color-surface);
  border-radius: var(--radius);
}
.empty-state p { color: var(--color-text-secondary); max-width: 62ch; }

.commands { margin: 8px 0 0; padding-left: 22px; display: grid; gap: 8px; }
.commands li { padding-left: 4px; }
.commands code {
  display: inline-block; padding: 2px 6px;
  background: var(--color-bg); border-radius: 4px;
  user-select: all;
}
.command-note { display: block; color: var(--color-text-muted); font-size: 13px; }

.placeholder { padding: 24px; border: 1px dashed var(--color-border); border-radius: var(--radius); }

/* ───── forms ───── */

.field { display: grid; gap: 4px; }
.field-label { font-size: 13px; color: var(--color-text-secondary); }
input, select, textarea {
  font: inherit; color: var(--color-text);
  height: 34px; padding: 0 10px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border); border-radius: var(--radius-small);
}
textarea { height: auto; padding: 8px 10px; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--color-border); border-radius: var(--radius-small);
  background: var(--color-surface-raised); color: var(--color-text);
  font: inherit; font-weight: 500; cursor: pointer;
}
.button:hover { border-color: var(--color-action-primary); }
.button-primary { background: var(--color-action-primary); border-color: transparent; color: var(--color-action-on-primary); }
.button-primary:hover { background: var(--color-action-primary-hover); }
.button:disabled { opacity: 0.55; cursor: default; }

.form-error { margin: 0; color: var(--color-feedback-danger); font-size: 13px; }
.form-error::before { content: "⚠ "; }
.form-ok { margin: 0; color: var(--color-feedback-success); font-size: 13px; }
.form-ok::before { content: "✓ "; }
.hint { margin: 0; color: var(--color-text-muted); font-size: 13px; }

/* ───── login ───── */

.bare .login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(360px, 100%);
  display: grid; gap: 14px;
  padding: 28px 24px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.login-card .brand { padding: 0 0 6px; }

/* ───── settings ───── */

.settings { display: grid; gap: 20px; max-width: 980px; }
.panel { padding: 20px; background: var(--color-surface); border-radius: var(--radius); }
.panel h2 { margin-bottom: 14px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; }
.checks input { height: auto; }

.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-weight: 500; font-size: 13px; color: var(--color-text-muted); padding: 6px 8px; }
.table td { padding: 7px 8px; border-top: 1px solid var(--color-border); vertical-align: middle; }
.table tbody tr:hover { background: var(--color-selected); }
.table select { height: 30px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 1px 8px; border-radius: 999px; }
.badge-danger { color: var(--color-feedback-danger); background: color-mix(in srgb, var(--color-feedback-danger) 12%, transparent); }
.badge-danger::before { content: "⛔"; font-size: 10px; }

/* ───── narrow screens: icons-only sidebar ───── */

@media (max-width: 720px) {
  .app { grid-template-columns: var(--sidebar-collapsed-width) 1fr; }
  .nav-label, .brand-name, .scope, .theme-label { display: none; }
  .content { padding: 12px; }
  .topbar { padding: 0 12px; }
}
