:root {
  --bg: #0f1512;
  --panel: #161e1a;
  --panel-2: #1c2621;
  --line: #2a3630;
  --text: #e8efea;
  --muted: #8fa298;
  --accent: #63d29a;
  --warn: #e0a458;
  --bad: #d96b6b;
  --radius: 10px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f4;
    --panel: #ffffff;
    --panel-2: #f0f3f0;
    --line: #dfe5e0;
    --text: #16211b;
    --muted: #647268;
    --accent: #1f8a5b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 ui-sans-serif, -apple-system, "SF Pro Text", Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-end;
}

.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand .flag { font-size: 26px; }
.brand h1 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.brand .sub { margin: 0; font-size: 12px; color: var(--muted); }

.controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }

.ctl { display: flex; flex-direction: column; gap: 5px; }
.ctl label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

input[type=date], input[type=time] {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 9px;
  font: inherit;
  font-size: 13.5px;
  color-scheme: dark light;
}

.date-row { display: flex; align-items: center; gap: 4px; }

.nudge {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  width: 28px; height: 30px;
  font-size: 16px;
  cursor: pointer;
}
.nudge:hover { border-color: var(--accent); }

.segmented { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button {
  background: var(--panel-2);
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 11px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.segmented button:last-child { border-right: 0; }
.segmented button.on { background: var(--accent); color: #08130d; font-weight: 600; }

.refresh {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.refresh:hover { border-color: var(--accent); color: var(--accent); }
.refresh[disabled] { opacity: .5; cursor: progress; }

/* ---------- day strip ---------- */

.daystrip {
  display: flex;
  gap: 6px;
  padding: 10px 18px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.daystrip button {
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 6px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  min-width: 62px;
  line-height: 1.25;
}
.daystrip button strong { display: block; color: var(--text); font-size: 13px; }
.daystrip button.on { border-color: var(--accent); background: var(--panel-2); }
.daystrip button.on strong { color: var(--accent); }

/* ---------- layout ---------- */

main { padding: 16px 18px 40px; }

.status { color: var(--muted); font-size: 13px; min-height: 20px; margin-bottom: 12px; }
.hidden { display: none !important; }

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
  align-items: start;
}

.col {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 120px;
}

.col-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  border-top: 3px solid var(--course);
  background: var(--panel-2);
  position: sticky;
  top: 0;
}
.col-head h2 { margin: 0; font-size: 14px; letter-spacing: -0.01em; }
.col-head .where { font-size: 11.5px; color: var(--muted); }
.col-head .count { float: right; font-size: 11.5px; color: var(--muted); }
.col-head .count b { color: var(--accent); }

.slots { padding: 8px; display: flex; flex-direction: column; gap: 5px; max-height: 62vh; overflow-y: auto; }

.slot {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  text-decoration: none;
  color: inherit;
}
.slot:hover { border-color: var(--course); }
.slot > div:first-child { min-width: 0; }
.slot .t { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; white-space: nowrap; }
.slot .p { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .r { text-align: right; max-width: 96px; }
.slot .spots {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  display: inline-block;
}
.slot .tag {
  font-size: 10px;
  color: var(--muted);
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.s1 { background: #5a3b3b; color: #ffd9d9; }
.s2 { background: #5a4f33; color: #ffeec9; }
.s3 { background: #34503f; color: #cdf0dc; }
.s4 { background: #1f8a5b; color: #eafff4; }

.empty, .err {
  padding: 14px 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.err { color: var(--bad); }

.note {
  padding: 7px 12px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

.col-foot {
  margin-top: auto;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}
.col-foot a { color: var(--muted); font-size: 11.5px; text-decoration: none; }
.col-foot a:hover { color: var(--accent); }

/* ---------- timeline ---------- */

.timeline { display: flex; flex-direction: column; gap: 2px; }

.tl-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 10px;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.tl-row .hour {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}
.tl-chips { display: flex; flex-wrap: wrap; gap: 5px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--course);
  border-radius: 7px;
  background: var(--panel);
  padding: 3px 8px;
  font-size: 12px;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
}
.chip:hover { border-color: var(--course); background: var(--panel-2); }
.chip .ct { font-variant-numeric: tabular-nums; font-weight: 600; }
.chip .cc { color: var(--muted); font-size: 11px; }
.chip .cs { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 99px; }

/* ---------- alerts drawer ---------- */

.pill {
  display: none;
  background: var(--accent);
  color: #08130d;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  margin-left: 4px;
}
.pill.show { display: inline-block; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100%);
  z-index: 50;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 16px 18px 40px;
  box-shadow: -12px 0 40px rgba(0, 0, 0, .25);
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.drawer-head h2 { margin: 0; font-size: 17px; margin-right: auto; }
.drawer-actions { display: flex; align-items: center; gap: 8px; }

.notify-status { font-size: 11.5px; color: var(--muted); }
.notify-status.bad { color: var(--warn); }

.alert-form {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 12px;
  margin-bottom: 18px;
}

.af-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.af { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.af > span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.af > span em { text-transform: none; letter-spacing: 0; font-style: normal; opacity: .75; }

.af select, .af input {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
  width: 100%;
  color-scheme: dark light;
}

.af-days { border: 0; padding: 12px 0 0; margin: 0; }
.af-days legend { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0; }
.af-days legend em { text-transform: none; letter-spacing: 0; font-style: normal; opacity: .75; }
.weekdays { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.weekdays button {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 7px;
  padding: 5px 9px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.weekdays button.on { background: var(--accent); color: #08130d; border-color: var(--accent); font-weight: 600; }

.af-quiet { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); margin-top: 12px; }

.af-submit { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.primary {
  background: var(--accent);
  border: 0;
  color: #08130d;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
}
.primary[disabled] { opacity: .6; cursor: progress; }

.form-msg { font-size: 12px; color: var(--muted); }
.form-msg.bad { color: var(--bad); }
.form-msg.good { color: var(--accent); }

.alert-list { display: flex; flex-direction: column; gap: 10px; }

.alert-card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--course);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--panel-2);
}
.alert-card.off { opacity: .55; }
.alert-card h3 { margin: 0 0 3px; font-size: 14px; }
.alert-card .terms { font-size: 12px; color: var(--muted); }
.alert-card .stats { font-size: 11px; color: var(--muted); margin-top: 6px; }
.alert-card .stats .bad { color: var(--bad); }
.alert-card .row { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.alert-card .row button {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 7px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.alert-card .row button:hover { border-color: var(--accent); color: var(--accent); }
.alert-card .row button.danger:hover { border-color: var(--bad); color: var(--bad); }

/* ---------- login ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 24px;
  text-align: center;
}
.login-mark { font-size: 34px; line-height: 1; }
.login-card h1 { margin: 10px 0 4px; font-size: 18px; }
.login-sub { margin: 0 0 18px; font-size: 13px; color: var(--muted); }

.login-card input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  margin-bottom: 10px;
  color-scheme: dark light;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-card .primary { width: 100%; padding: 10px; }

.login-msg { min-height: 18px; margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }
.login-msg.bad { color: var(--bad); }

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--line);
  padding: 10px 18px 22px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 11.5px;
}
.legend { display: flex; align-items: center; gap: 6px; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }

@media (max-width: 640px) {
  .topbar { padding: 10px 12px; gap: 12px; }
  main { padding: 12px; }
  .board { grid-template-columns: 1fr; }
  .slots { max-height: none; }
  .tl-row { grid-template-columns: 62px 1fr; }
}

.signout { color: var(--muted); text-decoration: none; margin-right: 14px; }
.signout:hover { color: var(--accent); text-decoration: underline; }
