:root {
  color-scheme: light dark;
  --bg: #f7f7f2;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #60706a;
  --line: #d9ded8;
  --brand: #17594a;
  --brand-2: #e7b75f;
  --danger: #b42318;
  --ok: #16704a;
  --warn: #946200;
  --shadow: 0 10px 26px rgba(20, 31, 28, .12);
}

[data-theme="dark"] {
  --bg: #101613;
  --panel: #18211d;
  --ink: #eef5ef;
  --muted: #a7b5ae;
  --line: #314039;
  --brand: #67c2a3;
  --brand-2: #f0c56c;
  --danger: #ff8d82;
  --ok: #74d69f;
  --warn: #ffd073;
  --shadow: 0 12px 30px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }
button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--brand);
  color: white;
  font-weight: 700;
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.warning { background: var(--warn); color: #191307; }
button.danger { background: var(--danger); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.table-action { min-height: 34px; padding: 6px 10px; font-size: 12px; }

input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--ink);
}
textarea { min-height: 92px; resize: vertical; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }

.app-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 900;
}
.brand h1 { margin: 0; font-size: 15px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; color: var(--muted); font-weight: 600; }

.content { width: min(1100px, 100%); margin: 0 auto; padding: 16px 14px 90px; }
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 7px 8px max(7px, env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.bottom-nav button {
  min-height: 52px;
  padding: 6px 4px;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  font-size: 11px;
}
.bottom-nav button.active { color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); }
.bottom-nav svg { display: block; margin: 0 auto 3px; width: 20px; height: 20px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(430px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 22px; box-shadow: var(--shadow); }
.login-card h1 { margin: 8px 0 4px; font-size: 25px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }

.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.card h2, .card h3 { margin: 0 0 10px; }
.kpi { display: grid; gap: 4px; }
.kpi strong { font-size: 28px; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.space { justify-content: space-between; }
.stack { display: grid; gap: 10px; }
.form-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}
.pill.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.timer-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.timer-pill { font-variant-numeric: tabular-nums; }
.list { display: grid; gap: 8px; }
.list-item { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: color-mix(in srgb, var(--panel) 88%, var(--bg)); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
.hidden { display: none !important; }
.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 78px;
  z-index: 20;
  padding: 12px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

@media (min-width: 760px) {
  .content { padding: 24px 22px 98px; }
  .brand h1 { font-size: 18px; }
  .bottom-nav { left: 50%; transform: translateX(-50%); width: min(680px, calc(100% - 28px)); bottom: 12px; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
}
