:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #d9dce1;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warn-bg: #fffbeb;
  --warn-border: #fcd34d;
  --radius: 8px;
  font-size: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app-shell { display: flex; min-height: 100vh; }

nav#main-nav {
  width: 220px;
  flex-shrink: 0;
  background: #16213a;
  color: #cbd5e1;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
  transition: width 0.18s ease, padding 0.18s ease;
}
nav#main-nav.collapsed { width: 0; padding: 1rem 0; }

#main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
header#top-bar {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.6rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
header#top-bar .top-bar-title { font-weight: 700; font-size: 0.95rem; }
button.icon-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.4rem 0.65rem;
  font-size: 1rem;
  line-height: 1;
}
button.icon-btn:hover { background: #f1f3f5; }
nav#main-nav .brand {
  font-weight: 700;
  color: #fff;
  padding: 0 1.25rem 1rem;
  font-size: 1.05rem;
  border-bottom: 1px solid #2a3a5c;
  margin-bottom: 0.5rem;
}
nav#main-nav a {
  display: block;
  padding: 0.65rem 1.25rem;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.92rem;
}
nav#main-nav a:hover { background: #1e2c4a; color: #fff; }
nav#main-nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
nav#main-nav .nav-footer {
  margin-top: auto;
  padding: 0.75rem 1.25rem;
  font-size: 0.78rem;
  color: #8391ab;
  border-top: 1px solid #2a3a5c;
}

main#view {
  flex: 1;
  padding: 1.75rem 2rem;
  max-width: 1200px;
}

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.75rem; }
p.subtitle { color: var(--muted); margin-top: -0.5rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.field input[readonly] { background: #f3f4f6; color: var(--muted); cursor: not-allowed; }

.pin-field-wrap { position: relative; }
.pin-field-wrap input { width: 100%; padding-right: 2.4rem; }
.pin-eye-btn {
  position: absolute; right: 0.3rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 0.2rem 0.35rem; font-size: 1rem;
  color: var(--muted); cursor: pointer; line-height: 1;
}
.pin-eye-btn:hover { color: var(--text); }

/* ---- elegant native selects (small fixed option lists) ---- */
select.select-elegant {
  appearance: none;
  -webkit-appearance: none;
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.19l3.71-3.96a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E") no-repeat right 0.6rem center / 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
select.select-elegant:hover { border-color: var(--accent); }
select.select-elegant:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---- cockpit color accents ---- */
.stat-card.cockpit-blue { border-left-color: #2563eb; }
.stat-card.cockpit-purple { border-left-color: #7c3aed; }
.stat-card.cockpit-teal { border-left-color: #0d9488; }
.stat-card.cockpit-indigo { border-left-color: #4f46e5; }
.stat-card.cockpit-amber { border-left-color: #d97706; }
.stat-card.cockpit-green { border-left-color: #16a34a; }
.stat-card.cockpit-pink { border-left-color: #db2777; }

button, .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
}
button:hover, .btn:hover { background: var(--accent-dark); }
button.secondary, .btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
button.secondary:hover, .btn.secondary:hover { background: #f1f3f5; }
button.danger { background: var(--danger); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table th, table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; }
table th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }
table tbody tr:hover { background: #f8f9fb; }
.table-scroll { overflow-x: auto; max-height: 520px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.table-scroll table th { position: sticky; top: 0; background: #fff; }

.banner { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.banner.success { background: var(--success-bg); color: #14532d; border: 1px solid #bbf7d0; }
.banner.error { background: var(--danger-bg); color: #7f1d1d; border: 1px solid #fecaca; }
.banner.warn { background: var(--warn-bg); color: #78350f; border: 1px solid var(--warn-border); }
.banner.info { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tabs button { background: none; color: var(--muted); border-radius: 6px 6px 0 0; padding: 0.55rem 1rem; font-weight: 600; }
.tabs button.active { background: var(--panel); color: var(--accent); border: 1px solid var(--border); border-bottom-color: var(--panel); margin-bottom: -1px; }

.progress-bar { background: #e5e7eb; border-radius: 999px; height: 8px; overflow: hidden; }
.progress-bar > div { background: var(--accent); height: 100%; }

.pill { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: #e5e7eb; color: #374151; }
.pill.complete { background: var(--success-bg); color: #166534; }
.pill.partial { background: var(--warn-bg); color: #92400e; }
.pill.empty { background: var(--danger-bg); color: #991b1b; }

.center-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; max-width: 480px; width: 100%; }

.muted { color: var(--muted); font-size: 0.85rem; }
.row-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; }
.stat-card .label { color: var(--muted); font-size: 0.8rem; }
.stat-card.cockpit { border-left: 4px solid var(--accent); }

/* ---- combobox (elegant searchable dropdown) ---- */
.combobox-panel {
  position: absolute;
  z-index: 1000;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  max-height: 280px;
  overflow-y: auto;
  padding: 0.25rem;
}
.combobox-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
}
.combobox-option:hover, .combobox-option.active { background: #eff6ff; }
.combobox-label { font-weight: 600; }
.combobox-sublabel { color: var(--muted); font-size: 0.8rem; }
.combobox-empty { padding: 0.6rem; color: var(--muted); font-size: 0.85rem; }

/* ---- status color dots/pills ---- */
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.4rem; flex-shrink: 0; }
.status-green { background: #16a34a; }
.status-amber { background: #d97706; }
.status-red { background: #dc2626; }
.status-blue { background: #2563eb; }
.status-purple { background: #7c3aed; }
.status-teal { background: #0d9488; }
.status-pink { background: #db2777; }
.status-gray { background: #9ca3af; }

/* ---- reports dashboard ---- */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; }
.card-title { display: flex; align-items: center; margin: 0 0 0.75rem; }
.card-title h2 { margin: 0; flex: 1; font-size: 1rem; }
.leaderboard-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0; }
.leaderboard-rank { width: 1.6rem; font-weight: 700; color: var(--muted); }
.leaderboard-name { width: 110px; flex-shrink: 0; font-weight: 600; }
.leaderboard-bar-track { flex: 1; background: #e5e7eb; border-radius: 999px; height: 10px; overflow: hidden; }
.leaderboard-bar-fill { background: var(--accent); height: 100%; }
.leaderboard-count { width: 3rem; text-align: right; font-variant-numeric: tabular-nums; }
