/* Account Sync — the Agrolt Books look: same tokens, light and dark by the OS setting. */
:root {
  color-scheme: light;
  --bg: #f4f6f9; --panel: #ffffff; --panel-2: #f8fafc; --text: #1b2430; --muted: #6b7686;
  --border: #e3e8ef; --accent: #2456a6; --accent-soft: #e8effa; --on-accent: #ffffff;
  --dr: #b4372f; --cr: #1f7a4d; --warn: #a15c00; --warn-soft: #fdf0dc; --ok-soft: #e3f3ea; --err-soft: #fbe9e7;
  --row-hover: #f2f6fc; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --side: #182a4d; --side-text: #c8d2e3; --side-strong: #ffffff; --side-hover: rgba(255,255,255,.06);
  --side-sel: rgba(255,255,255,.1); --side-line: rgba(255,255,255,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f141b; --panel: #161d27; --panel-2: #1b2430; --text: #e3e8ef; --muted: #8d99aa;
    --border: #273241; --accent: #6b9cf0; --accent-soft: #1d2b44; --on-accent: #0f141b;
    --dr: #f08a80; --cr: #5cc993; --warn: #e0a440; --warn-soft: #3a2a12; --ok-soft: #12301f; --err-soft: #3a1714;
    --row-hover: #1d2733; --shadow: none; --side: #101b30; --side-text: #9fb0c8;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 17px; }
p { margin: 0 0 8px; }
code { font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.error { color: var(--dr); font-size: 13px; }
.warn { color: var(--warn); }

/* forms and buttons */
.form { display: grid; gap: 12px; }
.form.wide { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-items: end; }
.form .full { grid-column: 1 / -1; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; display: grid; gap: 6px; }
legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.form h3 { margin: 6px 0 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; min-height: 36px; width: 100%; }
input[type="checkbox"] { width: auto; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); }
.btn { font: inherit; border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 8px;
  padding: 7px 14px; cursor: pointer; min-height: 36px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { filter: brightness(.97); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--dr); }
.btn.small { padding: 3px 10px; min-height: 28px; font-size: 13px; }
.link { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; }

/* sign-in card */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.login-card h1 { font-size: 22px; }
.login-card .link { color: var(--muted); justify-self: start; }
.qr { display: grid; place-items: center; }
.qr svg { width: 184px; height: 184px; border-radius: 6px; }
.key { overflow-wrap: anywhere; user-select: all; }

/* shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex: 0 0 232px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 14px; border-bottom: 1px solid var(--side-line); }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-weight: 700; flex: 0 0 32px; }
.brand-mark.big { width: 44px; height: 44px; font-size: 22px; border-radius: 11px; }
.brand-name { color: var(--side-strong); font-weight: 600; font-size: 13px; line-height: 1.25; }
.brand-sub { font-size: 11px; opacity: .75; margin-top: 2px; }
nav { padding: 8px 0; flex: 1; }
nav a { display: block; color: var(--side-text); padding: 7px 18px; font-size: 13.5px; border-left: 3px solid transparent; }
nav a:hover { background: var(--side-hover); text-decoration: none; color: var(--side-strong); }
nav a.active { color: var(--side-strong); background: var(--side-sel); border-left-color: var(--accent); font-weight: 600; }
.nav-h { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .55; padding: 14px 18px 4px; }
.sidebar-foot { padding: 12px 18px; font-size: 12px; display: flex; justify-content: space-between; align-items: center;
  gap: 8px; border-top: 1px solid var(--side-line); }
.sidebar-foot .who { color: var(--side-strong); font-weight: 600; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 20px;
  background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.page-title { font-size: 18px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.view { padding: 20px; max-width: 1500px; width: 100%; display: grid; gap: 16px; align-content: start; }

/* content */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); }
.panel > h2 { margin-bottom: 10px; }
.panel.empty { text-align: center; padding: 36px 18px; }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.cards > .full-row { grid-column: 1 / -1; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; margin: 12px 0 0; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font-size: 18px; font-weight: 600; }
.stats dd.small { font-size: 13px; font-weight: 500; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.flash { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 14px; }
.callout { background: var(--warn-soft); border-radius: 10px; padding: 10px 14px; }
.secret-once { background: var(--warn-soft); border: 1px dashed var(--warn); border-radius: 10px; padding: 12px 14px; }
.secret-once code { font-size: 15px; user-select: all; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel-2); position: sticky; top: 0; white-space: nowrap; }
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input[type="search"] { max-width: 320px; }

/* status badges */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok, .badge.done, .badge.matched { background: var(--ok-soft); color: var(--cr); border-color: transparent; }
.badge.failed, .badge.error, .badge.rejected { background: var(--err-soft); color: var(--dr); border-color: transparent; }
.badge.running, .badge.queued, .badge.paused, .badge.awaiting_approval, .badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

pre.log { margin: 0; max-height: 420px; overflow: auto; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; white-space: pre-wrap; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  nav { display: flex; overflow-x: auto; padding: 0; }
  nav a { border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
  nav a.active { border-bottom-color: var(--accent); }
  .nav-h { display: none; }
  .view { padding: 16px; }
}

/* filter tabs, pager */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs a { padding: 7px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .count { font-size: 11.5px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; margin-left: 2px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; }

/* ledger mapping */
.bulk { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 14px; }
.bulk select, .editor select { width: auto; }
.picker { position: relative; flex: 1 1 260px; min-width: 220px; }
.picker-results { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px 0; list-style: none;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.15);
  max-height: 320px; overflow-y: auto; }
.picker-results li { padding: 6px 12px; cursor: pointer; }
.picker-results li:hover, .picker-results li:focus { background: var(--row-hover); outline: none; }
.editor-row td { background: var(--accent-soft); }
.editor .note { flex: 0 1 200px; width: auto; }
.badge.auto { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* dashboard */
.card-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { display: block; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: var(--text); background: var(--panel-2); }
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile-label { display: block; font-size: 12px; color: var(--muted); }
.tile-value { display: block; margin-top: 2px; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile.ok .tile-value { color: var(--cr); }
.tile.warn .tile-value { color: var(--warn); }

/* runs: preview, approval, steps */
.stats.wide { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 12px; }
ul.plain { margin: 0; padding-left: 18px; }
.toolbar input.narrow { max-width: 90px; }
.badge.preview { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
