:root {
  --bg: #f4f5f8; --card: #fff; --text: #1d2130; --muted: #6b7185; --line: #e3e5ec;
  --accent: #2b5cdb; --accent-text: #fff; --pos: #1f8a3e; --neg: #c92a2a; --busy: #fff1e6; --busy-text: #a6420b;
  --free: #e6f6ea; --free-text: #1f7a37; --note: #fff8db; --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a; --card: #1c1f28; --text: #e8eaf0; --muted: #9aa0b4; --line: #2c303c;
    --accent: #6e8fff; --accent-text: #0d1020; --pos: #5cd27f; --neg: #ff7b7b; --busy: #3a2716; --busy-text: #ffb27a;
    --free: #173322; --free-text: #7be39a; --note: #332c12;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
main { max-width: 860px; margin: 0 auto; padding: 12px 16px 32px; }
h1 { font-size: 1.5rem; margin: 8px 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 16px 0 6px; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.top nav { display: flex; gap: 4px; overflow-x: auto; }
.top nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.top nav a[aria-current] { background: var(--accent); color: var(--accent-text); }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 0 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.narrow { max-width: 520px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.flash { background: var(--free); color: var(--free-text); padding: 10px 14px; border-radius: 10px; }
.error { background: #ffe3e3; color: #a51111; padding: 10px 14px; border-radius: 10px; }
@media (prefers-color-scheme: dark) { .error { background: #401919; color: #ffb3b3; } }
.note { background: var(--note); padding: 8px 12px; border-radius: 10px; font-size: .9rem; }
.hello { margin-top: 4px; }
.page-head, .res-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; justify-content: space-between; }
.res-head h2 { margin: 0; }
.res-head h2 a { color: var(--text); text-decoration: none; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.pill.busy { background: var(--busy); color: var(--busy-text); }
.pill.free { background: var(--free); color: var(--free-text); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 10px 0 14px; }
.card .actions { margin-bottom: 0; }
button, .button { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 9px 16px;
  border-radius: 10px; cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.big { padding: 14px 28px; font-size: 1.1rem; }
button.danger { color: var(--neg); }
button.link { background: none; border: 0; padding: 0 4px; color: var(--accent); text-decoration: underline; font-size: .9rem; }
form.inline { display: inline; }
.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-weight: 500; }
label.check, label.radio { display: flex; gap: 8px; align-items: center; font-weight: 400; }
input, select { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--text); width: 100%; min-width: 0; }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=color] { padding: 2px; height: 40px; width: 64px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0; display: grid; gap: 6px; }
legend { padding: 0 4px; font-weight: 600; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { padding: 5px 12px; font-size: .9rem; border-radius: 999px; }
details summary { cursor: pointer; color: var(--accent); margin: 8px 0; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list.bal li { display: flex; justify-content: space-between; }
.list li.me, tr.me td { font-weight: 600; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.big-num { font-size: 1.3rem; font-weight: 700; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-head h2 { margin: 0; }
.cal-head a { font-size: 1.6rem; text-decoration: none; padding: 0 12px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: 8px; }
.dow { text-align: center; font-size: .75rem; color: var(--muted); }
.day { min-height: 64px; border-radius: 8px; background: var(--bg); padding: 3px; text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.day.other { opacity: .45; }
.day.past .dn { color: var(--muted); }
.day.today { outline: 2px solid var(--accent); }
.dn { font-size: .8rem; }
.bar { display: block; color: #fff; font-size: .65rem; line-height: 1.5; border-radius: 4px; padding: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stats > div { background: var(--bg); border-radius: 10px; padding: 10px 12px; display: grid; }
.stats .label { font-size: .8rem; color: var(--muted); }
.stats .val { font-size: 1.35rem; font-weight: 700; }
.stats .val small { font-size: .8rem; font-weight: 400; color: var(--muted); }
.stats .sub { font-size: .8rem; color: var(--muted); }
.tblwrap { overflow-x: auto; margin: 0 -4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.tbl .n { text-align: right; white-space: nowrap; }
.card { overflow-x: auto; }
.settle { border-bottom: 1px solid var(--line); padding: 8px 0 12px; }
.settle-line { margin: 0 0 6px; }
.mp { background: var(--bg); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }
.mp p { margin: 4px 0; }
.copyrow { display: flex; gap: 8px; }
@media (max-width: 480px) {
  .row2 { grid-template-columns: 1fr; }
  .day { min-height: 52px; }
  .bar { font-size: 0; height: 6px; padding: 0; }
  .top { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .tbl { font-size: .86rem; }
  .tbl th, .tbl td { padding: 6px 4px; }
  .stats .val { font-size: 1.2rem; }
}
