:root {
  --ink: #0c1f28;
  --ink-soft: #3d5560;
  --muted: #6b808a;
  --line: #d5e2e6;
  --paper: #f3f7f8;
  --white: #ffffff;
  --teal: #0d6b6d;
  --teal-deep: #084b4d;
  --mint: #dff3f1;
  --mint-2: #c8e8e4;
  --coral: #e06b4f;
  --coral-soft: #f8e4de;
  --gold: #c4922a;
  --ok: #1f8a5b;
  --warn: #b7791f;
  --side: 268px;
  --radius: 14px;
  --font: "Sora", system-ui, sans-serif;
  --display: "Syne", "Sora", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
}

body {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-exit {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--teal-deep);
  color: #e8f7f5;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  z-index: 30;
}
.preview-exit:hover { background: #06393b; }
.in-frame .preview-exit,
.in-frame .side-back { display: none; }

.app {
  display: grid;
  grid-template-columns: var(--side) 1fr;
  flex: 1;
  min-height: 0;
  position: relative;
}

.app::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 480px at 12% -10%, #c8ebe7 0%, transparent 55%),
    radial-gradient(700px 420px at 100% 0%, #f6ddd4 0%, transparent 50%),
    linear-gradient(180deg, #eef5f6 0%, var(--paper) 40%);
  z-index: 0;
}

.sidebar,
.main {
  position: relative;
  z-index: 1;
}

/* ——— Sidebar ——— */
.sidebar {
  background: rgba(255, 255, 255, 0.82);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  animation: slideIn .55s ease both;
}

@keyframes slideIn {
  from { transform: translateX(-18px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 8px 16px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--teal-deep);
  color: #e8f7f5;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-mark svg { width: 22px; height: 22px; }

.brand h1 {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand p {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.role-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--mint);
  padding: 4px;
  border-radius: 12px;
  margin: 0 4px 14px;
}

.role-switch button {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 8px 4px;
  border-radius: 9px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .2s, color .2s, transform .2s;
}

.role-switch button.active {
  background: var(--white);
  color: var(--teal-deep);
  box-shadow: 0 0 0 1px rgba(13, 107, 109, 0.12);
}

.nav-scroll {
  flex: 1;
  overflow: auto;
  padding-right: 2px;
}

.nav-group {
  margin-bottom: 12px;
}

.nav-group h3 {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 6px 10px 6px;
  font-weight: 600;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .18s, color .18s, transform .18s;
}

.nav-btn:hover {
  background: rgba(13, 107, 109, 0.06);
  color: var(--ink);
}

.nav-btn.active {
  background: var(--teal);
  color: #fff;
}

.nav-btn .ico {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(13, 107, 109, 0.1);
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}

.nav-btn.active .ico {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.nav-btn.hidden { display: none; }

.side-foot {
  margin-top: 8px;
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--teal-deep), #0a6366);
  color: #dff6f4;
}

.side-foot strong {
  display: block;
  font-family: var(--display);
  font-size: 0.92rem;
  margin-bottom: 2px;
}

.side-foot span {
  font-size: 0.72rem;
  opacity: 0.8;
}

.side-back {
  display: inline-block;
  margin-top: 10px;
  color: #e8f7f5;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  opacity: 0.95;
}
.side-back:hover { text-decoration: underline; }

/* ——— Main ——— */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px 10px;
  animation: fadeUp .5s ease .08s both;
}

@keyframes fadeUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.topbar h2 {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.topbar .sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 2px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search {
  width: min(280px, 36vw);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  outline: none;
}

.search:focus {
  border-color: var(--teal);
}

.btn {
  border: 0;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .18s, background .18s, opacity .18s;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary {
  background: var(--coral);
  color: #fff;
}

.btn-ghost {
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line);
}

.workspace {
  flex: 1;
  overflow: auto;
  padding: 8px 28px 28px;
}

.panel {
  display: none;
  animation: fadeUp .4s ease both;
}

.panel.active { display: block; }

/* Dashboard */
.hero-strip {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.hero-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}

.hero-card.live {
  background: linear-gradient(135deg, #0a4f52 0%, #0d6b6d 55%, #14888a 100%);
  color: #ecfaf8;
  border: 0;
}

.hero-card.live::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  animation: pulse 3.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
}

.eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
  font-weight: 600;
  margin-bottom: 8px;
}

.hero-card h3 {
  font-family: var(--display);
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 8px;
  max-width: 18ch;
}

.hero-card p {
  font-size: 0.9rem;
  opacity: 0.88;
  max-width: 42ch;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}

.stat .label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat .value {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.stat .delta {
  font-size: 0.72rem;
  margin-top: 4px;
  color: var(--ok);
}

.split {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
}

.block {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.block-head h4 {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 11px 6px;
  border-bottom: 1px solid #e8f0f2;
  vertical-align: middle;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.pill.wait { background: #fff4d9; color: #8a6418; }
.pill.live { background: var(--mint); color: var(--teal-deep); }
.pill.done { background: #e4f5ec; color: var(--ok); }
.pill.alert { background: var(--coral-soft); color: #a94430; }

.queue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #e8f0f2;
  gap: 10px;
}

.queue-item:last-child { border-bottom: 0; }

.queue-item .token {
  font-family: var(--display);
  font-weight: 800;
  color: var(--teal);
  min-width: 42px;
}

.queue-item .meta { flex: 1; min-width: 0; }
.queue-item .meta strong { display: block; font-size: 0.88rem; }
.queue-item .meta span { font-size: 0.75rem; color: var(--muted); }

/* Module generic layout */
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.mod-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  min-height: 120px;
}

.mod-card h4 {
  font-family: var(--display);
  font-size: 1rem;
  margin-bottom: 6px;
}

.mod-card p {
  font-size: 0.84rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.mod-card .tag {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--teal);
  background: var(--mint);
  padding: 4px 8px;
  border-radius: 999px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.chip.on {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.display-board {
  background: #062e31;
  color: #e7f8f6;
  border-radius: 18px;
  padding: 28px;
  min-height: 360px;
  display: grid;
  place-items: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.display-board::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(224, 107, 79, 0.25), transparent 35%),
    radial-gradient(circle at 80% 70%, rgba(45, 180, 170, 0.25), transparent 40%);
}

.display-board .inner { position: relative; z-index: 1; }

.display-board .now {
  font-family: var(--display);
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 8px 0 12px;
}

.display-board .room {
  font-size: 1.1rem;
  opacity: 0.85;
}

.display-board .next {
  margin-top: 22px;
  font-size: 0.9rem;
  opacity: 0.7;
}

.empty-note {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hero-strip, .split, .module-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, var(--side));
    z-index: 20;
    transform: translateX(-105%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: none; }
  .menu-fab {
    display: inline-flex !important;
  }
}

.menu-fab {
  display: none;
  border: 0;
  background: var(--teal);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
