:root {
  --bg: #f6f5f2; --surface: #ffffff; --surface-2: #f1f0ec; --border: #e3e1db;
  --text: #17171a; --text-2: #55545a; --text-3: #7c7b80;
  --accent: #2a6fd6; --accent-ink: #ffffff; --accent-soft: #e6effc;
  --good: #1a8a52; --warn: #b7791f; --bad: #c8382f; --good-soft: #e3f4ea; --warn-soft: #fbf1df; --bad-soft: #fbe6e4;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 2px 8px rgba(20, 20, 30, .04);
  --radius: 12px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141416; --surface: #1d1d20; --surface-2: #26262a; --border: #333338;
    --text: #f0f0f2; --text-2: #b9b8bf; --text-3: #8d8c94;
    --accent: #5b97ec; --accent-ink: #0d0d10; --accent-soft: #1f2e45;
    --good: #4cc38a; --warn: #e0a84a; --bad: #ef6b62; --good-soft: #17301f; --warn-soft: #33281a; --bad-soft: #3a1d1b;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141416; --surface: #1d1d20; --surface-2: #26262a; --border: #333338;
  --text: #f0f0f2; --text-2: #b9b8bf; --text-3: #8d8c94;
  --accent: #5b97ec; --accent-ink: #0d0d10; --accent-soft: #1f2e45;
  --good: #4cc38a; --warn: #e0a84a; --bad: #ef6b62; --good-soft: #17301f; --warn-soft: #33281a; --bad-soft: #3a1d1b;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.sub { color: var(--text-2); font-size: 13px; margin: 0 0 20px; }
.muted { color: var(--text-2); font-size: 13px; }
.small { font-size: 12px; color: var(--text-3); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.hidden { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 12px; position: sticky; top: 0;
        height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 700; font-size: 15px; padding: 4px 10px 16px; }
.brand span { display: block; font-weight: 400; font-size: 12px; color: var(--text-3); }
.nav a { display: block; padding: 9px 10px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-size: 14px; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .bottom { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 4px; }
main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; }
.topbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 0 30% 0 0; z-index: 40; height: 100%; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .side.open { display: flex; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface);
            border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
  .topbar strong { font-size: 15px; }
  main { padding: 18px 16px 60px; }
  input, select, textarea { font-size: 16px !important; }
}

/* cards & grids */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
        box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 14px; }
.grid > .card + .card { margin-top: 0; }
.stat .label { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

/* forms */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
label .opt { font-weight: 400; color: var(--text-3); }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=date],
input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); font: inherit; font-size: 14px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field { margin-bottom: 14px; }
.help { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 14px; margin-bottom: 8px; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.05); background: var(--accent); }
button.danger { color: var(--bad); }
button.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.sm { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .55; cursor: default; }

/* status pieces */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.good { background: var(--good); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px;
        border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.good > i { background: var(--good); } .bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }
.banner { border-radius: 10px; padding: 12px 14px; font-size: 14px; margin-bottom: 16px; border: 1px solid var(--border);
          background: var(--surface); }
.banner.warn { background: var(--warn-soft); border-color: transparent; }
.banner.info { background: var(--accent-soft); border-color: transparent; }
.banner.bad { background: var(--bad-soft); border-color: transparent; }

/* lists & tables */
.list { display: flex; flex-direction: column; }
.item { padding: 12px 0; border-top: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.item:first-child { border-top: 0; padding-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap;
         max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
th { background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--text-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 10, 15, .45); z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
         padding: 22px; border: 1px solid var(--border); }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.modal .actions .left { margin-right: auto; }

/* toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
         padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 80; max-width: 92vw; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); color: #fff; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
           display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* calendar */
#calendar { --fc-border-color: var(--border); --fc-page-bg-color: var(--surface); --fc-neutral-bg-color: var(--surface-2);
            --fc-today-bg-color: var(--accent-soft); --fc-button-bg-color: var(--surface); --fc-button-text-color: var(--text);
            --fc-button-border-color: var(--border); --fc-button-hover-bg-color: var(--surface-2);
            --fc-button-hover-border-color: var(--border); --fc-button-active-bg-color: var(--accent-soft);
            --fc-button-active-border-color: var(--accent); --fc-event-text-color: #fff; --fc-list-event-hover-bg-color: var(--surface-2);
            font-size: 13px; }
#calendar .fc-toolbar-title { font-size: 17px; }
#calendar .fc-button { font-size: 13px; font-weight: 600; box-shadow: none !important; }
#calendar .fc-button-active { color: var(--accent) !important; }
#calendar .fc-col-header-cell-cushion, #calendar .fc-daygrid-day-number { color: var(--text-2); text-decoration: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border: 1px solid var(--border);
        border-radius: 99px; background: var(--surface); font-size: 13px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
pre.report { white-space: pre-wrap; font-size: 13px; background: var(--surface-2); padding: 12px; border-radius: 8px; margin: 0; }
details summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text-2); }
