:root {
  --bg: #0b0b0c;
  --bg-card: rgba(24, 24, 27, 0.82);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.18);
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 14px;
  --font: "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --page-pad: clamp(1rem, 2.5vw, 2rem);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  min-height: 100%;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

button, input, select { font: inherit; }

.bg-scene {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #0b0b0c;
}

.bg-slide {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  animation: bg-cycle 45s infinite;
}

.bg-1 { background-image: url("/assets/bg-1.webp"); }
.bg-2 { background-image: url("/assets/bg-2.webp"); }
.bg-3 { background-image: url("/assets/bg-3.webp"); }

.bg-slide:first-child { animation-name: bg-cycle-first; }
.bg-slide:nth-child(2) { animation-delay: 15s; }
.bg-slide:nth-child(3) { animation-delay: 30s; }

@keyframes bg-cycle-first {
  0% { opacity: 1; }
  30.7% { opacity: 1; }
  33.3% { opacity: 0; }
  97.4% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes bg-cycle {
  0% { opacity: 0; }
  2.6% { opacity: 1; }
  30.7% { opacity: 1; }
  33.3% { opacity: 0; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-slide { animation: none; opacity: 0; }
  .bg-slide:first-child { opacity: 1; }
}

.bg-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(8, 8, 10, 0.42), rgba(8, 8, 10, 0.62) 46%, rgba(8, 8, 10, 0.78)),
    radial-gradient(ellipse at 50% 0%, rgba(59, 130, 246, 0.12), transparent 55%);
  z-index: 0;
}

.nav, .login-shell, .app-main, .gate { position: relative; z-index: 1; }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem var(--page-pad);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
}

.brand-name { font-weight: 650; letter-spacing: 0.01em; }

.nav-links { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }

.nav-pill {
  color: #d4d4d8;
  background: transparent;
  border: 1px solid transparent;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
}
.nav-pill.active {
  color: #fff;
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.35);
}

.user-chip {
  color: #f4f4f5;
  font-size: 0.85rem;
  font-weight: 650;
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
}

.eyebrow {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.05;
  margin: 0 0 0.85rem;
  letter-spacing: -0.03em;
}

h2 { margin: 0; font-size: 1.1rem; letter-spacing: -0.02em; }
h3 { margin: 0.35rem 0 0; font-size: 1rem; }

.lede {
  max-width: 40rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
  margin: 0;
}

.lede.tight { margin: 0; font-size: 0.98rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font-weight: 650;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.85rem; }

.btn-primary { background: #fff; color: #0b0b0c; }
.btn-primary:hover { filter: brightness(0.95); }

.btn-ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.05); }

.btn-danger {
  background: #dc2626;
  color: #fff;
  border-color: #f87171;
}
.btn-danger:hover { background: #b91c1c; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(8, 8, 10, 0.72);
  backdrop-filter: blur(8px);
}

.login-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(1.5rem, 6vh, 4rem) var(--page-pad) 2rem;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 26rem);
  gap: clamp(1.25rem, 3vw, 2.5rem);
  align-items: center;
}

.preview-card, .panel, .stat-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: calc(var(--radius) + 2px);
  backdrop-filter: blur(14px);
}

.login-card {
  padding: 1.35rem 1.25rem;
  display: grid;
  gap: 0.85rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.preview-head { display: flex; align-items: center; gap: 0.55rem; }
.preview-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--ok);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.55);
}
.preview-title {
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #d4d4d8;
}

.preview-list {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.preview-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.85rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.92rem;
}
.preview-list span { color: var(--muted); }
.preview-list strong { font-weight: 650; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

input, select {
  background: rgba(15, 15, 18, 0.85);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  color: var(--text);
  padding: 0.65rem 0.75rem;
}

input:focus, select:focus {
  outline: 2px solid rgba(59, 130, 246, 0.45);
  outline-offset: 1px;
}

.form-msg { min-height: 1.25rem; margin: 0; font-size: 0.9rem; color: var(--muted); }
.form-msg.ok { color: var(--ok); }
.form-msg.err { color: #fca5a5; }

.app-main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0.25rem var(--page-pad) 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

#view-activity,
#view-commands,
#view-users {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.head-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}
.head-row h1 { margin-bottom: 0.35rem; }

.quota-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.15rem;
}

.stat-card { padding: 1rem 1.1rem; border-radius: var(--radius); }
.stat-label {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.stat-value {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.panel {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-radius: var(--radius);
}

.meta { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

.command-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.command-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 1rem;
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.command-card p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.command-card .btn { margin-top: auto; }
.command-card-wide { grid-column: 1 / -1; }
.command-card-danger { border-color: rgba(239, 68, 68, 0.28); }

.command-form { display: grid; gap: 0.65rem; width: 100%; }
.command-form > .btn { justify-self: start; }
.command-form-inline { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.grow { min-width: 0; }

.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.45rem;
  border-radius: 0.4rem;
  background: var(--accent-soft);
  color: #93c5fd;
}
.tag.bad { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.tag.ok { background: rgba(34, 197, 94, 0.15); color: #86efac; }

.action-result {
  padding: 0.9rem 1rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
  display: grid;
  gap: 0.45rem;
}
.action-result.err {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.1);
}
.action-result p { margin: 0; }
.revert-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}
.revert-id {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}
.raw-response {
  margin: 0;
  max-height: 10rem;
  overflow: auto;
  font-size: 0.78rem;
  color: #d4d4d8;
  white-space: pre-wrap;
  word-break: break-word;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.25rem;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.mode-switch {
  display: flex;
  padding: 0.2rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}
.mode-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-weight: 650;
  font-size: 0.82rem;
}
.mode-btn.active { background: rgba(59, 130, 246, 0.28); color: #fff; }

.table-wrap { overflow-x: auto; }
.board {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.board th, .board td {
  text-align: left;
  padding: 0.65rem 0.35rem;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
}
.board th {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 650;
  border-top: 0;
}
.board th:first-child, .board td:first-child { width: 4.5rem; }
.board th:last-child, .board td:last-child { text-align: right; }
.user-link {
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
  font-weight: 650;
}
.user-link:hover { color: #93c5fd; }

.pager { display: flex; align-items: center; gap: 0.65rem; }

.division-grid {
  display: flex;
  align-items: stretch;
  gap: 0.85rem;
}
.division-card {
  padding: 0.85rem 0.9rem;
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.division-card h3 { font-size: 0.92rem; line-height: 1.35; margin-bottom: 0.45rem; }
.division-card p { margin: 0; color: var(--muted); font-size: 0.84rem; }
.division-card strong { color: #fff; font-weight: 650; }
.division-card.is-zero { opacity: 0.72; }

#lookup-result {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.15rem;
  padding-top: 0.95rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.lookup-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.lookup-head h3 { margin: 0; font-size: 1.15rem; }
.lookup-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}
.lookup-total strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.lookup-total span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.lookup-kicker {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lookup-shifts {
  list-style: none;
  margin: 0;
  padding: 0;
}
.lookup-shifts li {
  display: grid;
  gap: 0.2rem;
  padding: 0.7rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.lookup-shifts li:first-child { border-top: 0; padding-top: 0; }

.user-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}
.user-stat {
  padding: 0.7rem 0.75rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.user-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.shift-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
  max-height: 22rem;
  overflow: auto;
}
.shift-list li {
  display: grid;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: rgba(16, 16, 20, 0.55);
  font-size: 0.88rem;
}
.shift-top { display: flex; justify-content: space-between; gap: 0.75rem; align-items: center; }

.division-card {
  flex: 1 1 0;
  min-width: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.division-card:hover { border-color: rgba(59, 130, 246, 0.45); }
.division-card.active {
  opacity: 1;
  border-color: rgba(59, 130, 246, 0.7);
  background: rgba(59, 130, 246, 0.16);
}
.lock-card { align-items: flex-start; max-width: 36rem; }
.account-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; }
.account-actions { display: flex; justify-content: flex-end; gap: 0.4rem; white-space: nowrap; }
.issued {
  padding: 0.85rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
  display: grid;
  gap: 0.45rem;
}
.signin-dialog { max-width: min(92vw, 26rem); }

.confirm-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #111827;
  color: var(--text);
  padding: 0;
  max-width: min(92vw, 28rem);
}
.confirm-dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
.confirm-dialog-inner { padding: 1.15rem 1.2rem; display: grid; gap: 0.75rem; }
.confirm-dialog-inner h3 { margin: 0; }
.confirm-dialog-inner p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.cta-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; }

@media (max-width: 860px) {
  .login-shell, .panel-grid, .command-grid, .quota-summary { grid-template-columns: 1fr; }
  .command-card-wide { grid-column: auto; }
  .command-form-inline { grid-template-columns: 1fr; }
  .user-stats { grid-template-columns: 1fr; }
  .account-form { grid-template-columns: 1fr; }
  .division-grid { overflow-x: auto; }
  .division-card { flex: 1 0 9.25rem; }
  h1 { font-size: 2.15rem; }
}
