/* ==================================================================
   KZS — water schedule
   Same visual language as the video archive (archive.html).
================================================================== */

:root {
  --navy:    #10243f;
  --navy-2:  #1b3557;
  --red:     #c8102e;
  --red-dk:  #9b0c23;
  --page:    #eef1f4;
  --card:    #ffffff;
  --ink:     #16202c;
  --muted:   #5f7080;
  --line:    #d5dde4;
  --line-2:  #e8edf1;
  --zebra:   #f7f9fb;
  --good:    #1c7a4a;
  --amber:   #b26a00;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --hour-h: 52px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.wrap { max-width: 1380px; margin: 0 auto; padding: 0 18px; }

[hidden] { display: none !important; }

/* ---------- masthead ---------- */

.masthead { background: var(--navy); color: #fff; }

.masthead .wrap {
  display: flex; align-items: center; gap: 14px;
  padding-top: 14px; padding-bottom: 14px;
}

.masthead img { height: 46px; width: auto; display: block; border-radius: 3px; }
.masthead h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: 0.01em; }
.masthead p { margin: 1px 0 0; font-size: 12px; color: #a8bdd4; letter-spacing: 0.02em; }
.masthead .spacer { flex: 1 1 auto; }
.masthead .user { font-size: 12px; color: #a8bdd4; text-align: right; }
.masthead a.plain { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 14px; }

.navbar { background: var(--navy-2); }

.navbar .wrap {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding-top: 8px; padding-bottom: 8px; align-items: center;
}

.pill {
  background: rgba(255,255,255,0.08);
  border: 1px solid transparent;
  border-radius: 999px;
  color: #dbe6f2;
  font-size: 12px; font-weight: 600;
  padding: 4px 12px;
  cursor: pointer; text-decoration: none;
}

.pill:hover { background: rgba(255,255,255,0.16); color: #fff; }
.pill[aria-pressed="true"] { background: var(--red); color: #fff; }
.pill.on { background: var(--red); color: #fff; }
.navbar .spacer { flex: 1 1 auto; }

/* ---------- panels ---------- */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  margin: 18px 0;
}

.panel > h2 {
  margin: 0;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--navy);
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
}

.panel > h2 span { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); }
.panel .body { padding: 14px 16px; }

.hint { color: var(--muted); font-size: 12px; }
.hint kbd {
  font-family: var(--mono); font-size: 11px;
  background: var(--zebra); border: 1px solid var(--line);
  border-radius: 3px; padding: 0 4px;
}

/* ---------- buttons ---------- */

.btn {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12px; font-weight: 600;
  padding: 6px 11px;
  cursor: pointer; text-decoration: none;
  display: inline-block; white-space: nowrap;
}

.btn:hover { border-color: var(--navy); }
.btn.play { background: var(--red); border-color: var(--red); color: #fff; }
.btn.play:hover { background: var(--red-dk); border-color: var(--red-dk); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.ghost { color: var(--muted); }
.btn.danger { color: var(--red); border-color: #edc9cf; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ---------- toolbar ---------- */

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.toolbar .range { font-weight: 700; font-size: 14px; min-width: 190px; }
.toolbar .spacer { flex: 1 1 auto; }

/* ---------- calendar ---------- */

.calscroll { overflow-x: auto; }
.calinner { min-width: 820px; }

.calhead {
  display: grid; grid-template-columns: 54px repeat(7, 1fr);
  background: var(--zebra); border-bottom: 1px solid var(--line);
}

.calhead div {
  padding: 7px 8px; text-align: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted);
}
.calhead div b { display: block; font-size: 15px; letter-spacing: 0; color: var(--ink); }
.calhead div.today { color: var(--red); }
.calhead div.today b { color: var(--red); }

.calbody {
  display: grid; grid-template-columns: 54px repeat(7, 1fr);
  max-height: 68vh; overflow-y: auto;
}

.caltimes { position: relative; border-right: 1px solid var(--line); }
.caltimes span {
  position: absolute; right: 7px; transform: translateY(-6px);
  font-size: 10px; color: var(--muted); font-family: var(--mono);
}

.calday { position: relative; border-right: 1px solid var(--line-2); }
.calday:last-child { border-right: 0; }
.calday.weekend { background: var(--zebra); }
.calday.today { background: #fdf6f7; }
.calline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line-2); }
.calline.half { border-top-style: dotted; }

.ev {
  position: absolute;
  border: 1px solid var(--line);
  border-left: 3px solid var(--ev, var(--navy));
  border-radius: 3px;
  background: #fff;
  padding: 4px 6px;
  font-size: 11px; line-height: 1.25;
  overflow: hidden;
}

.ev .t { font-weight: 700; font-size: 11.5px; }
.ev .m { color: var(--muted); }
.ev .y { color: var(--muted); font-style: italic; }
.ev:hover { box-shadow: 0 2px 10px rgba(16,36,63,0.18); z-index: 5; }
.ev.draggable { cursor: grab; }
.ev.dragging { cursor: grabbing; z-index: 40; box-shadow: 0 10px 24px rgba(16,36,63,0.3); opacity: 0.9; }
.ev.copying { border-style: dashed; border-left-style: solid; }
.ev.pending { background: repeating-linear-gradient(135deg, #fff8e6 0 7px, #fdf0d0 7px 14px); }

/* open session — anyone with a DSM account may join */
.ev.open {
  background: #e8f6ee;
  border-color: #b6dcc6;
  box-shadow: inset 0 4px 0 #34a06a;
  padding-top: 8px;
}
.ev.open.pending {
  background: repeating-linear-gradient(135deg, #eef8f1 0 7px, #dcf0e4 7px 14px);
}
.ev.rejected { opacity: 0.5; }
.ev.selected { box-shadow: inset 0 0 0 2px var(--red); }

.selcount { font-weight: 600; color: var(--navy); white-space: nowrap; }

/* ticked in the admin request table */
.ev.picked {
  box-shadow: inset 0 0 0 2px var(--navy), 0 4px 14px rgba(16,36,63,0.22);
  z-index: 6;
}

/* free-text combo fields keep the browser's own dropdown affordance */
.field input[list] { background-image: none; }

/* optional-names block in the booking dialog */
/* group name + colour swatch side by side */
.gridgc { display: grid; grid-template-columns: 1fr 76px; gap: 10px; }
.field input[type="color"] {
  padding: 3px; height: 33px; cursor: pointer; background: #fff;
}

/* administrator's editor for the people who joined */
.joinrow {
  display: grid; grid-template-columns: 1fr 62px 1fr 30px;
  gap: 5px; margin-bottom: 5px; align-items: center;
}
.joinrow input {
  width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 3px;
  color: var(--ink); font-family: var(--sans); font-size: 13.5px; padding: 5px 8px;
}
.joinrow input:focus { border-color: var(--navy); outline: none; }
.joinrow .jdrop { padding: 4px 0; text-align: center; line-height: 1; font-size: 15px; }

/* water open / close inside the hover card */
.pop .watertimes b { color: var(--ink); font-weight: 600; }

.namelist { margin-bottom: 11px; }
.namelist label { display: block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin-bottom: 4px; }
.namelist input.namein {
  width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 3px;
  color: var(--ink); font-family: var(--sans); font-size: 14px;
  padding: 6px 9px; margin-bottom: 5px;
}
.namelist input.namein:focus { border-color: var(--navy); outline: none; }

.pop .foot .btn { width: 100%; text-align: center; }

.ev .badge {
  display: inline-block; margin-top: 2px; padding: 0 4px;
  border-radius: 2px; background: var(--zebra); border: 1px solid var(--line);
  font-size: 9px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted);
}

/* two or more bookings drawn as one block */
.ev.combo { border-left-width: 5px; border-left-style: double; }
.ev.combo .t { line-height: 1.15; }

/* rows in the "which one?" dialog */
.chooserow {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line-2);
}
.chooserow:last-of-type { border-bottom: 0; }
.chooserow > div { flex: 1; min-width: 0; }
.chooserow b { font-size: 13.5px; }

.pop .popgrp {
  font-weight: 700; font-size: 12px; margin: 9px 0 3px;
  padding-top: 8px; border-top: 1px solid var(--line-2);
}
.pop .popgrp:first-of-type { margin-top: 2px; padding-top: 0; border-top: 0; }

/* roster card on hover / tap */
.pop {
  position: absolute; z-index: 200; width: 244px;
  background: var(--card); border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 14px 34px rgba(16,36,63,0.24);
  padding: 12px 13px; font-size: 12.5px;
}
.pop h4 { margin: 0 0 2px; font-size: 13.5px; }
.pop .when { color: var(--muted); font-size: 11.5px; margin-bottom: 8px; }
.pop ol { margin: 0; padding-left: 17px; }
.pop li { padding: 1px 0; }
.pop .none { color: var(--muted); font-style: italic; }
.pop .foot { margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--line-2);
  color: var(--muted); font-size: 11.5px; }

/* ---------- legend ---------- */

.legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 16px;
  font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 2px; display: inline-block;
  border: 1px solid rgba(0,0,0,0.12); }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; }

thead th {
  background: var(--zebra); border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; text-align: left;
  padding: 7px 10px;
}

tbody td { border-bottom: 1px solid var(--line-2); padding: 8px 10px; vertical-align: top; }
tbody tr:hover td { background: var(--zebra); }
td.num, th.num { text-align: right; font-family: var(--mono); }

.tag { display: inline-block; padding: 1px 6px; border-radius: 2px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.tag.requested { background: #fff8e6; color: #6b5200; border: 1px solid #ecd9a8; }
.tag.approved { background: #e9f5ee; color: var(--good); border: 1px solid #bfe0cd; }
.tag.rejected { background: #fdeaed; color: var(--red-dk); border: 1px solid #f0c8ce; }

/* ---------- sign in gate ---------- */

.gate {
  position: fixed; inset: 0; z-index: 60;
  background: var(--navy);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gate[hidden] { display: none; }

.gate form {
  width: 100%; max-width: 320px;
  background: var(--card); border-radius: 5px; padding: 22px;
}

.gate h2 { margin: 0 0 3px; font-size: 16px; }
.gate .sub { margin: 0 0 18px; font-size: 12px; color: var(--muted); }
.gate .field { margin-bottom: 11px; }

.gate label {
  display: block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); margin-bottom: 4px;
}

.gate input, .gate textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 3px;
  font-family: var(--sans); font-size: 16px; padding: 8px 10px;
  color: var(--ink); background: #fff;
}
.gate textarea { font-size: 14px; resize: vertical; }
.gate input:focus, .gate textarea:focus { border-color: var(--navy); outline: none; }

.gate button.submit {
  width: 100%; margin-top: 6px;
  background: var(--red); border: 1px solid var(--red); border-radius: 3px;
  color: #fff; font-size: 13px; font-weight: 700; padding: 10px; cursor: pointer;
}
.gate button.submit:disabled { opacity: 0.55; cursor: default; }

.gate .tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.gate .tabs button {
  flex: 1; padding: 7px 4px; border: 1px solid var(--line); background: #fff;
  border-radius: 3px; font: inherit; font-size: 11.5px; font-weight: 700;
  color: var(--muted); cursor: pointer;
}
.gate .tabs button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.gate .swap { margin: 12px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.gate .swap a { color: var(--navy); }

.alert { margin-top: 11px; padding: 8px 10px; border-left: 3px solid var(--red);
  background: #fdeaed; font-size: 13px; }
.alert.good { border-left-color: var(--good); background: #e9f5ee; }
.alert[hidden] { display: none; }

/* ---------- dialog ---------- */

.modal {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(10,20,32,0.72);
  display: flex; align-items: center; justify-content: center; padding: 26px;
}

.modalbox {
  background: var(--card); border-radius: 5px;
  width: min(560px, 100%); max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden;
}

.modalhead { display: flex; align-items: baseline; gap: 8px;
  padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--zebra); }
.modalhead strong { font-size: 14px; }
.modalhead span { font-size: 12px; color: var(--muted); }

.modalbody { padding: 14px 16px; overflow-y: auto; }

.modalfoot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--line); background: var(--zebra); }
.modalfoot .left { margin-right: auto; }

.field { margin-bottom: 11px; }
.field label { display: block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 3px;
  color: var(--ink); font-family: var(--sans); font-size: 14px; padding: 7px 9px;
}
.field input:focus, .field select:focus { border-color: var(--navy); outline: none; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.roster { border: 1px solid var(--line); border-radius: 3px; max-height: 180px;
  overflow-y: auto; padding: 5px; }
.roster .grp { font-size: 10px; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted); padding: 7px 5px 3px; }
.roster label { display: flex; align-items: center; gap: 8px; padding: 4px 5px;
  font-size: 13.5px; text-transform: none; letter-spacing: 0; color: var(--ink);
  font-weight: 400; margin: 0; cursor: pointer; }
.roster label:hover { background: var(--zebra); }
.roster input { width: auto; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 500; padding: 9px 15px; border-radius: 3px;
  font-size: 13px; font-weight: 600; color: #fff;
  box-shadow: 0 10px 26px rgba(16,36,63,0.3);
}

footer.page { padding: 22px 0 40px; text-align: center; font-size: 12px; color: var(--muted); }
footer.page a { color: var(--muted); }

@media (max-width: 700px) {
  :root { --hour-h: 46px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .modal { padding: 0; }
  .modalbox { border-radius: 0; height: 100%; max-height: 100%; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }
