@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #17203a;
  --ink-2: #344054;
  --muted: #667085;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --brand: #1c2540;
  --brand-2: #161d33;
  --brand-ink: #dfe5f5;
  --brand-muted: #8c98bd;
  --accent: #2457e6;
  --accent-hover: #1b46c4;
  --focus: #2f6bff;
  --ok: #0f9d58;
  --ok-bg: #e9f8f0;
  --ok-line: #b8e6cf;
  --warn: #e8890c;
  --warn-bg: #fff4e0;
  --warn-line: #f6dfae;
  --bad: #e5484d;
  --bad-bg: #fdecec;
  --bad-line: #f6c9cb;
  --info: #3b82f6;
  --info-bg: #eaf2ff;
  --info-line: #c6dbff;
  --line-red: #e5484d;
  --line-orange: #e8890c;
  --line-green: #0f9d58;
  --line-blue: #2457e6;
  --line-purple: #8b5cf6;
  --line-teal: #0db5c8;
  --line-pink: #e0448c;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 20px 50px rgba(5, 20, 40, 0.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { line-height: 1.25; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- App shell ---------- */
body.is-app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: var(--brand);
  color: var(--brand-ink);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px 18px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 0; }
.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.brand-text strong { display: block; font-size: 14.5px; letter-spacing: -0.01em; }
.brand-text small { display: block; color: var(--brand-muted); font-size: 12px; }

.route-line { display: flex; gap: 4px; padding: 0 8px; margin-top: 12px; }
.route-line span { height: 5px; flex: 1; border-radius: 3px; background: var(--brand-muted); }
.route-line .r1 { background: #ff8a8a; }
.route-line .r2 { background: #ffb454; }
.route-line .r3 { background: #4ade80; }
.route-line .r4 { background: #6ea8ff; }
.route-line .r5 { background: #c084fc; }
.route-line .r6 { background: #2dd4bf; }

.nav-dot { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; display: inline-block; background: #7f8fb0; }
.nav-dot.red { background: #ff8a8a; }
.nav-dot.orange { background: #ffb454; }
.nav-dot.green { background: #4ade80; }
.nav-dot.blue { background: #6ea8ff; }
.nav-dot.purple { background: #c084fc; }
.nav-dot.teal { background: #2dd4bf; }
.nav-dot.pink { background: #f472b6; }

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-muted);
  padding: 14px 10px 5px;
}
.side-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--brand-ink);
  text-decoration: none;
  font-size: 13.5px;
}
.side-nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.side-nav a.is-active { background: rgba(255, 255, 255, 0.14); color: #fff; font-weight: 600; }

.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, 0.15); padding-top: 13px; display: flex; flex-direction: column; gap: 10px; }
.who strong { display: block; font-size: 13.5px; }
.who small { color: var(--brand-muted); font-size: 11.5px; letter-spacing: 0.05em; text-transform: uppercase; }

.main { padding: 28px 32px 56px; width: 100%; max-width: 1560px; }

/* ---------- Page header ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.015em; }
.page-head h1.ref-title { font-family: var(--mono); font-size: 19px; font-weight: 600; letter-spacing: 0; }
.eyebrow {
  margin: 0 0 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.page-sub { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Cards & stats ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-head .hint { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 20px; }
.card + .card { margin-top: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { position: relative; overflow: hidden; padding: 16px 18px 14px 24px; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--stat-color, var(--accent)); }
.stat .value { font-family: var(--mono); font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; color: var(--stat-color, var(--ink)); }
.stat .label { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.stat-blue { --stat-color: var(--line-blue); background: #f2f6ff; border-color: #d9e5ff; }
.stat-green { --stat-color: var(--line-green); background: #eefaf3; border-color: #cdeedb; }
.stat-amber { --stat-color: var(--line-orange); background: #fff7ea; border-color: #f6e3bd; }
.stat-purple { --stat-color: var(--line-purple); background: #f6f2ff; border-color: #e2d6fb; }
.stat-red { --stat-color: var(--line-red); background: #fdf1f1; border-color: #f6d2d3; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfc; }
.table .primary-cell { font-weight: 500; }
.table .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.table .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.table .num { font-family: var(--mono); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* ---------- Badges & status ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.7;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  white-space: nowrap;
}
.badge.confirmed { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.badge.pending { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.badge.rejected, .badge.cancelled { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.badge.conflict { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #98a2b3; flex: 0 0 auto; }
.dot.available { background: var(--ok); }
.dot.restricted { background: var(--warn); }
.dot.maintenance { background: var(--bad); }
.dot.pending { background: var(--info); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { background: var(--surface); border-color: var(--bad-line); color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); color: var(--bad); }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, 0.28); color: var(--brand-ink); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.input, .select, .textarea {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--focus); outline: 2px solid rgba(46, 144, 250, 0.25); outline-offset: 0; }
.textarea { resize: vertical; min-height: 64px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }

.inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inline-form .field { min-width: 150px; }
.filter-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; gap: 12px; align-items: end; }
.filter-grid .field { min-width: 0; }

.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  background: var(--surface-2);
}
.check-group label { display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 400; margin: 0; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }

/* ---------- Alerts & flash ---------- */
.flash, .alert {
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13.5px;
  margin-bottom: 18px;
  border: 1px solid var(--ok-line);
  background: var(--ok-bg);
  color: #075e3a;
}
.alert-error {
  border-color: var(--bad-line);
  background: var(--bad-bg);
  color: var(--bad);
}
.alert-error ul { margin: 0; padding-left: 18px; }
.error { color: var(--bad); }

/* ---------- Availability board ---------- */
.board-card { overflow: hidden; }
.board-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.confirmed { background: var(--ok); }
.swatch.pending { background: var(--warn); }

.board-scroll { overflow: auto; max-height: calc(100vh - 270px); }
.board { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; }
.board thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--brand);
  color: #cdd8ef;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  padding: 8px 0;
  text-align: center;
  min-width: 46px;
  border-bottom: 1px solid var(--brand-2);
  border-right: 1px solid #2b3557;
}
.board thead th.room-col { z-index: 3; text-align: left; padding: 8px 16px; min-width: 210px; }
.board .room-col {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  min-width: 210px;
  max-width: 210px;
  text-align: left;
  padding: 6px 16px;
  border-right: 1px solid var(--line);
}
.board tbody th.room-col { font-weight: 400; }
.board tbody td { border-bottom: 1px solid var(--line); border-right: 1px solid #f1f3f7; text-align: center; padding: 4px 0; }
.board tbody tr:hover td, .board tbody tr:hover .room-col { background: #fafbfc; }
.board .room-code { display: flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 12.5px; font-weight: 600; color: var(--ink); }
.board .room-name { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.board td .badge {
  width: 22px;
  height: 22px;
  padding: 0;
  justify-content: center;
  border-radius: 6px;
  font-size: 11px;
  cursor: default;
}
.board td .badge.confirmed { background: var(--ok); border-color: var(--ok); color: #fff; }
.board td .badge.pending { background: var(--warn); border-color: var(--warn); color: #fff; }
.board .empty { text-align: left; padding: 20px 16px; color: var(--muted); }

/* ---------- Room cards ---------- */
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.room-card .card-head { align-items: flex-start; }
.room-card .card-head h2 { font-family: var(--mono); font-size: 14px; }
.room-card .card-head .sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 2px; }

/* ---------- Notifications ---------- */
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif { display: flex; gap: 14px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.notif:last-child { border-bottom: 0; }
.notif .notif-body { flex: 1; min-width: 0; }
.notif .notif-title { font-weight: 500; }
.notif .notif-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.notif .notif-text { color: var(--ink-2); font-size: 13px; margin-top: 4px; }

/* ---------- Auth ---------- */
body.is-auth {
  background: var(--brand);
  background-image: radial-gradient(1100px 500px at 15% -10%, rgba(255, 255, 255, 0.07), transparent 60%);
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.auth-main { width: min(430px, 100%); }
.auth-main .flash { margin-bottom: 16px; }
.auth-card { background: var(--surface); border-radius: 12px; padding: 32px; box-shadow: var(--shadow-lg); }
.auth-card .route-line { margin: 0 0 22px; padding: 0; }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.auth-brand .brand-text strong { color: var(--ink); }
.auth-brand .brand-text small { color: var(--muted); }
.auth-card h1 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.auth-sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Dashboard layout ---------- */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.dash-grid > div > .card + .card { margin-top: 18px; }
.dash-col { display: flex; flex-direction: column; gap: 18px; }
.dash-col .card + .card { margin-top: 0; }

.schedule { max-height: 420px; overflow: auto; }
.schedule .slot {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.schedule .slot:last-child { border-bottom: 0; }
a.slot:hover { background: #fafbfc; }
.slot-time { font-family: var(--mono); font-size: 11.5px; color: var(--muted); flex: 0 0 92px; }
.slot-main { flex: 1; min-width: 0; font-size: 13.5px; }
.slot-main strong { font-family: var(--mono); font-weight: 600; margin-right: 6px; }
.slot-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.schedule .empty { padding: 22px 18px; text-align: left; }

.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; padding: 16px 18px; }
.week-day {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: inherit;
  text-decoration: none;
}
.week-day:hover { border-color: var(--line-strong); background: var(--surface); }
.week-day.heat-1 { background: #eff4ff; border-color: #dbe6ff; }
.week-day.heat-2 { background: #dde8ff; border-color: #c3d5ff; }
.week-day.heat-3 { background: #c8daff; border-color: #a6c2ff; }
.week-day.heat-4 { background: #aecbff; border-color: #8ab1ff; }
.week-day.is-today { border-color: var(--line-orange); background: #fff7ea; box-shadow: inset 0 0 0 1px var(--line-orange); }
.wd-name { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.wd-date { font-size: 12px; color: var(--ink-2); }
.wd-count { font-family: var(--mono); font-size: 20px; font-weight: 600; margin-top: 3px; }

/* ---------- Detail layout ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.detail-grid .card + .card { margin-top: 0; }
.kv { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kv th {
  width: 170px;
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12.5px;
  padding: 9px 16px 9px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.kv td { padding: 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: 0; }
.decision-forms { display: flex; flex-direction: column; gap: 18px; }
.decision-block { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.decision-block h3 { margin: 0 0 10px; font-size: 13.5px; font-weight: 600; }
.decision-block form { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  body.is-app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .brand { padding: 0; }
  .side-nav { flex-direction: row; flex: 1 1 100%; overflow-x: auto; gap: 4px; }
  .nav-label { display: none; }
  .side-nav a { white-space: nowrap; padding: 7px 10px; }
  .sidebar-foot { border-top: 0; padding-top: 0; flex-direction: row; align-items: center; gap: 12px; }
  .main { padding: 20px 16px 44px; }
  .form-grid, .detail-grid, .dash-grid { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .board-scroll { max-height: none; }
  .week-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .week-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
