:root {
  color-scheme: light;
  --bg: #f6f4f0;
  --surface: #fcfcfb;
  --surface-2: #f1eee8;
  --border: #e4e0d8;
  --text: #1b1a18;
  --text-2: #52514e;
  --text-3: #7a7873;
  --accent: #b5302a;
  --accent-ink: #ffffff;
  --accent-soft: #f7e3e1;
  --series-1: #2a78d6;
  --grid: #ebe8e2;
  --good: #1f7a3a;   --good-bg: #e3f2e7;
  --warn: #8a5a00;   --warn-bg: #fcefd2;
  --crit: #b3261e;   --crit-bg: #fbe2e0;
  --info: #2a5fa8;   --info-bg: #e2ecf8;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --radius: 12px;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #33322f;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #94938b;
    --accent: #e0574e; --accent-ink: #1a0d0c; --accent-soft: #3a1f1d;
    --series-1: #3987e5; --grid: #2b2a28;
    --good: #6fcf8a; --good-bg: #1d3324; --warn: #f0c060; --warn-bg: #3a2f14;
    --crit: #f08a82; --crit-bg: #3d1e1c; --info: #8ab4ef; --info-bg: #1c2a3d;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #33322f;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #94938b;
  --accent: #e0574e; --accent-ink: #1a0d0c; --accent-soft: #3a1f1d;
  --series-1: #3987e5; --grid: #2b2a28;
  --good: #6fcf8a; --good-bg: #1d3324; --warn: #f0c060; --warn-bg: #3a2f14;
  --crit: #f08a82; --crit-bg: #3d1e1c; --info: #8ab4ef; --info-bg: #1c2a3d;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 16px 0 8px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
pre, code, textarea.code { font-family: var(--mono); font-size: 12.5px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }

/* Layout */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; }
.brand-mark { font-size: 26px; }
.brand-name { font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--text-3); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .ico { width: 18px; text-align: center; opacity: .8; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 14px 10px 4px; }
.badge { margin-left: auto; background: var(--accent); color: var(--accent-ink); border-radius: 10px; font-size: 11px; font-weight: 700; padding: 0 7px; min-width: 20px; text-align: center; }
.badge.warn { background: var(--crit); color: #fff; }
.sidebar-foot { padding-top: 12px; border-top: 1px solid var(--border); }
.topbar { display: none; }
.main { padding: 24px 28px 48px; min-width: 0; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.cols-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.split { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 12px; margin-bottom: 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.empty { color: var(--text-3); padding: 24px; text-align: center; }

/* Stat tile */
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile-label { color: var(--text-2); font-size: 13px; }
.tile-value { font-size: 28px; font-weight: 650; margin-top: 2px; }
.tile-delta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.tile-delta.up { color: var(--good); } .tile-delta.down { color: var(--crit); }
a.tile { text-decoration: none; color: inherit; display: block; }
a.tile:hover { border-color: var(--accent); }

/* Controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { color: var(--crit); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: transparent; color: var(--text-2); padding: 5px 12px; border-radius: 7px; font: inherit; font-weight: 550; cursor: pointer; }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 120px; resize: vertical; }
textarea.tall { min-height: 360px; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 4px; font-weight: 550; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
select.inline { width: auto; padding: 4px 8px; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.crit { background: var(--crit-bg); color: var(--crit); }
.pill.info { background: var(--info-bg); color: var(--info); }

/* Tables & lists */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.list { display: flex; flex-direction: column; }
.list-item { display: block; padding: 11px 14px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; cursor: pointer; }
.list-item:hover { background: var(--surface-2); }
.list-item.sel { background: var(--accent-soft); }
.list-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .s { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.meta { display: flex; gap: 8px; align-items: center; color: var(--text-3); font-size: 12px; margin-top: 4px; flex-wrap: wrap; }

.callout { border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; display: flex; gap: 10px; align-items: flex-start; }
.callout.warn { background: var(--warn-bg); color: var(--warn); }
.callout.crit { background: var(--crit-bg); color: var(--crit); }
.callout.info { background: var(--info-bg); color: var(--info); }
.callout.good { background: var(--good-bg); color: var(--good); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; word-break: break-word; }

/* Schedule */
.day { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.day:last-child { border-bottom: 0; }
.day-label { font-weight: 600; } .day-label .muted { display: block; font-weight: 400; font-size: 12px; }
.slot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 3px 0; }

/* Agents */
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.agent { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface); }
.agent .n { font-weight: 650; } .agent .d { color: var(--text-2); font-size: 12.5px; margin: 4px 0 8px; }
.agent .num { font-size: 12px; color: var(--text-3); }

/* Chat */
.chat { display: flex; flex-direction: column; height: 560px; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.bubble.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }

/* Mail thread */
.msg { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: var(--surface); }
.msg.out { border-left: 3px solid var(--accent); }
.msg-head { display: flex; justify-content: space-between; gap: 8px; color: var(--text-3); font-size: 12px; margin-bottom: 6px; flex-wrap: wrap; }

/* Charts */
.chart-card .card-head { margin-bottom: 4px; }
.chart-sub { color: var(--text-3); font-size: 12px; margin: 0 0 8px; }
.chart svg { display: block; overflow: visible; }
.chart text { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart .bar { fill: var(--series-1); transition: opacity .12s; }
.chart.hovering .bar { opacity: .4; } .chart.hovering .bar.hot { opacity: 1; }
.hbar-row { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: center; padding: 4px 0; }
.hbar-label { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { display: flex; align-items: center; gap: 8px; min-height: 22px; cursor: default; }
.hbar { height: 14px; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-val { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--text); color: var(--surface); padding: 6px 10px; border-radius: 8px; font-size: 12px; box-shadow: var(--shadow); max-width: 240px; }
.tooltip b { display: block; }

/* Toasts */
.toast-wrap { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 360px; }
.toast.err { background: var(--crit); color: #fff; }

details.acc { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--surface); }
details.acc summary { cursor: pointer; padding: 10px 14px; font-weight: 600; }
details.acc > div { padding: 0 14px 14px; }
.copy-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.copy-row code { flex: 1; background: var(--surface-2); padding: 7px 10px; border-radius: 8px; overflow-x: auto; white-space: nowrap; }

@media (max-width: 1100px) {
  .cols-3-2, .cols-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-value { font-size: 22px; overflow-wrap: anywhere; }
  .page-head > .row { width: 100%; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
  .main { padding: 16px 16px 40px; }
  .split, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .day { grid-template-columns: 1fr; gap: 4px; }
}

/* --- Catering OS additions --- */
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 140px; }
.col h3 { margin: 2px 4px 10px; display: flex; justify-content: space-between; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; box-shadow: var(--shadow); }
.kcard .t { font-weight: 650; }
.kcard .s { color: var(--text-2); font-size: 12.5px; margin: 2px 0 6px; }
.meter-row { display: grid; grid-template-columns: 92px 1fr 150px; gap: 10px; align-items: center; padding: 5px 0; }
.meter { height: 10px; border-radius: 5px; background: var(--info-bg); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 5px; background: var(--series-1); }
.meter.warn { background: var(--warn-bg); } .meter.warn > span { background: var(--warn); }
.meter.crit { background: var(--crit-bg); } .meter.crit > span { background: var(--crit); }
.matrix th.rot { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-size: 11px; padding: 8px 4px; text-transform: none; letter-spacing: 0; }
.matrix td.cell { text-align: center; padding: 6px 4px; font-weight: 700; }
.a-contains { color: var(--crit); } .a-may_contain { color: var(--warn); } .a-free { color: var(--good); } .a-unknown { color: var(--text-3); }
.score { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.score .bar { width: 60px; height: 6px; border-radius: 3px; background: var(--info-bg); overflow: hidden; }
.score .bar span { display: block; height: 100%; background: var(--series-1); }
.reasons { margin: 6px 0 10px; padding-left: 18px; }
.reasons li { margin: 2px 0; }
.legend-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
@media (max-width: 860px) {
  .board { grid-template-columns: repeat(5, 240px); }
  .meter-row { grid-template-columns: 70px 1fr; } .meter-row .muted { grid-column: 1 / -1; }
}

[hidden] { display: none !important; }

/* Ask Claude */
.diff { border: 1px solid var(--border); border-radius: 10px; margin: 8px 0 14px; overflow: hidden; }
.diff-head { padding: 8px 12px; background: var(--surface-2); font-size: 12.5px; color: var(--text-2); }
.diff pre { padding: 8px 12px; margin: 0; font-size: 12.5px; overflow-x: auto; }
.diff-old { background: var(--crit-bg); color: var(--text); }
.diff-new { background: var(--good-bg); color: var(--text); }
.diff-old::before { content: "− before\A"; color: var(--crit); font-weight: 700; }
.diff-new::before { content: "+ after\A"; color: var(--good); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--text-2); text-align: left; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -3px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
