/* ================================================================
   MustrHQ — a staff time clock for kitchens.
   Kiosk: dark graphite equipment panel, big touch targets (fluid via clamp).
   Admin: daylight operating instrument — cool steel neutrals, graphite ink,
          green only for state; the working clock is the hero. Flat, ruled,
          quiet, so the time reads first.
   Type: Space Grotesk (display) · IBM Plex Sans (body) · IBM Plex Mono (time)
   ================================================================ */

:root {
  --font-display: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* kiosk (dark equipment) */
  --k-bg: #14171c;
  --k-surface: #1e232b;
  --k-surface2: #262d37;
  --k-ink: #f3f4f2;
  --k-muted: #97a0ad;
  --k-line: #333c47;
  --k-on: #12b981;
  --k-on-deep: #0c8f63;
  --k-off: #3a434f;
  --k-warn: #e0a021;
  --k-danger: #e0574f;

  /* admin (daylight instrument) */
  --paper: #edf0f2;
  --surface: #ffffff;
  --ink: #16191d;
  --ink-2: #59626e;
  --ink-3: #8a929c;
  --rule: #dce1e4;
  --rule-2: #e9edef;
  --brand: #01216c;
  --brand-deep: #011a56;
  --brand-tint: #e8edf6;
  --green: #0d9c66;
  --green-deep: #0a7a50;
  --green-tint: #e4f3ec;
  --amber: #b7770f;
  --amber-tint: #f5eeda;
  --red: #cf4640;
  --red-tint: #f7e4e3;
}

* { box-sizing: border-box; }

/* ============================ KIOSK ============================ */

body.kiosk {
  margin: 0;
  min-height: 100vh;
  background: var(--k-bg);
  color: var(--k-ink);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.k-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(14px, 2.6vw, 22px) clamp(18px, 4vw, 34px);
  border-bottom: 1px solid var(--k-line);
}
.k-ident { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.k-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(18px, 3.4vw, 24px);
  letter-spacing: -0.02em;
}
.k-place {
  font-size: clamp(13px, 2.4vw, 15px);
  color: var(--k-muted);
  padding-left: 14px;
  border-left: 1px solid var(--k-line);
  line-height: 1.2;
}
.k-now { text-align: right; }
.k-clock {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: clamp(30px, 7vw, 46px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: var(--k-ink);
  white-space: nowrap;
}
.k-meta {
  display: flex; justify-content: flex-end; align-items: center; gap: 14px;
  margin-top: 7px; font-size: clamp(12px, 2.2vw, 14px); color: var(--k-muted);
}
.k-onnow { display: inline-flex; align-items: center; gap: 7px; }
.k-date { padding-right: 14px; border-right: 1px solid var(--k-line); }
.k-onnow .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--k-off); }
.k-onnow.live { color: var(--k-on); }
.k-onnow.live .dot { background: var(--k-on); box-shadow: 0 0 0 4px rgba(18,185,129,0.16); }

/* Centre the crew in the available space so the screen never looks half-empty. */
.k-main {
  min-height: calc(100vh - 108px);
  display: flex; flex-direction: column; justify-content: center;
  padding-bottom: clamp(20px, 5vh, 60px);
}
.k-hint {
  text-align: center;
  color: var(--k-muted);
  font-size: clamp(14px, 3.6vw, 16px);
  margin: 0 0 clamp(16px, 3vh, 28px);
}

.k-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(150px, 20vw, 230px), 1fr));
  gap: clamp(12px, 1.8vw, 20px);
  padding: 0 clamp(16px, 4vw, 34px);
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 1.4vw, 16px);
  padding: clamp(20px, 2.6vw, 30px) 16px clamp(18px, 2.2vw, 24px);
  background: var(--k-surface);
  border: 1px solid var(--k-line);
  border-radius: clamp(14px, 1.6vw, 20px);
  color: var(--k-ink);
  font-family: var(--font-body);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.06s ease, border-color 0.12s ease, background 0.12s ease;
}
.tile:hover { background: #232933; }
.tile:active { transform: scale(0.98); }

/* On shift: unmistakable from across the kitchen. */
.tile.on {
  background: linear-gradient(180deg, rgba(18,185,129,0.10), rgba(18,185,129,0.02));
  border-color: rgba(18,185,129,0.55);
}
.tile.on::before {
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--k-on);
}

.tile-face {
  width: clamp(66px, 7.5vw, 96px);
  height: clamp(66px, 7.5vw, 96px);
  border-radius: 50%;
  background: var(--k-surface2);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.12s ease;
}
.tile.on .tile-face { border-color: var(--k-on); }
.tile-face img { width: 100%; height: 100%; object-fit: cover; }
.tile-initials {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(24px, 3vw, 34px); color: #6d7885;
}
.tile.on .tile-initials { color: var(--k-on); }

.tile-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(17px, 1.9vw, 23px);
  text-align: center;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.tile-state {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(13px, 1.2vw, 15px);
  color: var(--k-muted);
}
.tile-state .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--k-off); }
.tile.on .tile-state .dot { background: var(--k-on); box-shadow: 0 0 0 4px rgba(18,185,129,0.16); }
.tile.on .tile-state-text { color: var(--k-on); font-weight: 500; }
.tile-elapsed {
  font-family: var(--font-mono); color: var(--k-on);
  font-variant-numeric: tabular-nums; font-size: clamp(13px, 1.2vw, 15px);
}

.k-devlink {
  position: fixed; right: 14px; bottom: 12px;
  color: #3f4855; font-size: 12px; text-decoration: none;
  padding: 6px 10px; border-radius: 8px;
}
.k-devlink:hover { color: var(--k-muted); }

.k-empty { text-align: center; color: var(--k-muted); padding: 40px 20px; }
.k-empty h2 { font-family: var(--font-display); color: var(--k-ink); }

/* overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 15, 0.74);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}
.overlay[hidden] { display: none; }

.sheet {
  position: relative;
  width: min(430px, 100%);
  background: var(--k-surface);
  border: 1px solid var(--k-line);
  border-radius: 20px;
  padding: clamp(22px, 5vw, 30px) clamp(18px, 4vw, 26px) clamp(20px, 4vw, 26px);
  text-align: center;
}
.sheet-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--k-surface2);
  border: 1px solid var(--k-line);
  color: var(--k-muted);
  font-size: 18px;
  cursor: pointer;
}
.sheet-name { font-family: var(--font-display); font-weight: 700; font-size: clamp(20px, 5.5vw, 26px); }
.sheet-sub { color: var(--k-muted); margin: 6px 0 18px; }

.dots { display: flex; justify-content: center; gap: 16px; margin-bottom: 14px; }
.dots span {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--k-line); background: transparent;
  transition: background 0.1s ease, border-color 0.1s ease;
}
.dots span.filled { background: var(--k-on); border-color: var(--k-on); }
.pin-msg { color: var(--k-danger); min-height: 22px; font-size: 15px; margin-bottom: 10px; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(8px, 2vw, 12px); }
.keypad button {
  font-family: var(--font-mono);
  font-size: clamp(22px, 6vw, 26px);
  min-height: clamp(52px, 12vw, 66px);
  background: var(--k-surface2);
  border: 1px solid var(--k-line);
  border-radius: 14px;
  color: var(--k-ink);
  cursor: pointer;
  transition: transform 0.05s ease, background 0.1s ease;
}
.keypad button:active { transform: scale(0.97); background: #2f3743; }
.keypad .key-blank { visibility: hidden; }
.keypad .key-back { font-size: 22px; color: var(--k-muted); }

.brand-choices { display: grid; gap: 12px; }
.brand-btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(18px, 4.6vw, 20px);
  padding: clamp(16px, 4vw, 20px);
  background: var(--k-surface2);
  border: 1px solid var(--k-line);
  border-radius: 14px;
  color: var(--k-ink);
  cursor: pointer;
}
.brand-btn:active { transform: scale(0.99); }

.overlay.result .result-inner { text-align: center; }
.result-mark {
  width: clamp(84px, 22vw, 104px); height: clamp(84px, 22vw, 104px); border-radius: 50%;
  display: grid; place-items: center;
  font-size: clamp(42px, 11vw, 54px); color: #fff;
  margin: 0 auto 20px;
  background: var(--k-off);
}
.overlay.is-in .result-mark { background: var(--k-on); }
.overlay.is-out .result-mark { background: var(--k-warn); }
.result-big { font-family: var(--font-display); font-weight: 700; font-size: clamp(30px, 9vw, 42px); }
.result-sub { color: var(--k-muted); font-size: clamp(15px, 4vw, 18px); margin-top: 8px; }

.shake { animation: shake 0.32s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-8px); }
  40%,80% { transform: translateX(8px); }
}

/* ============================ ADMIN ============================ */

body.admin {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body.admin.centered { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

/* --- masthead: white, ruled, with a precise underline for the active tab --- */
.topbar {
  display: flex; align-items: center; gap: 22px;
  height: 62px; padding: 0 clamp(16px, 4vw, 32px);
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 9px;
  text-decoration: none; color: var(--ink);
  font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -0.02em;
}
.brand-mark { flex: 0 0 auto; display: block; }
.brand-logo { display: block; height: 26px; width: auto; }
.k-logo { display: block; height: clamp(24px, 3.2vw, 34px); width: auto; }
.brand-word { line-height: 1; }
.brand.big { font-size: 24px; }
.brand-sub { color: var(--ink-2); font-weight: 500; font-size: 13px; }

.mainnav {
  flex: 1 1 auto; min-width: 0; height: 100%;
  display: flex; align-items: stretch; gap: 2px;
  overflow-x: auto; scrollbar-width: none;
}
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  flex: 0 0 auto; display: inline-flex; align-items: center; white-space: nowrap;
  color: var(--ink-2); text-decoration: none;
  padding: 0 12px; font-weight: 500; font-size: 14.5px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .12s;
}
.mainnav a:hover { color: var(--ink); }
.mainnav a.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--brand); }

.topbar-right { flex: 0 0 auto; display: flex; align-items: center; gap: 14px; }
.kiosk-link {
  color: var(--ink-2); text-decoration: none; font-size: 13.5px;
  padding: 6px 11px; border: 1px solid var(--rule); border-radius: 8px; white-space: nowrap;
  transition: color .12s, border-color .12s;
}
.kiosk-link:hover { color: var(--ink); border-color: var(--ink-3); }
.whochip { display: inline-flex; align-items: center; gap: 8px; }
.avatar-sm {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-tint); color: var(--brand);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; font-family: var(--font-display);
}
.who { color: var(--ink); font-size: 14px; font-weight: 500; }
a.ghost { color: var(--ink-2); text-decoration: none; font-size: 14px; }
a.ghost:hover { color: var(--ink); }

/* --- content --- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 30px clamp(16px, 4vw, 32px) 80px; }
.page-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(22px, 5vw, 27px); letter-spacing: -0.02em;
  margin: 4px 0 22px; color: var(--ink);
}

.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 24px; }
.auth-card { width: min(400px, 100%); }

.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 20px 22px; margin-bottom: 18px; }
.panel > h2 { font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: -0.01em; margin: 0 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--rule-2); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--rule-2); flex-wrap: wrap; }
.panel-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: -0.01em; margin: 0; }

/* --- the working clock: the dashboard's hero --- */
.daybar {
  display: flex; align-items: center; gap: clamp(20px, 5vw, 44px); flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 12px;
  padding: clamp(18px, 3vw, 24px) clamp(20px, 4vw, 28px); margin-bottom: 18px;
}
.daybar-time { display: flex; flex-direction: column; gap: 3px; }
.daybar-clock {
  font-family: var(--font-mono); font-weight: 500;
  font-size: clamp(40px, 8vw, 60px); line-height: 1; letter-spacing: 0.01em;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.daybar-date { font-size: 14px; color: var(--ink-2); }
.daybar-figs {
  display: flex; align-items: center; gap: clamp(18px, 4vw, 36px); flex-wrap: wrap;
  border-left: 1px solid var(--rule-2); padding-left: clamp(18px, 4vw, 36px);
}
.dfig { display: flex; flex-direction: column; gap: 4px; }
.dfig-n { font-family: var(--font-mono); font-weight: 500; font-size: 24px; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.dfig-l { font-size: 13px; color: var(--ink-2); }
a.dfig { text-decoration: none; }
a.dfig:hover .dfig-l { color: var(--ink); }
.dfig-n .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 9px; vertical-align: middle; }
.dfig-n .dot.bad { background: var(--red); }
.dfig-n .dot.warn { background: var(--amber); }

/* --- tables --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--ink-2);
  padding: 0 12px 10px; white-space: nowrap; border-bottom: 1px solid var(--rule);
}
table.grid td { padding: 11px 12px; border-bottom: 1px solid var(--rule-2); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover td { background: #f6f8f9; }
td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num { text-align: right; white-space: nowrap; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
tr.total td { border-top: 1px solid var(--rule); border-bottom: none; font-weight: 600; }
.empty-row td { color: var(--ink-2); text-align: center; padding: 28px; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--green-tint); color: var(--green-deep);
  display: inline-grid; place-items: center; overflow: hidden;
  font-size: 12px; font-weight: 600; font-family: var(--font-display);
  vertical-align: middle; object-fit: cover;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* --- state chips --- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12.5px; font-weight: 500; line-height: 1.65; }
.badge.on, .badge.ontime { background: var(--green-tint); color: var(--green-deep); }
.badge.off { background: #eceff1; color: var(--ink-2); }
.badge.late { background: var(--amber-tint); color: var(--amber); }
.badge.noshow { background: var(--red-tint); color: var(--red); }
.badge.unscheduled { background: #e8edf1; color: var(--ink-2); }
.tag { display: inline-block; background: #eceff1; color: var(--ink-2); border-radius: 5px; padding: 2px 8px; font-size: 12.5px; margin: 0 3px 3px 0; }

/* --- buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand); color: #fff; border: none; border-radius: 8px;
  padding: 9px 15px; font-family: var(--font-body); font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background .12s, transform .04s;
}
.btn:hover { background: var(--brand-deep); }
.btn:active { transform: translateY(1px); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.ghost { background: #fff; border: 1px solid var(--rule); color: var(--ink); }
.btn.ghost:hover { background: #f5f7f8; border-color: var(--ink-3); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #b93b36; }
.btn-link { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 14px; padding: 0; text-decoration: none; font-family: var(--font-body); }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--red); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; }

/* --- forms --- */
label { display: block; font-size: 13.5px; font-weight: 500; margin-bottom: 14px; color: var(--ink); }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=datetime-local], select, textarea {
  display: block; width: 100%; padding: 10px 12px;
  border: 1px solid var(--rule); border-radius: 8px;
  font-family: var(--font-body); font-size: 15px; margin-top: 6px;
  background: #fff; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 22px; }
.filters { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 20px; }
.filters label { margin-bottom: 0; }
.filters .field { min-width: 150px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 16px; margin-top: 8px; }
.check-grid label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14.5px; font-weight: 400; }
.check-grid input { width: auto; margin: 0; }
.hint { color: var(--ink-2); font-size: 13px; margin-top: 6px; }

/* --- flashes --- */
.flash { padding: 12px 15px; border-radius: 8px; margin-bottom: 18px; font-size: 14.5px; border: 1px solid transparent; }
.flash.ok { background: var(--green-tint); color: var(--green-deep); border-color: #c7e6d5; }
.flash.err { background: var(--red-tint); color: #a5352f; border-color: #f0cfcd; }
.flash.warn { background: var(--amber-tint); color: var(--amber); border-color: #ecdcb8; }

.muted { color: var(--ink-2); }
.right { text-align: right; }
code { font-family: var(--font-mono); background: #eceff1; padding: 1px 6px; border-radius: 5px; font-size: 13px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ========================= RESPONSIVE ========================= */

@media (max-width: 820px) {
  .wrap { padding: 24px 16px 60px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 0; padding: 10px 14px 0; }
  .brand { font-size: 19px; padding-bottom: 8px; }
  .topbar-right { padding-bottom: 8px; gap: 10px; }
  .kiosk-link { display: none; }
  .who { display: none; }
  .mainnav {
    order: 3; flex-basis: 100%; width: 100%; height: auto;
    border-top: 1px solid var(--rule); margin-top: 2px;
  }
  .mainnav a { padding: 10px 12px; margin-bottom: 0; }

  .wrap { padding: 16px 12px 48px; }
  .panel { padding: 16px 15px; margin-bottom: 16px; }

  .daybar-figs { border-left: none; padding-left: 0; width: 100%; justify-content: space-between; }

  .table-wrap table.grid th, .table-wrap table.grid td { white-space: nowrap; }
  table.grid th { padding: 0 10px 9px; }
  table.grid td { padding: 10px; }

  .filters { flex-direction: column; align-items: stretch; gap: 10px; }
  .filters .field { min-width: 0; }
  .btn { padding: 11px 15px; }
  .btn.small { padding: 8px 12px; }

  input[type=text], input[type=password], input[type=number], input[type=date],
  input[type=time], input[type=datetime-local], select, textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
