:root {
  --bg: #f6f7f9; --surface: #fff; --text: #1d2330; --muted: #667085; --border: #e3e6eb;
  --accent: #1f4e9c; --accent-text: #fff; --danger: #b42318; --past: #f0f1f4;
  --sel: rgba(31, 78, 156, .18); --today: #fff8e6; --slot-h: 22px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --surface: #1b1f27; --text: #e6e8ec; --muted: #98a2b3; --border: #2c323d;
    --accent: #6c9cf0; --accent-text: #0d1320; --danger: #f97066; --past: #171a21;
    --sel: rgba(108, 156, 240, .25); --today: #231f14;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #12151b; --surface: #1b1f27; --text: #e6e8ec; --muted: #98a2b3; --border: #2c323d;
    --accent: #6c9cf0; --accent-text: #0d1320; --danger: #f97066; --past: #171a21;
    --sel: rgba(108, 156, 240, .25); --today: #231f14;
    color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.4rem; margin: .5rem 0 1rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.inline { display: inline; margin: 0; }
.dot { display: inline-block; width: .7em; height: .7em; border-radius: 50%; margin-right: .4em; vertical-align: baseline; }

.topbar { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.topbar nav a { text-decoration: none; }
.topbar .who { color: var(--muted); font-size: .85rem; }

button, .btn, select, input, textarea { font: inherit; color: inherit; }
button, .btn { cursor: pointer; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 6px 12px; text-decoration: none; display: inline-block; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button.small { padding: 3px 8px; font-size: .85rem; }
button:disabled { opacity: .6; cursor: wait; }
select, input, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; width: 100%; }

.messages { list-style: none; padding: 0; margin: 0 0 12px; }
.messages li { padding: 8px 12px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); }
.error { color: var(--danger); margin: 8px 0; }

.login-card { max-width: 420px; margin: 8vh auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 24px; }
.login-card h1 { font-size: 1.25rem; }
.login-card label { display: block; margin: 12px 0 4px; font-weight: 600; }
.login-card button { width: 100%; margin-top: 18px; padding: 9px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.resource-picker select { min-width: 240px; font-weight: 600; }
.weeknav { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.week-label { margin-left: 8px; font-weight: 600; }
.resource-info { margin: 4px 0; }
.hint { margin: 4px 0 10px; }

.calendar { display: grid; grid-template-columns: 52px repeat(7, minmax(110px, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow-x: auto; user-select: none; }
.cal-head { position: sticky; top: 0; z-index: 3; text-align: center; padding: 6px 2px; font-weight: 600; font-size: .85rem; background: var(--surface); border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-head span { font-weight: 400; color: var(--muted); }
.cal-head.corner { border-left: 0; }
.cal-head.today { background: var(--today); }
.times { grid-column: 1; }
.time { height: var(--slot-h); font-size: .72rem; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-.55em); }
.day { position: relative; border-left: 1px solid var(--border); }
.day.today { background: var(--today); }
.slot { height: var(--slot-h); border-top: 1px dashed transparent; cursor: pointer; }
.slot.hour { border-top: 1px solid var(--border); }
.slot:not(.hour) { border-top-color: color-mix(in srgb, var(--border) 50%, transparent); }
.slot:hover:not(.past) { background: var(--sel); }
.slot.past { background: var(--past); cursor: not-allowed; }
.slot.selected { background: var(--sel); }

.booking { position: absolute; left: 3px; right: 3px; z-index: 2; margin-top: 1px; padding: 2px 6px; overflow: hidden; text-align: left; font-size: .78rem; line-height: 1.25; border-radius: 5px; border: 0; border-left: 4px solid var(--color); background: color-mix(in srgb, var(--color) 22%, var(--surface)); color: var(--text); display: flex; flex-direction: column; }
.booking.mine { background: color-mix(in srgb, var(--color) 45%, var(--surface)); box-shadow: inset 0 0 0 1px var(--color); }
.booking .b-time { font-weight: 600; }
.booking .b-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.booking .b-who { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

dialog { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); padding: 20px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog h2 { margin: 0 0 6px; font-size: 1.15rem; }
dialog label { display: block; margin: 10px 0 0; font-weight: 600; }
dialog .row { display: flex; gap: 12px; } dialog .row label { flex: 1; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
dialog .actions form { margin: 0; }

table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
@media (max-width: 640px) {
  table.list thead { display: none; }
  table.list tr { display: block; border-bottom: 1px solid var(--border); padding: 6px 0; }
  table.list td { display: block; border: 0; padding: 2px 10px; }
}

.theme-toggle { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 3px 10px; font-size: .85rem; }
.theme-toggle.floating { position: fixed; top: 16px; right: 16px; }
