* {
  box-sizing: border-box;
}

:root {
  /* Palette LMDG (site public) — primaire = ink (foncé) */
  --paper: oklch(0.99 0.004 220);
  --ink: oklch(0.24 0.04 235);
  --sky: oklch(0.78 0.08 215);
  --primary: var(--ink);
  --primary-dark: var(--ink);
  --bg: var(--paper);
  --muted: oklch(0.5 0.03 230);
  --muted-strong: oklch(0.38 0.03 232);
  --card-bg: oklch(0.96 0.008 222);
  --card-border: oklch(0.88 0.01 225);
  --progress-track: oklch(0.92 0.01 220);
  --boarding: oklch(0.7 0.14 165);
  --font: "Archivo", "Helvetica Neue", sans-serif;

  --sidebar-pad: clamp(20px, 3.2vw, 56px);
  --main-pad-x: clamp(16px, 4vw, 80px);
  --main-pad-y: clamp(16px, 2.5vh, 28px);
  --gap: clamp(8px, 1.4vh, 16px);

  --fs-brand-title: clamp(1.25rem, 2.2vw, 2.375rem);
  --fs-brand-sub: clamp(0.95rem, 1.4vw, 1.5rem);
  --fs-label: clamp(0.75rem, 1.2vw, 1.375rem);
  --fs-route: clamp(1.75rem, 3.4vw, 3.75rem);
  --fs-depart: clamp(2.75rem, 7vw, 6.75rem);
  --fs-status: clamp(0.7rem, 1.15vw, 1.4375rem);
  --fs-clock: clamp(1.75rem, 4vw, 4.125rem);
  --fs-date: clamp(0.9rem, 1.3vw, 1.5rem);
  --fs-passages: clamp(1rem, 1.8vw, 1.875rem);
  --fs-odometer: clamp(4.5rem, 14vmin, 14.7rem);
  --fs-quota: clamp(1rem, 1.6vw, 1.75rem);
  --fs-stat-label: clamp(0.7rem, 1vw, 1.1875rem);
  --fs-stat-value: clamp(1.75rem, 3.2vw, 3.5rem);
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  font-family: var(--font);
  color: var(--primary-dark);
  overflow: hidden;
}

.screen {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  display: flex;
  overflow: hidden;
  background: var(--bg);
}

/* ——— Sidebar ——— */

.sidebar {
  width: clamp(280px, 36vw, 620px);
  flex: none;
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: var(--sidebar-pad);
  min-height: 0;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.5vw, 24px);
  min-width: 0;
}

.brand-logo {
  height: clamp(56px, 7vw, 104px);
  width: clamp(56px, 7vw, 104px);
  object-fit: contain;
  flex: none;
  border-radius: 22%;
  background: #fff;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: var(--fs-brand-title);
  font-weight: 800;
  line-height: 1.1;
}

.brand-subtitle {
  font-size: var(--fs-brand-sub);
  font-weight: 500;
  opacity: 0.85;
  margin-top: 2px;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.25);
  margin: clamp(16px, 3.5vh, 44px) 0;
  flex: none;
}

.label-caps {
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.7;
}

.route-name {
  font-size: var(--fs-route);
  font-weight: 800;
  line-height: 1.15;
  margin-top: 0.15em;
  word-break: break-word;
}

.depart-label {
  margin-top: clamp(16px, 3.5vh, 40px);
}

.depart-time {
  font-size: var(--fs-depart);
  font-weight: 900;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.status-wrap {
  margin-top: clamp(12px, 3vh, 36px);
  min-height: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: clamp(8px, 0.9vw, 14px);
  max-width: 100%;
  padding: clamp(8px, 1vh, 12px) clamp(14px, 1.5vw, 26px);
  border-radius: 999px;
  font-size: var(--fs-status);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
  white-space: normal;
  hyphens: auto;
}

.status-pill.is-hidden {
  display: none;
}

.status-boarding {
  background: var(--boarding);
  color: #fff;
}

.status-waiting {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
}

.status-dot {
  width: 0.55em;
  height: 0.55em;
  min-width: 8px;
  min-height: 8px;
  border-radius: 50%;
  background: #fff;
  flex: none;
  animation: pulse 1.6s ease-in-out infinite;
}

.status-dot-muted {
  background: rgba(255, 255, 255, 0.6);
  animation: none;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.sidebar-spacer {
  flex: 1 1 auto;
  min-height: clamp(8px, 2vh, 24px);
}

.flag {
  height: clamp(40px, 6vh, 84px);
  width: auto;
  object-fit: contain;
  margin-bottom: clamp(12px, 2.5vh, 36px);
  align-self: flex-start;
  flex: none;
}

.clock-time {
  font-size: var(--fs-clock);
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.clock-date {
  font-size: var(--fs-date);
  opacity: 0.85;
  text-transform: capitalize;
  margin-top: 0.2em;
  flex: none;
}

.version-info {
  margin-top: clamp(8px, 1.2vh, 18px);
  font-size: clamp(0.7rem, 0.9vw, 0.8125rem);
  font-weight: 600;
  opacity: 0.45;
  flex: none;
}

.version-info .api-version {
  opacity: 0.85;
}

/* ——— Main panel ——— */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  padding: var(--main-pad-y) var(--main-pad-x);
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.logo-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(1400px, 110%);
  aspect-ratio: 1;
  opacity: 0.07;
  filter: blur(12px);
  pointer-events: none;
  z-index: 0;
}

.logo-watermark::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--primary);
  -webkit-mask: url("/counter/assets/lmdg.svg") no-repeat center / contain;
  mask: url("/counter/assets/lmdg.svg") no-repeat center / contain;
}

.pad-logo,
.passages-label,
.odometer,
.quota-block,
.stats-grid,
.error-box {
  position: relative;
  z-index: 1;
}

.pad-logo {
  height: clamp(52px, 9vh, 110px);
  width: auto;
  max-width: 70%;
  object-fit: contain;
  flex: none;
}

.passages-label {
  font-size: var(--fs-passages);
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  color: oklch(0.5 0.08 215);
  font-weight: 700;
  text-transform: uppercase;
  flex: none;
}

.odometer {
  display: flex;
  justify-content: center;
  font-size: var(--fs-odometer);
  font-weight: 900;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  margin: -0.05em 0;
  line-height: 1;
  min-height: 1em;
  flex: none;
}

.odometer-digit {
  height: 1em;
  overflow: hidden;
  line-height: 1;
  width: 0.62em;
  text-align: center;
}

.odometer-strip {
  transition: transform 750ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.odometer-strip > div {
  height: 1em;
  line-height: 1;
  text-align: center;
}

.quota-block {
  width: 100%;
  max-width: min(1120px, 100%);
  flex: none;
}

.quota-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: var(--fs-quota);
  font-weight: 600;
  color: var(--muted-strong);
  margin-bottom: 0.4em;
}

.quota-total {
  color: var(--primary);
  font-weight: 800;
}

.quota-pct {
  font-variant-numeric: tabular-nums;
  flex: none;
}

.progress {
  height: clamp(14px, 2.5vh, 32px);
  border-radius: 999px;
  background: var(--progress-track);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.8s ease;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(10px, 1.4vw, 22px);
  width: 100%;
  max-width: min(1120px, 100%);
  margin-top: clamp(4px, 1vh, 16px);
  flex: none;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: clamp(12px, 1.2vw, 18px);
  padding: clamp(10px, 1.4vh, 18px) clamp(12px, 1.6vw, 28px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat-card-goreen {
  background: oklch(0.95 0.03 215);
  border-color: var(--sky);
}

.stat-card-goreen .stat-label {
  color: oklch(0.42 0.08 215);
}

.stat-card-goreen .stat-value {
  color: oklch(0.38 0.1 215);
}

.stat-card-accent {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.stat-label {
  font-size: var(--fs-stat-label);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-card-accent .stat-label {
  color: #fff;
  opacity: 0.85;
}

.stat-value {
  font-size: var(--fs-stat-value);
  font-weight: 800;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-card-accent .stat-value {
  color: #fff;
}

.error-box {
  display: none;
  margin-top: 4px;
  width: 100%;
  max-width: min(1120px, 100%);
  padding: clamp(10px, 1.2vh, 16px) clamp(14px, 1.4vw, 22px);
  border-radius: 14px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: #991b1b;
  font-weight: 700;
  font-size: clamp(0.8rem, 1.2vw, 1.125rem);
  flex: none;
}

/* ——— Compact desktop (narrow or short) ——— */

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-height: 800px) {
  :root {
    --fs-odometer: clamp(3.5rem, 12vmin, 9rem);
    --fs-depart: clamp(2.25rem, 6vw, 4.5rem);
    --fs-route: clamp(1.5rem, 3vw, 2.75rem);
    --fs-clock: clamp(1.5rem, 3.5vw, 3rem);
    --fs-stat-value: clamp(1.5rem, 2.8vw, 2.5rem);
  }

  .sidebar-divider {
    margin: 12px 0;
  }

  .depart-label {
    margin-top: 12px;
  }

  .status-wrap {
    margin-top: 10px;
  }

  .flag {
    margin-bottom: 10px;
  }
}

@media (max-height: 640px) {
  :root {
    --fs-odometer: clamp(2.75rem, 10vmin, 6rem);
    --gap: 6px;
  }

  .pad-logo {
    height: 40px;
  }

  .flag {
    height: 32px;
    margin-bottom: 6px;
  }

  .version-info {
    display: none;
  }
}

/* ——— Stacked layout (tablet / mobile) ——— */

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .screen {
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    overflow: visible;
  }

  .sidebar-spacer {
    display: none;
  }

  .brand {
    flex-wrap: wrap;
  }

  .status-pill {
    white-space: normal;
  }

  .flag {
    margin: 20px 0 10px;
  }

  .main {
    overflow: visible;
    padding-bottom: 40px;
  }

  .logo-watermark {
    max-height: 60%;
  }

  .passages-label {
    letter-spacing: 0.35em;
    text-indent: 0.35em;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  :root {
    --sidebar-pad: 20px;
    --main-pad-x: 16px;
    --fs-odometer: clamp(3.5rem, 22vw, 6rem);
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-label {
    white-space: normal;
  }

  .quota-meta {
    flex-wrap: wrap;
  }
}

@media (max-width: 400px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
