:root {
  color-scheme: dark;
  --bg: #131a2c;
  --bg-raised: #1b2440;
  --bg-sunken: #0f1524;
  --paper: #fbfbf4;
  --ink: #263f84;
  --ink-muted: #5b6a95;
  --text: #eef1f8;
  --text-muted: #98a3c2;
  --line: rgba(238, 241, 248, 0.14);
  --go: #2f9e6f;
  --go-ink: #0c2a1e;
  --wait: #e8b23a;
  --stop: #d95858;
  --radius: 14px;
  --shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

.admin-body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

button,
input {
  font: inherit;
}

[hidden] {
  display: none !important;
}

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

.mono {
  font-family: "Courier New", Courier, monospace;
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  background: rgba(238, 241, 248, 0.1);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 80ms ease, filter 120ms ease, background 120ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 2px solid #8fb2ff;
  outline-offset: 2px;
}

.btn--primary {
  color: #ffffff;
  background: var(--go);
}

.btn--primary:hover {
  filter: brightness(1.08);
}

.btn--ghost {
  color: var(--text-muted);
  background: transparent;
  border-color: var(--line);
}

.btn--ghost:hover {
  color: var(--text);
  border-color: rgba(238, 241, 248, 0.3);
}

.btn--warn {
  color: #2a1c05;
  background: var(--wait);
}

.btn--block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.icon-btn {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text-muted);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--text);
}

.icon-btn[aria-pressed="false"] {
  opacity: 0.45;
}

.icon-btn.is-connected {
  color: #7fdcaf;
  border-color: rgba(127, 220, 175, 0.45);
  background: rgba(47, 158, 111, 0.14);
}

.icon-btn.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

.icon-btn--width {
  font-variant-numeric: tabular-nums;
}

/* --- Login ---------------------------------------------------------------- */

.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
}

.login__card {
  width: min(380px, 100%);
  padding: 28px 24px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}

.login__brand {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.login__title {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.4rem;
  line-height: 1;
}

.login__copy {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.login__form label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 700;
}

.login__form input {
  width: 100%;
  min-height: 46px;
  margin-bottom: 14px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--bg-sunken);
}

.login__form input:focus-visible {
  outline: 2px solid #8fb2ff;
  outline-offset: 1px;
}

.login__message {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--stop);
  font-size: 0.86rem;
}

/* --- Board shell ---------------------------------------------------------- */

.board {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 14px calc(120px + env(safe-area-inset-bottom, 0px));
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(12px, env(safe-area-inset-top, 0px)) 0 12px;
}

.topbar__brand b {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.32rem;
  font-weight: 400;
  line-height: 1.1;
}

.topbar__brand span {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar__tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.pill--online {
  color: #7fdcaf;
  border-color: rgba(127, 220, 175, 0.4);
  background: rgba(47, 158, 111, 0.14);
}

.pill--offline {
  color: #ff9d9d;
  border-color: rgba(217, 88, 88, 0.45);
  background: rgba(217, 88, 88, 0.14);
}

.pill--unknown {
  color: var(--text-muted);
}

/* --- Controls ------------------------------------------------------------- */

/* Search and filters stay reachable while the rail scrolls; the brand row
   above them is free to scroll away so a phone keeps its screen space. */
.controls {
  position: sticky;
  top: 0;
  z-index: 3;
  margin: 0 -14px;
  padding: 8px 14px 12px;
  background: var(--bg);
  box-shadow: 0 8px 16px rgba(15, 21, 36, 0.6);
}

.searchbox {
  position: relative;
  display: flex;
  align-items: center;
}

.searchbox__icon {
  position: absolute;
  left: 13px;
  color: var(--text-muted);
  font-size: 1.2rem;
  pointer-events: none;
}

.searchbox input {
  width: 100%;
  min-height: 46px;
  padding: 0 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: var(--bg-sunken);
  -webkit-appearance: none;
  appearance: none;
}

.searchbox input::-webkit-search-cancel-button {
  display: none;
}

.searchbox input:focus-visible {
  outline: 2px solid #8fb2ff;
  outline-offset: 1px;
}

.searchbox__clear {
  position: absolute;
  right: 8px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  color: var(--text-muted);
  background: rgba(238, 241, 248, 0.12);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.filters {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filters::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  background: transparent;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.chip b {
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(238, 241, 248, 0.12);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.chip:focus-visible {
  outline: 2px solid #8fb2ff;
  outline-offset: 2px;
}

.chip.is-active {
  color: #10192e;
  background: var(--paper);
  border-color: var(--paper);
}

.chip.is-active b {
  background: rgba(19, 26, 44, 0.14);
}

.chip[data-filter="waiting"].has-work:not(.is-active) {
  color: #ffd782;
  border-color: rgba(232, 178, 58, 0.5);
}

.filters.is-muted .chip {
  opacity: 0.5;
}

.search-note {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* --- Agent warning -------------------------------------------------------- */

.alert {
  margin-bottom: 14px;
  padding: 13px 15px;
  border: 1px solid rgba(217, 88, 88, 0.5);
  border-radius: var(--radius);
  background: rgba(217, 88, 88, 0.12);
}

.alert b {
  display: block;
  margin-bottom: 4px;
  color: #ffb3b3;
  font-size: 0.95rem;
}

.alert p {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.45;
  max-width: 62ch;
}

.alert__link {
  margin: 10px 0 0 !important;
  font-size: 0.85rem;
}

.alert__link a {
  color: #ffb3b3;
}

.alert code {
  display: block;
  overflow-x: auto;
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--text);
  background: var(--bg-sunken);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.84rem;
  white-space: nowrap;
}

/* --- Ticket rail ---------------------------------------------------------- */

.rail {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .rail {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    align-items: start; /* cards keep their own height instead of stretching */
  }
}

.rail__empty {
  padding: 44px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
}

.rail__empty b {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 1.05rem;
}

.ticket {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.ticket--pending {
  border-left-color: var(--wait);
  background: #212c4c;
}

.ticket--approved,
.ticket--printing {
  border-left-color: #6f8ee0;
}

.ticket--printed {
  border-left-color: var(--go);
  background: rgba(27, 36, 64, 0.55);
}

.ticket--declined {
  border-left-color: rgba(238, 241, 248, 0.2);
  background: rgba(27, 36, 64, 0.4);
  opacity: 0.72;
}

.ticket.is-selected {
  outline: 2px solid #8fb2ff;
  outline-offset: 1px;
}

.ticket.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

.ticket__select {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  cursor: pointer;
}

.ticket__select input {
  width: 22px;
  height: 22px;
  accent-color: #6f8ee0;
  cursor: pointer;
}

.ticket__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge--pending {
  color: #2a1c05;
  background: var(--wait);
}

.badge--approved,
.badge--printing {
  color: #0c1730;
  background: #93aef0;
}

.badge--printed {
  color: #ffffff;
  background: var(--go);
}

.badge--declined {
  color: var(--text-muted);
  background: rgba(238, 241, 248, 0.14);
}

.ticket__no {
  color: #aab4d0;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.ticket__guest {
  margin: 10px 0 2px;
  font-family: "Courier New", Courier, monospace;
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  word-break: break-all;
}

.ticket__guest--blank {
  color: var(--text-muted);
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

.ticket__sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.ticket__reprints {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(238, 241, 248, 0.12);
  font-size: 0.74rem;
  font-weight: 700;
}

.ticket__actions {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.ticket__actions .btn {
  flex: 1 1 auto;
  min-width: 108px;
}

/* --- Fallback ------------------------------------------------------------- */

.fallback {
  margin-top: 26px;
  padding: 16px;
  border: 1px dashed rgba(232, 178, 58, 0.42);
  border-radius: var(--radius);
  background: rgba(232, 178, 58, 0.07);
}

.fallback h2 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.fallback p {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.45;
  max-width: 52ch;
}

/* --- Drag select ---------------------------------------------------------- */

.marquee {
  position: absolute;
  z-index: 4;
  border: 1px solid #8fb2ff;
  border-radius: 6px;
  background: rgba(143, 178, 255, 0.16);
  pointer-events: none;
}

.admin-body.is-marquee {
  user-select: none;
  cursor: crosshair;
}

.admin-body.is-marquee .ticket {
  cursor: crosshair;
}

/* --- Bulk bar + toast ----------------------------------------------------- */

.bulkbar {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  width: min(720px, calc(100% - 20px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 21, 36, 0.96);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}

.bulkbar__count {
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.bulkbar__actions {
  display: flex;
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  z-index: 6;
  max-width: min(420px, calc(100% - 24px));
  padding: 11px 16px;
  border-radius: 999px;
  color: #10192e;
  background: var(--paper);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.toast--bad {
  color: #ffffff;
  background: var(--stop);
}
