:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #eaeeea;
  --ink: #17201c;
  --ink-2: #4f5b56;
  --muted: #7b8783;
  --line: #d9dfdb;
  --accent: #0b6b66;
  --accent-ink: #ffffff;
  --accent-soft: #dcecea;
  --warn: #b45309;
  --warn-soft: #fbe9d3;
  --ok: #2f7a3a;
  --ok-soft: #dff1e0;
  --danger: #b3261e;
  --shadow: 0 10px 30px rgba(20, 35, 30, 0.12);
  --radius: 14px;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101513; --surface: #182019; --surface-2: #212b24; --ink: #e6ebe7; --ink-2: #b7c2bc;
    --muted: #8a9691; --line: #2d3832; --accent: #4fd1c3; --accent-ink: #072421; --accent-soft: #163a37;
    --warn: #f5b04c; --warn-soft: #3d2a10; --ok: #7fd48a; --ok-soft: #1c3a22; --danger: #f28b82;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101513; --surface: #182019; --surface-2: #212b24; --ink: #e6ebe7; --ink-2: #b7c2bc;
  --muted: #8a9691; --line: #2d3832; --accent: #4fd1c3; --accent-ink: #072421; --accent-soft: #163a37;
  --warn: #f5b04c; --warn-soft: #3d2a10; --ok: #7fd48a; --ok-soft: #1c3a22; --danger: #f28b82;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.wrap { max-width: 640px; margin: 0 auto; padding-inline: 16px; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; text-wrap: balance; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent); }
.money, .num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.eyebrow { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }

button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 8px 14px; min-height: 40px; display: inline-flex; align-items: center; gap: 6px;
  justify-content: center; text-decoration: none; transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 0.85rem; border-radius: 8px; }
.btn-icon { width: 40px; padding: 0; }
button[disabled] { opacity: 0.5; cursor: default; }

input, textarea, select {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; width: 100%; min-height: 40px;
}
textarea { resize: vertical; line-height: 1.5; font-family: var(--font-mono); font-size: 0.9rem; }
label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--ink-2); font-weight: 500; }
label > input, label > select, label > textarea { font-weight: 400; color: var(--ink); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.spread { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 0.85rem; font-weight: 500; cursor: pointer; min-height: 32px;
}
.chip.active { border-color: var(--accent); background: var(--accent-soft); }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; flex: 0 0 auto; text-transform: uppercase;
}
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-muted { background: var(--surface-2); color: var(--ink-2); }

table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { padding: 6px 4px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
td.r, th.r { text-align: right; }
.table-wrap { overflow-x: auto; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 0.9rem; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 15, 13, 0.45); z-index: 40; display: none; }
.sheet-backdrop.open { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--surface); border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow); transform: translateY(105%); transition: transform 0.22s ease; max-height: 88vh; overflow: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.sheet.open { transform: translateY(0); }
.sheet-inner { max-width: 640px; margin: 0 auto; display: grid; gap: 14px; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
