/* ==========================================================================
   Escalade OBD2 — Design system
   Thème sombre premium, inspiré tableau de bord automobile Cadillac.
   ========================================================================== */

:root {
  --bg: #0a0a0f;
  --bg-glow-1: #1a1330;
  --bg-glow-2: #0f1a24;
  --card-bg: #1a1a2e;
  --card-bg-alt: #20203a;
  --card-border: rgba(201, 162, 39, 0.16);
  --card-border-strong: rgba(201, 162, 39, 0.4);

  --gold: #c9a227;
  --gold-light: #e8c766;
  --gold-dark: #8a6d1a;

  --red: #c0392b;
  --red-light: #e0574a;
  --orange: #e67e22;
  --green: #27ae60;
  --teal: #2fa4a0;
  --blue: #3d7dc9;

  --text: #ffffff;
  --text-secondary: #a0a0b0;
  --text-dim: #6c6c80;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  --nav-height: 76px;
  --header-height: 64px;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--bg-glow-1) 0%, transparent 55%),
    radial-gradient(1000px 500px at 110% 10%, var(--bg-glow-2) 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.mono {
  font-family: "SFMono-Regular", ui-monospace, "Courier New", monospace;
  font-variant-numeric: tabular-nums;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Écran d'authentification ---------- */

.app-hidden { display: none !important; }

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--bg-glow-1) 0%, transparent 55%),
    radial-gradient(1000px 500px at 110% 10%, var(--bg-glow-2) 0%, transparent 50%),
    var(--bg);
}
.auth-screen.open { display: flex; }

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--card-border-strong);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-card);
  text-align: center;
}

.auth-crest {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  filter: drop-shadow(0 0 10px rgba(201, 162, 39, 0.55));
}
.auth-crest svg { width: 100%; height: 100%; }

.auth-brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  margin: 0;
  background: linear-gradient(120deg, var(--gold-light), var(--gold) 45%, var(--gold-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin: 8px 0 22px;
  line-height: 1.5;
}

.auth-title {
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  margin: 0 0 4px;
}

.auth-hint {
  font-size: 11px;
  color: var(--text-dim);
  text-align: left;
  margin: -8px 0 10px;
  line-height: 1.4;
}

.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrap input {
  width: 100%;
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.password-toggle:active { color: var(--gold-light); }

.auth-match {
  min-height: 16px;
  font-size: 11px;
  text-align: left;
  margin: -8px 0 10px;
  color: var(--text-dim);
}
.auth-match.match { color: var(--green); }
.auth-match.mismatch { color: var(--red-light); }

.auth-error {
  min-height: 18px;
  font-size: 12px;
  color: var(--red-light);
  text-align: left;
  margin: 2px 0 10px;
}

.auth-submit { width: 100%; margin-top: 4px; }

.auth-toggle { display: block; margin: 6px auto 0; }

#authForgotBtn { display: block; margin: 14px auto 0; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

/* ---------- Header ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.crest {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(201, 162, 39, 0.5));
}
.crest svg { width: 100%; height: 100%; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 3px;
  background: linear-gradient(120deg, var(--gold-light), var(--gold) 45%, var(--gold-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.conn-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .2s, background .2s, color .2s;
}
.conn-pill:active { transform: scale(0.97); }
.conn-pill .icon { width: 16px; height: 16px; }

.conn-pill.connected {
  border-color: rgba(39, 174, 96, 0.5);
  background: rgba(39, 174, 96, 0.1);
  color: var(--green);
}
.conn-pill.connecting {
  border-color: rgba(201, 162, 39, 0.5);
  background: rgba(201, 162, 39, 0.1);
  color: var(--gold-light);
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.conn-pill.connected .conn-dot {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.6);
  animation: pulse-dot 2s infinite;
}
.conn-pill.connecting .conn-dot {
  background: var(--gold);
  animation: pulse-dot 0.9s infinite;
}

@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(39, 174, 96, 0); }
  100% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0); }
}

/* ---------- Main / tabs ---------- */

.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px calc(var(--nav-height) + 24px);
  scrollbar-width: none;
}
.app-main::-webkit-scrollbar { display: none; }

.tab { display: none; animation: fade-in .25s ease; }
.tab.active { display: block; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.tab-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 4px 0 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: 0.3px;
}

/* ---------- Gauges (dashboard) ---------- */

.gauge-row {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 8px 0 6px;
}

.gauge {
  --value: 0;
  --color: var(--gold);
  width: 42vw;
  height: 42vw;
  max-width: 176px;
  max-height: 176px;
  min-width: 130px;
  min-height: 130px;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(closest-side, var(--card-bg) 76%, transparent 77% 100%),
    conic-gradient(from 0deg, var(--color) calc(var(--value) * 1%), rgba(255,255,255,0.07) 0);
  box-shadow: var(--shadow-card);
  transition: background 0.5s ease;
}

.gauge::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.gauge-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.gauge-value {
  font-family: "SFMono-Regular", ui-monospace, "Courier New", monospace;
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
  text-shadow: 0 0 14px color-mix(in srgb, var(--color) 65%, transparent);
  line-height: 1;
}

.gauge-unit {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.gauge-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ---------- Metric cards ---------- */

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.metric-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-card);
}

.metric-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 10px;
}

.metric-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 0.5s ease, background 0.5s ease;
}
.metric-bar-fill.gold { background: linear-gradient(90deg, var(--gold-dark), var(--gold-light)); }
.metric-bar-fill.teal { background: linear-gradient(90deg, #1d6f6c, var(--teal)); }

.metric-foot {
  margin-top: 8px;
  font-size: 15px;
  font-weight: 700;
  font-family: "SFMono-Regular", ui-monospace, "Courier New", monospace;
  font-variant-numeric: tabular-nums;
}

/* ---------- DTC quick card + km row ---------- */

.dtc-quick-card {
  width: 100%;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}

.dtc-quick-left { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); }
.dtc-quick-left .icon { color: var(--gold); }

.badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.4px;
  background: rgba(39, 174, 96, 0.15);
  color: var(--green);
}
.badge.alert { background: rgba(192, 57, 43, 0.18); color: var(--red-light); }

.km-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 6px 4px;
}
.km-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.km-value {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--gold-light);
  font-family: "SFMono-Regular", ui-monospace, "Courier New", monospace;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.km-value .icon { width: 14px; height: 14px; color: var(--text-dim); }

/* ---------- Icons ---------- */

.icon {
  width: 20px;
  height: 20px;
  color: currentColor;
  flex-shrink: 0;
}
.icon-sm { width: 16px; height: 16px; }

/* ---------- Bottom nav ---------- */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-height);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: rgba(15, 15, 22, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(201, 162, 39, 0.15);
  z-index: 20;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  min-height: 48px;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.nav-item .icon { transition: transform 0.2s, color 0.2s; }

.nav-item.active {
  color: var(--gold-light);
}
.nav-item.active .icon {
  color: var(--gold-light);
  transform: translateY(-2px);
  filter: drop-shadow(0 0 6px rgba(201, 162, 39, 0.55));
}

.nav-item.active::before {
  content: "";
  position: absolute;
  top: 2px;
  width: 28px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold-light));
}

/* ---------- Generic card / buttons / forms ---------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  flex: 1;
  background: linear-gradient(135deg, var(--gold-light), var(--gold) 55%, var(--gold-dark));
  color: #14140f;
  box-shadow: 0 6px 18px rgba(201, 162, 39, 0.25);
}
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-danger-outline {
  flex: 1;
  background: rgba(192, 57, 43, 0.08);
  border: 1px solid rgba(192, 57, 43, 0.45);
  color: var(--red-light);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text);
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: rgba(201, 162, 39, 0.08);
  color: var(--gold-light);
  cursor: pointer;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0;
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}

.field input, .field select {
  min-height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 16px;
  padding: 0 14px;
  font-family: inherit;
  text-transform: none;
  letter-spacing: normal;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.15);
}

/* ---------- Maintenance list ---------- */

.maintenance-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.maintenance-item {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--text-dim);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-card);
}
.maintenance-item.level-ok { border-left-color: var(--green); }
.maintenance-item.level-warning { border-left-color: var(--orange); }
.maintenance-item.level-urgent { border-left-color: var(--red); }
.maintenance-item.level-unknown { border-left-color: var(--text-dim); }

.maintenance-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.maintenance-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(201, 162, 39, 0.1);
  color: var(--gold-light);
  flex-shrink: 0;
}
.maintenance-icon .icon { width: 20px; height: 20px; }

.maintenance-info { flex: 1; min-width: 0; }
.maintenance-title { font-size: 14px; font-weight: 700; }
.maintenance-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.status-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}
.status-pill.level-ok { background: rgba(39, 174, 96, 0.15); color: var(--green); }
.status-pill.level-warning { background: rgba(230, 126, 34, 0.18); color: var(--orange); }
.status-pill.level-urgent { background: rgba(192, 57, 43, 0.2); color: var(--red-light); }
.status-pill.level-unknown { background: rgba(255, 255, 255, 0.07); color: var(--text-dim); }

.maintenance-progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  margin-top: 12px;
  overflow: hidden;
}
.maintenance-progress-fill { height: 100%; border-radius: 999px; }
.level-ok .maintenance-progress-fill { background: var(--green); }
.level-warning .maintenance-progress-fill { background: var(--orange); }
.level-urgent .maintenance-progress-fill { background: var(--red); }
.level-unknown .maintenance-progress-fill { background: var(--text-dim); }

.maintenance-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--gold-light);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 4px;
}

/* ---------- Flexfuel ---------- */

.fuel-ratio-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: 18px;
}

.fuel-ratio-bar {
  display: flex;
  height: 40px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
}

.fuel-ratio-e85, .fuel-ratio-sp95 {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #0c0c10;
  transition: width 0.5s ease;
}
.fuel-ratio-e85 { background: linear-gradient(90deg, var(--gold-dark), var(--gold-light)); }
.fuel-ratio-sp95 { background: linear-gradient(90deg, #2e5f95, var(--blue)); color: #eef4ff; }

.fuel-ratio-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.fuel-ratio-legend b { color: var(--text); margin-left: 4px; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot-e85 { background: var(--gold-light); }
.dot-sp95 { background: var(--blue); }

.calc-card { margin-bottom: 8px; }

.calc-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 4px;
  margin-top: 12px;
}

.calc-toggle-btn {
  flex: 1;
  min-height: 38px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.calc-toggle-btn.active {
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  color: #14140f;
}

.calc-results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.calc-result {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.calc-result-label { display: block; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.calc-result-value { display: block; margin-top: 6px; font-size: 19px; font-weight: 800; font-family: "SFMono-Regular", ui-monospace, "Courier New", monospace; }
.calc-result-value.gold { color: var(--gold-light); }

.calc-capacity { font-size: 12px; color: var(--text-dim); margin: 14px 0 2px; text-align: center; }

.fuel-history, .dtc-history {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
}
.history-row-date { color: var(--text-dim); font-size: 11px; }
.history-row-main { font-weight: 700; }
.history-row-ratio { color: var(--gold-light); font-weight: 700; font-size: 12px; }

.empty-state {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 24px 12px;
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-md);
}

/* ---------- Diagnostic ---------- */

.dtc-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(39, 174, 96, 0.1);
  border: 1px solid rgba(39, 174, 96, 0.35);
  color: var(--green);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 16px;
}
.dtc-banner.alert {
  background: rgba(192, 57, 43, 0.12);
  border-color: rgba(192, 57, 43, 0.4);
  color: var(--red-light);
}

.dtc-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.dtc-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}

.dtc-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--red);
  border-radius: var(--radius-md);
  padding: 14px;
}
.dtc-card.info { border-left-color: var(--gold); }

.dtc-code {
  font-family: "SFMono-Regular", ui-monospace, "Courier New", monospace;
  font-size: 16px;
  font-weight: 800;
  color: var(--red-light);
}
.dtc-card.info .dtc-code { color: var(--gold-light); }

.dtc-desc { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }
.dtc-note { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--gold-light); }
.dtc-note .icon { width: 14px; height: 14px; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 10, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-overlay.open { display: flex; animation: overlay-in 0.2s ease; }

@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--card-bg-alt);
  border: 1px solid var(--card-border-strong);
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
  animation: modal-up 0.25s cubic-bezier(.2,.8,.3,1);
  max-height: 86vh;
  overflow-y: auto;
}

@keyframes modal-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.15);
  margin: 0 auto 14px;
}

.modal-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 4px;
}
.modal-sub { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  width: min(92vw, 420px);
}

.toast {
  background: rgba(26, 26, 46, 0.96);
  border: 1px solid var(--card-border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  animation: toast-in 0.25s ease;
}
.toast.error { border-color: rgba(192, 57, 43, 0.5); color: var(--red-light); }
.toast.success { border-color: rgba(39, 174, 96, 0.5); color: var(--green); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */

@media (min-width: 480px) {
  .app-main { max-width: 480px; margin: 0 auto; width: 100%; }
  .app-header { max-width: 480px; margin: 0 auto; width: 100%; }
  .bottom-nav { max-width: 480px; margin: 0 auto; }
}

@media (min-width: 720px) {
  #app { max-width: 480px; margin: 0 auto; box-shadow: 0 0 60px rgba(0,0,0,0.6); }
  .bottom-nav { left: 50%; transform: translateX(-50%); width: 480px; }
}
