/* ============================================================
   LEGO SIMULATION STUDIO — Design System
   Dark, high-contrast, projection-friendly
   ============================================================ */

:root {
  /* Colors */
  --bg:          #0d0f18;
  --surface:     #161927;
  --card:        #1e2235;
  --card-hover:  #252a42;
  --border:      rgba(255,255,255,0.07);
  --border-md:   rgba(255,255,255,0.12);
  --border-str:  rgba(255,255,255,0.20);

  --primary:        #7c6bff;
  --primary-light:  #a09eff;
  --primary-dark:   #5c4adf;
  --primary-glow:   rgba(124,107,255,0.25);
  --primary-bg:     rgba(124,107,255,0.12);

  --success:        #4ecca3;
  --success-bg:     rgba(78,204,163,0.12);
  --warning:        #ffd166;
  --warning-bg:     rgba(255,209,102,0.12);
  --danger:         #ef476f;
  --danger-bg:      rgba(239,71,111,0.12);
  --info:           #06bef7;
  --info-bg:        rgba(6,190,247,0.12);
  --purple:         #c77dff;
  --purple-bg:      rgba(199,125,255,0.12);

  --text:        #f0f2fc;
  --text-2:      #a0a8c8;
  --text-3:      #60698a;
  --text-inv:    #0d0f18;

  /* Spacing */
  --sidebar-w:   220px;
  --gap:         16px;
  --gap-lg:      24px;

  /* Radius */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* Shadows */
  --sh-sm: 0 2px 8px rgba(0,0,0,0.35);
  --sh:    0 4px 20px rgba(0,0,0,0.45);
  --sh-lg: 0 8px 40px rgba(0,0,0,0.55);
  --sh-p:  0 4px 24px rgba(124,107,255,0.35);

  /* Transitions */
  --tr: 0.18s ease;
  --tr-slow: 0.35s ease;

  /* Typography */
  --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  --font-mono: 'Consolas', 'JetBrains Mono', 'Monaco', monospace;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }
input, textarea, select { font-family: inherit; color: var(--text); }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary); color: #fff; }

/* ============================================================
   APP SHELL
   ============================================================ */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-icon {
  font-size: 26px;
  line-height: 1;
}
.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--primary-light);
  line-height: 1.1;
}
.brand-sub {
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Nav */
.nav-menu {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--tr), color var(--tr);
  position: relative;
}
.nav-item:hover {
  background: var(--card);
  color: var(--text);
}
.nav-item.active {
  background: var(--primary-bg);
  color: var(--primary-light);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  opacity: 0.8;
}
.nav-label {
  flex: 1;
}

/* Sidebar status */
.sidebar-status {
  padding: 14px 14px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.status-phase {
  display: flex;
  flex-direction: column;
  margin-bottom: 6px;
}
.status-label {
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--text-3);
  text-transform: uppercase;
}
.status-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--warning);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-timer {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--success);
  letter-spacing: 0.05em;
  line-height: 1.2;
}
.status-session {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
#main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.view-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--gap-lg);
  scrollbar-width: thin;
  scrollbar-color: var(--card-hover) transparent;
}
.view-container::-webkit-scrollbar { width: 6px; }
.view-container::-webkit-scrollbar-track { background: transparent; }
.view-container::-webkit-scrollbar-thumb { background: var(--card-hover); border-radius: 3px; }

/* ============================================================
   VIEW HEADER
   ============================================================ */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap-lg);
  gap: var(--gap);
}
.view-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.view-title small {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-3);
  margin-left: 8px;
}
.view-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--gap-lg);
}
.card-sm { padding: var(--gap); }
.card-title {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 12px;
  font-weight: 600;
}
.card-label {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--gap); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--tr);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--sh-p); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }

.btn-success { background: var(--success); color: var(--text-inv); }
.btn-success:hover:not(:disabled) { background: #3ab88f; }

.btn-warning { background: var(--warning); color: var(--text-inv); }
.btn-warning:hover:not(:disabled) { background: #f0c040; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #d93060; }

.btn-info { background: var(--info); color: var(--text-inv); }
.btn-info:hover:not(:disabled) { background: #05a8da; }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-md);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--card-hover);
  color: var(--text);
  border-color: var(--border-str);
}

.btn-icon {
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  transition: all var(--tr);
  font-size: 14px;
}
.btn-icon:hover { background: var(--card); color: var(--text); border-color: var(--border-md); }

.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xl {
  padding: 14px 32px;
  font-size: 16px;
  border-radius: var(--r);
  letter-spacing: 0.02em;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-primary { background: var(--primary-bg); color: var(--primary-light); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-purple  { background: var(--purple-bg);  color: var(--purple); }
.badge-neutral { background: rgba(255,255,255,0.07); color: var(--text-2); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  outline: none;
}
.form-control::placeholder { color: var(--text-3); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--gap); }
.form-hint { font-size: 11px; color: var(--text-3); }
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,0.02); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
  animation: fadeIn var(--tr);
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--card);
  border: 1px solid var(--border-md);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--sh-lg);
  animation: slideUp 0.25s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--card-hover) transparent;
}
.modal-box.modal-lg { max-width: 800px; }
.modal-box.modal-xl { max-width: 1000px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-md);
  color: var(--text-2);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--tr);
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: var(--gap); }
.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--card);
  border: 1px solid var(--border-md);
  border-radius: var(--r);
  box-shadow: var(--sh-lg);
  font-size: 13px;
  font-weight: 500;
  max-width: 360px;
  animation: slideInRight 0.25s ease;
  border-left: 3px solid var(--primary);
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-error   { border-left-color: var(--danger); }
.toast.toast-info    { border-left-color: var(--info); }
.toast-icon { font-size: 16px; }
.toast-msg  { flex: 1; line-height: 1.4; }
.toast-dismiss { background: none; border: none; color: var(--text-3); font-size: 18px; padding: 0; line-height: 1; }
.toast.fade-out { animation: fadeOut 0.3s ease forwards; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 340px 1fr 320px;
  grid-template-rows: auto 1fr;
  gap: var(--gap);
  height: calc(100vh - var(--gap-lg) * 2);
  min-height: 0;
}

/* Phase panel */
.phase-panel {
  grid-column: 1;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.phase-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.phase-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--info));
}
.phase-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  background: var(--primary-bg);
  border: 1px solid var(--primary);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary-light);
  margin-bottom: 14px;
}
.phase-num {
  font-size: 44px;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}
.phase-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-light);
  margin-bottom: 8px;
}
.phase-objective {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 16px;
}
.phase-duration {
  font-size: 12px;
  color: var(--text-3);
}

.phase-nav {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}

/* Timer */
.timer-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  text-align: center;
}
.timer-display {
  font-family: var(--font-mono);
  font-size: 52px;
  font-weight: 900;
  color: var(--success);
  letter-spacing: 0.04em;
  line-height: 1;
  margin-bottom: 14px;
  text-shadow: 0 0 30px rgba(78,204,163,0.4);
  transition: color var(--tr);
}
.timer-display.paused { color: var(--warning); text-shadow: 0 0 30px rgba(255,209,102,0.4); }
.timer-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Scoreboard */
.scoreboard-panel {
  grid-column: 2;
  grid-row: 1 / 3;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.scoreboard-card {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.scoreboard-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.scoreboard-title {
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
}
.scoreboard-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.team-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  transition: background var(--tr);
  border-bottom: 1px solid var(--border);
}
.team-row:last-child { border-bottom: none; }
.team-row:hover { background: rgba(255,255,255,0.02); }
.team-rank {
  font-size: 18px;
  font-weight: 900;
  color: var(--text-3);
  text-align: center;
}
.team-rank.rank-1 { color: var(--warning); }
.team-rank.rank-2 { color: var(--text-2); }
.team-rank.rank-3 { color: #cd7f32; }

.team-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.team-info { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.team-name-sb {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.team-members-count { font-size: 11px; color: var(--text-3); }
.score-col { text-align: right; }
.score-num {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}
.score-label { font-size: 10px; color: var(--text-3); display: block; }
.score-total {
  font-size: 22px;
  font-weight: 900;
  color: var(--primary-light);
  font-family: var(--font-mono);
}

.score-bar-wrap {
  grid-column: 1 / -1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: -4px 0 2px;
  overflow: hidden;
}
.score-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* Events recent panel */
.events-panel {
  grid-column: 3;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  overflow: hidden;
}
.events-recent-card {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.events-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--card-hover) transparent;
}
.event-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: default;
  transition: background var(--tr);
}
.event-item:last-child { border-bottom: none; }
.event-item:hover { background: rgba(255,255,255,0.02); }
.event-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.event-sev-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.event-title-sb {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  line-height: 1.3;
}
.event-time { font-size: 10px; color: var(--text-3); white-space: nowrap; }
.event-desc-sb {
  font-size: 11px;
  color: var(--text-2);
  padding-left: 16px;
  line-height: 1.4;
}

/* Quick journal form */
.quick-journal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  flex-shrink: 0;
}

/* ============================================================
   TEAMS PAGE
   ============================================================ */
.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap);
}
.team-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: box-shadow var(--tr), border-color var(--tr);
}
.team-card:hover { box-shadow: var(--sh); border-color: var(--border-str); }
.team-card-banner {
  height: 6px;
}
.team-card-body { padding: 18px; }
.team-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.team-card-name {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}
.team-card-actions { display: flex; gap: 6px; }

.team-scores-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.score-tile {
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 8px;
  text-align: center;
}
.score-tile-val {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 2px;
}
.score-tile-lbl {
  font-size: 9px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.team-members-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--surface);
  border-radius: var(--r-sm);
}
.member-name { font-size: 13px; font-weight: 500; }
.member-role { font-size: 11px; color: var(--text-3); }

/* ============================================================
   EVENTS PAGE
   ============================================================ */
.event-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow var(--tr);
}
.event-card:hover { box-shadow: var(--sh); }
.event-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.event-card-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}
.event-card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.event-card-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}
.event-card-impact {
  font-size: 12px;
  color: var(--warning);
  font-style: italic;
  padding: 8px 12px;
  background: var(--warning-bg);
  border-radius: var(--r-sm);
  border-left: 3px solid var(--warning);
}
.event-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.event-projected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.event-random-card {
  background: linear-gradient(135deg, var(--primary-bg), var(--purple-bg));
  border: 1px solid var(--primary);
  border-radius: var(--r-lg);
  padding: 24px;
  text-align: center;
  margin-bottom: var(--gap);
}

/* ============================================================
   DISTRICTS PAGE
   ============================================================ */
.district-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: box-shadow var(--tr);
}
.district-card:hover { box-shadow: var(--sh); }
.district-banner {
  height: 8px;
}
.district-card-body { padding: 18px; }
.district-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.district-name { font-size: 18px; font-weight: 800; }
.district-plate { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.district-desc { font-size: 13px; color: var(--text-2); margin-bottom: 12px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-thumb {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  transition: transform var(--tr);
  overflow: hidden;
}
.photo-thumb:hover { transform: scale(1.03); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Photo upload zone */
.photo-drop-zone {
  border: 2px dashed var(--border-md);
  border-radius: var(--r);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--tr);
  background: var(--surface);
}
.photo-drop-zone:hover, .photo-drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.photo-drop-zone-icon { font-size: 32px; margin-bottom: 8px; }
.photo-drop-zone-text { font-size: 13px; color: var(--text-2); }

/* Photo timeline */
.photo-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.photo-timeline-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.photo-timeline-img {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.photo-timeline-img img { width: 100%; height: 100%; object-fit: cover; }
.photo-timeline-meta { flex: 1; }
.photo-timeline-phase { font-size: 11px; color: var(--primary-light); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.photo-timeline-comment { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.photo-timeline-date { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ============================================================
   RULES PAGE
   ============================================================ */
.rules-category-section { margin-bottom: var(--gap-lg); }
.rules-category-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  font-weight: 700;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.rule-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 8px;
  transition: all var(--tr);
}
.rule-item:hover { border-color: var(--border-md); }
.rule-item.inactive { opacity: 0.5; }
.rule-color-chip {
  width: 16px;
  min-width: 16px;
  height: 16px;
  border-radius: 4px;
  margin-top: 2px;
}
.rule-content { flex: 1; }
.rule-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rule-desc { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.rule-checkpoints {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.checkpoint-chip {
  font-size: 10px;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 999px;
  color: var(--text-2);
}
.rule-actions { display: flex; gap: 6px; align-items: flex-start; }

/* ============================================================
   JOURNAL PAGE
   ============================================================ */
.journal-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--gap);
  height: calc(100vh - var(--gap-lg) * 2 - 60px);
}
.journal-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  scrollbar-width: thin;
  scrollbar-color: var(--card-hover) transparent;
}
.journal-entry {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--tr);
}
.journal-entry:last-child { border-bottom: none; }
.journal-entry:hover { background: rgba(255,255,255,0.02); }
.journal-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.3;
  padding-top: 2px;
}
.journal-content { flex: 1; }
.journal-type-badge {
  display: inline-flex;
  margin-bottom: 6px;
}
.journal-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.journal-team-tag {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

.journal-sidebar { display: flex; flex-direction: column; gap: var(--gap); }
.journal-form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--gap);
}

/* ============================================================
   ANALYSIS PAGE
   ============================================================ */
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; right: 0;
  width: 60px;
  height: 60px;
  opacity: 0.06;
  font-size: 60px;
  line-height: 1;
}
.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  font-weight: 600;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
  color: var(--text);
}
.stat-sub { font-size: 12px; color: var(--text-2); }

/* ============================================================
   ARCHIVES PAGE
   ============================================================ */
.archive-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--tr);
}
.archive-item:hover { border-color: var(--border-md); }
.archive-icon { font-size: 28px; flex-shrink: 0; }
.archive-info { flex: 1; }
.archive-name { font-size: 15px; font-weight: 700; margin-bottom: 3px; }
.archive-date { font-size: 12px; color: var(--text-3); }
.archive-meta { font-size: 12px; color: var(--text-2); }
.archive-actions { display: flex; gap: 6px; }

/* ============================================================
   UTILITIES
   ============================================================ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 6px; }
.gap { gap: var(--gap); }
.gap-lg { gap: var(--gap-lg); }
.mt-sm { margin-top: 8px; }
.mt { margin-top: var(--gap); }
.mt-lg { margin-top: var(--gap-lg); }
.mb-sm { margin-bottom: 8px; }
.mb { margin-bottom: var(--gap); }
.text-center { text-align: center; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.text-primary { color: var(--primary-light); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-state-sub { font-size: 13px; }

.separator {
  height: 1px;
  background: var(--border);
  margin: var(--gap) 0;
}

/* Severity colors */
.sev-faible    { color: var(--success); }
.sev-modere    { color: var(--warning); }
.sev-eleve     { color: var(--danger); }
.sev-critique  { color: #ff0040; }

.bg-sev-faible    { background: var(--success-bg); }
.bg-sev-modere    { background: var(--warning-bg); }
.bg-sev-eleve     { background: var(--danger-bg); }
.bg-sev-critique  { background: rgba(255,0,64,0.15); }

/* Color inputs */
.color-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-preview {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-md);
  flex-shrink: 0;
}
input[type=color] {
  width: 42px;
  height: 34px;
  padding: 2px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-md);
  background: var(--surface);
  cursor: pointer;
}

/* Chips / tags */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border-md);
  color: var(--text-2);
}
.chip-remove {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 14px;
  padding: 0;
  line-height: 1;
  cursor: pointer;
}

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--tr);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-2);
  top: 3px;
  left: 3px;
  transition: all var(--tr);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: #fff;
}

/* Scrollbar global */
* { scrollbar-width: thin; scrollbar-color: var(--card-hover) transparent; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.pulse { animation: pulse 1.5s ease infinite; }
.fade-in { animation: fadeIn 0.25s ease; }

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-3);
  font-size: 14px;
  gap: 10px;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Tab system */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface);
  padding: 4px;
  border-radius: var(--r);
  border: 1px solid var(--border);
}
.tab {
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--tr);
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--card); }
.tab.active { background: var(--card); color: var(--primary-light); }

/* Score edit input */
.score-input {
  width: 60px;
  text-align: center;
  padding: 4px 6px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
}

/* Projection mode banner */
.projected-event-banner {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  background: linear-gradient(90deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 500;
  box-shadow: 0 -4px 20px rgba(124,107,255,0.4);
  animation: slideUp 0.3s ease;
}
.projected-event-banner.hidden { display: none; }
.projected-label {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0.8;
}
.projected-title { font-size: 18px; font-weight: 800; }
.projected-desc { font-size: 13px; opacity: 0.85; flex: 1; }

/* Divider with label */
.divider-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin: var(--gap) 0;
}
.divider-label::before, .divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Scrollable area for modules */
.scroll-area {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--card-hover) transparent;
}

/* Info box */
.info-box {
  padding: 12px 16px;
  border-radius: var(--r);
  font-size: 13px;
  line-height: 1.5;
}
.info-box-primary { background: var(--primary-bg); border: 1px solid rgba(124,107,255,0.3); color: var(--primary-light); }
.info-box-warning { background: var(--warning-bg); border: 1px solid rgba(255,209,102,0.3); color: var(--warning); }
.info-box-success { background: var(--success-bg); border: 1px solid rgba(78,204,163,0.3); color: var(--success); }
.info-box-danger  { background: var(--danger-bg);  border: 1px solid rgba(239,71,111,0.3);  color: var(--danger); }

/* Responsive minimal */
@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 300px 1fr;
    grid-template-rows: auto auto auto;
  }
  .phase-panel { grid-column: 1; grid-row: 1; }
  .scoreboard-panel { grid-column: 2; grid-row: 1 / 3; }
  .events-panel { grid-column: 1; grid-row: 2; }
}

/* ============================================================
   AUTH OVERLAY & FORMS
   ============================================================ */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
  overflow-y: auto;
}
.auth-overlay.hidden { display: none; }

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border-md);
  border-radius: var(--r-xl);
  padding: 36px 40px;
  box-shadow: var(--sh-lg);
  animation: slideUp 0.3s ease;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo {
  font-size: 44px;
  margin-bottom: 10px;
}
.auth-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.auth-sub {
  font-size: 13px;
  color: var(--text-3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}

.auth-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.5;
  padding: 0;
}
.auth-eye:hover { opacity: 1; }

.auth-alert {
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  line-height: 1.5;
}
.auth-alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(78,204,163,0.3); }
.auth-alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(239,71,111,0.3); }
.auth-alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(255,209,102,0.3); }

.auth-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.auth-link {
  background: none;
  border: none;
  color: var(--primary-light);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth-link:hover { color: var(--text); }
.auth-sep { color: var(--text-3); }

.auth-dev-link {
  color: var(--warning);
  word-break: break-all;
  font-size: 12px;
}

/* ============================================================
   SIDEBAR USER BADGE
   ============================================================ */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-bg);
  border: 1px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--primary-light);
  flex-shrink: 0;
}
.user-info {
  flex: 1;
  overflow: hidden;
}
.user-name {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.user-role-badge {}

/* Read-only indicator for étudiants */
.readonly-notice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}

/* ============================================================
   PHASE 3 — ANALYSIS (local plate + AI)
   ============================================================ */

/* Analysis modal layout */
.analysis-modal { display: flex; flex-direction: column; gap: 16px; }
.analysis-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.analysis-tab-content { animation: fadeIn 0.2s ease; }

/* Local editor */
.local-editor { display: flex; flex-direction: column; gap: 16px; }
.local-editor-top {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.grid-config { display: flex; flex-direction: column; gap: 6px; min-width: 120px; }
.grid-size-inputs { display: flex; align-items: center; gap: 8px; }

/* Type palette */
.type-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}
.palette-btn {
  padding: 4px 10px;
  font-size: 11px;
  border: 1px solid;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background var(--tr), opacity var(--tr);
  opacity: 0.6;
}
.palette-btn:hover { opacity: 1; }
.palette-btn.active { opacity: 1; background: color-mix(in srgb, currentColor 15%, transparent); }

/* Plate grid */
#plate-grid-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface);
  padding: 4px;
}
.plate-grid {
  display: grid;
  gap: 2px;
  user-select: none;
  min-height: 200px;
}
.plate-cell {
  border: 1px solid;
  border-radius: 3px;
  min-height: 48px;
  cursor: crosshair;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.1s;
  font-size: 10px;
  font-weight: 700;
  overflow: hidden;
}
.plate-cell:hover { filter: brightness(1.4); }
.cell-label { pointer-events: none; opacity: 0.8; }

/* Occupancy bar */
.occupancy-bar-wrap { display: flex; align-items: center; gap: 10px; }
.occupancy-bar {
  flex: 1;
  height: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.occupancy-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.2s;
}
.occupancy-pct { font-size: 12px; font-weight: 700; color: var(--text-2); min-width: 36px; }

/* Infrastructure chips */
.infra-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.infra-chip {
  padding: 3px 10px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--tr);
  user-select: none;
}
.infra-chip:hover { border-color: var(--primary); color: var(--primary); }
.infra-chip.active { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }

/* AI status bar */
.ai-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  flex-wrap: wrap;
}

/* AI result */
.ai-result { display: flex; flex-direction: column; gap: 12px; }
.ai-result-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--r);
  border: 1px solid var(--border);
}
.ai-result-status {
  padding: 4px 14px;
  border: 2px solid;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ai-confidence {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.confidence-bar {
  flex: 1;
  height: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  min-width: 60px;
}
.confidence-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.ai-summary {
  padding: 12px 16px;
  background: var(--surface);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--r) var(--r) 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-2);
}

/* Compliance issues & suggested actions */
.compliance-issue,
.suggested-action {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.compliance-issue:last-child,
.suggested-action:last-child { border-bottom: none; }

/* badge-success */
.badge-success { color: var(--accent); border-color: var(--accent); }

/* ============================================================
   RESPONSIVE — MOBILE (≤ 768px)
   ============================================================ */

/* ---- Mobile header (hidden on desktop) ---- */
.mobile-header { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {

  /* Allow page to scroll on mobile */
  body { overflow: auto; height: auto; }

  /* App shell: stack vertically */
  #app {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  /* ---- Mobile top bar ---- */
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 150;
    flex-shrink: 0;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }
  .mobile-brand-icon { font-size: 22px; line-height: 1; }
  .mobile-brand-title {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--primary-light);
  }

  .mobile-status {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    overflow: hidden;
  }
  .mobile-phase-name {
    font-size: 11px;
    color: var(--warning);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .mobile-timer-pill {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 700;
    color: var(--success);
    letter-spacing: 0.04em;
  }

  /* Hamburger button */
  .btn-mobile-menu {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border-md);
    border-radius: var(--r-sm);
    flex-shrink: 0;
    width: 40px;
    height: 40px;
  }
  .btn-mobile-menu:hover { background: var(--card); }
  .hamburger-line {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-2);
    border-radius: 2px;
    transition: all 0.2s;
  }
  body.sidebar-open .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  body.sidebar-open .hamburger-line:nth-child(2) { opacity: 0; }
  body.sidebar-open .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* ---- Sidebar backdrop ---- */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(2px);
    z-index: 160;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: all;
  }

  /* ---- Sidebar as slide-in drawer ---- */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 85vw);
    min-width: 0;
    z-index: 170;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  body.sidebar-open #sidebar {
    transform: translateX(0);
    box-shadow: var(--sh-lg);
  }

  /* ---- Main content: full width ---- */
  #main-content {
    width: 100%;
    overflow: visible;
  }
  .view-container {
    padding: 16px;
    overflow: visible;
    height: auto;
  }

  /* ---- View header: stack ---- */
  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .view-title { font-size: 18px; }
  .view-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }

  /* ---- Grids: collapse ---- */
  .grid-2,
  .grid-3,
  .grid-4 { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: 1fr; }

  /* ---- Forms: collapse ---- */
  .form-row,
  .form-row-3 { grid-template-columns: 1fr; }

  /* ---- Dashboard: vertical stack ---- */
  .dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
    gap: 12px;
  }
  .phase-panel,
  .scoreboard-panel,
  .events-panel {
    grid-column: 1;
    grid-row: auto;
    overflow: visible;
  }
  .scoreboard-card,
  .events-recent-card {
    min-height: 300px;
  }
  .scoreboard-body,
  .events-list { max-height: 320px; }

  /* Timer on dashboard */
  .timer-display { font-size: 40px; }

  /* Phase number */
  .phase-num { font-size: 36px; }

  /* ---- Team row: simplified ---- */
  .team-row {
    grid-template-columns: 28px 1fr auto auto;
    gap: 8px;
    padding: 10px 14px;
  }
  .score-bar-wrap { grid-column: 1 / -1; }

  /* ---- Modals: bottom sheet style ---- */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-box,
  .modal-box.modal-lg,
  .modal-box.modal-xl {
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: slideUpMobile 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .modal-header { padding: 16px 18px 12px; }
  .modal-body   { padding: 14px 18px; }
  .modal-footer { padding: 12px 18px 20px; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; justify-content: center; }

  /* ---- Toasts: full width bottom ---- */
  .toast-container {
    bottom: 12px;
    left: 12px;
    right: 12px;
    align-items: stretch;
  }
  .toast { max-width: 100%; }

  /* ---- Cards ---- */
  .card { padding: 16px; }
  .card-sm { padding: 12px; }

  /* ---- Buttons: slightly larger tap targets ---- */
  .btn { min-height: 40px; }
  .btn-xl { padding: 12px 20px; font-size: 15px; }
  .btn-lg { padding: 10px 18px; font-size: 14px; }
  .btn-icon { padding: 10px; }

  /* ---- Tables: force scroll ---- */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ---- Analysis plate grid: smaller cells ---- */
  .plate-cell { min-height: 36px; }

  /* ---- Rule items ---- */
  .rule-item { flex-direction: column; align-items: flex-start; gap: 10px; }
  .rule-actions { width: 100%; justify-content: flex-end; }

  /* ---- District card header: wrap ---- */
  .district-card-header { flex-wrap: wrap; gap: 8px; }

  /* ---- Photo timeline ---- */
  .photo-timeline-item { flex-wrap: wrap; }

  /* ---- Auth card ---- */
  .auth-card { padding: 24px 18px; }

  /* ---- Compliance table: hide on very small ---- */
  @media (max-width: 480px) {
    .table th:nth-child(n+3),
    .table td:nth-child(n+3) { display: none; }
  }
}

/* Tablet: 769–1024px — sidebar visible, slight layout adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-w: 180px; }
  .view-container { padding: 18px; }
  .dashboard-grid {
    grid-template-columns: 280px 1fr 260px;
  }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
}

/* Keyframe for mobile modal */
@keyframes slideUpMobile {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
