:root {
  --bg: #f4f6f9; --card: #fff; --text: #17202a; --muted: #6b7684; --line: #e3e8ee;
  --primary: #1f4e79; --primary-text: #fff; --accent: #2e7d32; --warn: #b45309; --danger: #c62828;
  --good-bg: #e6f4ea; --bad-bg: #fdecea; --warn-bg: #fff4e0; --info-bg: #e8f0fa; --hol-bg: #f1ecf8;
  --radius: 14px; --tab-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a; --card: #1a222c; --text: #e8edf2; --muted: #93a0ae; --line: #2a3441;
    --primary: #5aa0e0; --primary-text: #08131f; --accent: #66bb6a; --warn: #ffb74d; --danger: #ef7a73;
    --good-bg: #17301c; --bad-bg: #3a1c1a; --warn-bg: #33270f; --info-bg: #17283b; --hol-bg: #261f33;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; font-size: 16px; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: var(--primary); color: var(--primary-text); }
@media (prefers-color-scheme: dark) { .topbar { background: #14202d; color: var(--text); } }
.topbar h1 { font-size: 18px; }
main { max-width: 720px; margin: 0 auto; padding: 14px 14px calc(var(--tab-h) + var(--safe-b) + 24px); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabbar button { flex: 1; height: var(--tab-h); background: none; border: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; }
.tabbar button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.active { color: var(--primary); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }
.pos { color: var(--accent); } .neg { color: var(--danger); }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 14px; font-weight: 600; }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.btn.green { background: var(--accent); color: #fff; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.big { padding: 16px; font-size: 18px; width: 100%; }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; }
.btns { display: grid; gap: 10px; }
.btns.two { grid-template-columns: 1fr 1fr; }

.status { text-align: center; padding: 18px 10px; }
.status .big { font-size: 44px; font-weight: 700; line-height: 1.1; }
.status .lbl { color: var(--muted); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat .v { font-size: 24px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat.wide { grid-column: span 2; }

.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--info-bg); white-space: nowrap; }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.good { background: var(--good-bg); color: var(--accent); }
.chip.bad { background: var(--bad-bg); color: var(--danger); }
.chip.hol { background: var(--hol-bg); }

.notice { border-radius: 10px; padding: 8px 10px; font-size: 13px; margin-top: 8px; background: var(--info-bg); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }

.list { margin: 0; padding: 0; list-style: none; }
.list li { display: flex; align-items: center; gap: 10px; padding: 11px 4px; border-top: 1px solid var(--line); cursor: pointer; }
.list li:first-child { border-top: 0; }
.list .date { width: 52px; flex: none; text-align: center; line-height: 1.15; }
.list .date b { font-size: 18px; display: block; }
.list .date span { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.list li.weekend { background: color-mix(in srgb, var(--muted) 7%, transparent); }
.list li.future { opacity: .55; }
.list li.today .date b { color: var(--primary); }

.monthnav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.monthnav button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 20px; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: right; font-weight: 600; color: var(--muted); font-size: 12px; padding: 4px 4px; }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t td { text-align: right; padding: 8px 4px; border-top: 1px solid var(--line); }
.scroll { overflow-x: auto; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); min-height: 44px; }
input[type=time] { min-width: 100px; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.seg button { padding: 8px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); font-size: 14px; }
.seg button.on { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.blk { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.blk.loc { grid-template-columns: 1fr 1fr auto; }
.blk.loc label:nth-of-type(3) { grid-column: 1 / 3; grid-row: 2; }
.blk.loc .x { grid-column: 3; grid-row: 1; }
.blk .x { min-height: 44px; width: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--danger); font-size: 18px; }
.blk label span { display: block; font-size: 11px; color: var(--muted); }
.h3 { font-size: 14px; font-weight: 600; margin: 14px 0 6px; }

.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(20px + var(--safe-b)); }
.sheet h2 { font-size: 18px; margin-bottom: 12px; }
.sheet .sticky { position: sticky; bottom: calc(-20px - var(--safe-b)); background: var(--bg); padding: 10px 0 calc(8px + var(--safe-b)); margin-top: 8px; }
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 18px; } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + var(--safe-b) + 14px); z-index: 30;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 99px; font-size: 14px; max-width: 90vw; }
.toast.err { background: var(--danger); }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px; width: 100%; max-width: 360px; text-align: center; }
.login-card img { border-radius: 16px; }
.login-card h1 { margin: 10px 0 18px; font-size: 22px; }
.login-card .field { text-align: left; }
.err { color: var(--danger); font-size: 14px; }
