/* TimeLore Command — calm paper and ink, one indigo, one sage. */
:root {
  --paper: #f6f5f1;
  --surface: #ffffff;
  --sunk: #efede7;
  --ink: #1d2230;
  --muted: #676b75;
  --line: #e2dfd7;
  --accent: #141414;
  --accent-ink: #ffffff;
  --accent-soft: #f2ead3;
  --link: #7a5610;
  --gold: #8A6213;
  --sage: #5f8264;
  --sage-soft: #e5eee5;
  --warn: #9a6512;
  --warn-soft: #f6ecd9;
  --danger: #a3342c;
  --danger-soft: #f7e3e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 36, .05), 0 6px 24px rgba(20, 24, 36, .05);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111111; --surface: #181818; --sunk: #222222; --ink: #e8e6e1; --muted: #9a978f;
    --line: #2b2b2b; --accent: #E6C66A; --accent-ink: #141414; --accent-soft: #2b2515; --link: #E6C66A; --gold: #D4AF37;
    --sage: #93b898; --sage-soft: #1f2d22; --warn: #e3b25e; --warn-soft: #34291a;
    --danger: #ef8d84; --danger-soft: #3a2220; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111111; --surface: #181818; --sunk: #222222; --ink: #e8e6e1; --muted: #9a978f;
  --line: #2b2b2b; --accent: #E6C66A; --accent-ink: #141414; --accent-soft: #2b2515; --link: #E6C66A; --gold: #D4AF37;
  --sage: #93b898; --sage-soft: #1f2d22; --warn: #e3b25e; --warn-soft: #34291a;
  --danger: #ef8d84; --danger-soft: #3a2220; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ------------------------------------------------------------ layout */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.brand b { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { padding: 8px 10px; border-radius: 8px; color: var(--ink); }
.nav a:hover { background: var(--sunk); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 12px 10px 4px; }
.me { margin-top: auto; padding: 12px 10px; border-top: 1px solid var(--line); }
.me b { display: block; }
.me .links { display: flex; gap: 12px; margin-top: 6px; }
.me button { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
main { padding: 32px 40px 60px; max-width: 1180px; width: 100%; min-width: 0; }
.nowrap, td.mono, td .mono { white-space: nowrap; }
td .actions { flex-wrap: nowrap; }
.dlg .stack .btn { justify-content: center; }
[hidden] { display: none !important; }
.list li > :last-child { white-space: nowrap; }
.head .total { text-align: right; }
.head .total .n { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.head .total .l { color: var(--muted); font-size: 12.5px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.head p { margin: 4px 0 0; color: var(--muted); }

/* ------------------------------------------------------------ pieces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stat .n { font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 7px 13px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--sunk); }
.btn.wrap { white-space: normal; text-align: left; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--sunk); color: var(--muted); }
.pill.ok { background: var(--sage-soft); color: var(--sage); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

.banner { border: 1px solid var(--line); background: var(--warn-soft); color: var(--ink); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; }
.banner b { color: var(--warn); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 0 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--sunk); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

progress { width: 120px; height: 6px; appearance: none; border: 0; border-radius: 99px; background: var(--sunk); overflow: hidden; vertical-align: middle; }
progress::-webkit-progress-bar { background: var(--sunk); }
progress::-webkit-progress-value { background: var(--sage); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--sage); }
progress.high::-webkit-progress-value { background: var(--warn); }
progress.high::-moz-progress-bar { background: var(--warn); }

/* ------------------------------------------------------------ forms */
form .field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
label { font-weight: 500; font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.radio { display: flex; gap: 16px; }
.radio label { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.radio input { width: auto; }
.error { color: var(--danger); min-height: 18px; font-size: 13px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form select { width: auto; min-width: 180px; }

/* ------------------------------------------------------------ sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 380px; padding: 32px 28px; }
.auth .brand { justify-content: center; flex-direction: column; text-align: center; gap: 8px; margin-bottom: 24px; }
.auth .brand img { width: 56px; height: 56px; border-radius: 13px; }
.auth .brand b { font-size: 20px; }
.auth .btn.primary { width: 100%; justify-content: center; padding: 10px; }

/* ------------------------------------------------------------ dialog, toast */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 18, 28, .45); }
.dlg { padding: 24px; }
.dlg h2 { font-size: 17px; margin-bottom: 16px; }
.dlg .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.secret { font-family: var(--mono); font-size: 18px; letter-spacing: .04em; background: var(--sunk); border-radius: 8px; padding: 12px 14px; text-align: center; margin: 8px 0 14px; user-select: all; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ------------------------------------------------------------ phone */
@media (max-width: 860px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; gap: 10px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav .label { display: none; }
  .nav a { white-space: nowrap; }
  .me { margin: 0; padding: 8px 0 0; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; }
  .me .links { margin: 0; }
  main { padding: 20px 16px 48px; }
  .row { flex-direction: column; gap: 0; }
  .hide-sm { display: none; }
}

[data-gap="top"] { margin-top: 16px; }
[data-gap="top-start"] { margin-top: 12px; justify-content: flex-start; }
[data-gap="bottom"] { margin-bottom: 16px; }
.secret.long { word-break: break-all; font-size: 13px; letter-spacing: 0; text-align: left; }
.card .head { margin-bottom: 8px; align-items: center; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters select { width: auto; min-width: 150px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg .btn { border: 0; border-radius: 0; }
.seg .btn.on { background: var(--accent); color: var(--accent-ink); }
tr.day td { background: var(--sunk); font-size: 12.5px; padding-top: 8px; padding-bottom: 8px; }
.small-note { font-size: 12px; }
.list progress { width: 90px; }
