:root {
  --bg: #f7f3ec; --card: #ffffff; --ink: #2b2118; --muted: #7a6a5a; --line: #e6dccd;
  --brand: #8a4b12; --brand-ink: #ffffff; --gold: #d99a1e;
  --free: #1f7a3f; --free-bg: #e7f5ec; --occ: #9a5b00; --occ-bg: #fff3dc;
  --late: #b3261e; --late-bg: #fde8e6; --dirty: #5b5f66; --dirty-bg: #eceef1;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); }
header.top { background: var(--brand); color: var(--brand-ink); padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
header.top .brand { font-weight: 700; font-size: 1.15rem; color: #fff; text-decoration: none; margin-right: auto; }
header.top .brand span { color: var(--gold); }
nav.main { display: flex; gap: 4px; flex-wrap: wrap; }
nav.main a, nav.main button { color: #fff; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: .95rem; background: none; border: 0; font: inherit; cursor: pointer; }
nav.main a.on, nav.main a:hover, nav.main button:hover { background: rgba(255,255,255,.18); }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.4rem; margin: 4px 0 12px; }
h2 { font-size: 1.1rem; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.msg { padding: 12px 14px; border-radius: 10px; margin-bottom: 10px; background: var(--free-bg); color: var(--free); font-weight: 600; }
.msg.error { background: var(--late-bg); color: var(--late); }
.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 10px; background: var(--occ-bg); color: var(--occ); }
.alert a { color: inherit; font-weight: 600; }

.counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.counts div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; }
.counts b { display: block; font-size: 1.5rem; }
.counts .free b { color: var(--free); } .counts .occupied b { color: var(--occ); }
.counts .overdue b { color: var(--late); } .counts .dirty b { color: var(--dirty); }

.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.room { background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--free); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.room h3 { margin: 0; font-size: 1.1rem; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tag { font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.room.free { border-left-color: var(--free); } .room.free .tag { background: var(--free-bg); color: var(--free); }
.room.occupied { border-left-color: var(--occ); } .room.occupied .tag { background: var(--occ-bg); color: var(--occ); }
.room.overdue { border-left-color: var(--late); background: var(--late-bg); } .room.overdue .tag { background: var(--late); color: #fff; }
.room.dirty { border-left-color: var(--dirty); } .room.dirty .tag { background: var(--dirty-bg); color: var(--dirty); }
.room dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: .9rem; }
.room dt { color: var(--muted); } .room dd { margin: 0; }
.room .left { font-weight: 700; }
.room.overdue .left { color: var(--late); }
.room .actions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.room .actions > * { flex: 1; }

.btn { display: inline-block; text-align: center; padding: 12px 16px; border-radius: 10px; border: 0; background: var(--brand); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; min-height: 46px; }
.btn.alt { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.green { background: var(--free); } .btn.red { background: var(--late); }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 10px; min-height: 0; font-size: .875rem; }
form.inline { display: inline; margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; margin-bottom: 4px; }
.field input[type=text], .field input[type=number], .field input[type=tel], .field input[type=date], .field input:not([type]), .field select, .field textarea, input.box {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; min-height: 46px; }
.field .errorlist, .errorlist { color: var(--late); margin: 4px 0 0; padding: 0; list-style: none; font-size: .9rem; }
.choices > div { display: flex; flex-wrap: wrap; gap: 8px; }
.choices label { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-weight: 500; }
.choices label:has(input:checked) { border-color: var(--brand); background: #fbf1e4; font-weight: 700; }
.choices input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }
.check label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.total { font-size: 1.6rem; font-weight: 800; }
.total .was { font-size: 1rem; color: var(--muted); text-decoration: line-through; margin-right: 8px; font-weight: 500; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total-row td { font-weight: 700; border-top: 2px solid var(--ink); }
.scroll { overflow-x: auto; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat span { display: block; color: var(--muted); font-size: .85rem; }
.stat b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stat.good b { color: var(--free); } .stat.bad b { color: var(--late); }
.stat.hl { background: #fbf1e4; border-color: var(--gold); }

.chart { display: flex; align-items: flex-end; gap: 10px; height: 200px; padding: 8px 0 0; border-bottom: 1px solid var(--line); }
.chart .wk { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.chart .bars { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.chart .bar { width: 40%; max-width: 26px; border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .bar.in { background: var(--free); } .chart .bar.out { background: var(--gold); }
.chart-labels { display: flex; gap: 10px; font-size: .75rem; color: var(--muted); }
.chart-labels span { flex: 1; text-align: center; }
.legend { display: flex; gap: 16px; font-size: .85rem; margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.weeknav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.login { max-width: 380px; margin: 40px auto; }

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .counts b { font-size: 1.25rem; }
  .counts div { padding: 6px 2px; font-size: .8rem; }
  main { padding: 12px; }
  .hide-sm { display: none; }
}
