/* ApexRoute PRO v2.2.0 — Core Stylesheet
 * Copyright (c) 2026 ApexRoute PRO. All rights reserved.
 */
:root {
  --bg-app: #f3f6fa;
  --bg-card: #ffffff;
  --bg-sub: #e9eff7;
  --bg-input: #f8fafc;
  --border: #d5dfec;
  --text-main: #0f172a;
  --text-muted: #475569;
  --accent: #059669;
  --accent-hover: #047857;
  --accent-soft: rgba(5, 150, 105, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.12);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.14);
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, 0.12);
  --shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}

html.dark {
  --bg-app: #080d17;
  --bg-card: #101827;
  --bg-sub: #172236;
  --bg-input: #0c1320;
  --border: #23314a;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-soft: rgba(16, 185, 129, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.15);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.14);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.demo-banner {
  background: var(--warn-soft);
  border-bottom: 1px solid var(--warn);
  color: var(--text-main);
  padding: 8px 16px;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.demo-banner button {
  background: var(--warn);
  color: #0b111e;
  border: none;
  border-radius: 8px;
  padding: 4px 10px;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
}

header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 0;
}
.header-top {
  max-width: 960px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--accent); color: #06130e;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1rem; flex-shrink: 0;
}
.brand-title { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; }
.badge-pro {
  font-size: 0.68rem; font-weight: 800; padding: 2px 7px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.nav-tabs {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  padding: 10px 12px;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

main {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  flex: 1;
}

/* Welcome / Onboarding Screen */
.welcome-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.welcome-badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.welcome-hero h1 {
  margin: 0 0 8px;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.welcome-hero p {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.welcome-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 720px) {
  .welcome-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.welcome-tile {
  background: var(--bg-sub);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}
.welcome-tile strong { font-size: 0.95rem; }
.welcome-tile span { font-size: 0.8rem; color: var(--text-muted); }

.control-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.control-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.control-row select {
  flex: 1;
  min-width: 0;
  background: var(--bg-sub);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}
.unit-toggle {
  display: inline-flex;
  background: var(--bg-sub);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border);
}
.unit-toggle button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.unit-toggle button.active {
  background: var(--accent);
  color: #06130e;
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.icon-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-sub);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.icon-pill:hover { border-color: var(--accent); }
.sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn);
}
.sync-dot.encrypted { background: var(--accent); }

.btn-primary {
  background: var(--accent);
  color: #06130e;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary {
  background: var(--bg-sub);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 760px) {
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.kpi-card:active { transform: scale(0.99); }
.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.kpi-val {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}
.progress-track {
  height: 6px;
  background: var(--bg-sub);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}
.pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
}
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-ok { background: var(--accent-soft); color: var(--accent); }
.pill-info { background: var(--info-soft); color: var(--info); }

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.section-title {
  font-size: 1rem;
  font-weight: 800;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
@media (min-width: 640px) {
  .action-grid { grid-template-columns: 1fr 1fr; }
}
.action-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  color: var(--text-main);
}
.action-tile:hover { border-color: var(--accent); }

/* Routing & Search Autocomplete */
.recorder-meta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.origin-box {
  background: var(--bg-sub);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.origin-box input, .dest-search-wrap input {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 0.88rem;
}
.dest-search-wrap {
  background: var(--bg-sub);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.autocomplete-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 45;
  max-height: 220px;
  overflow-y: auto;
}
.autocomplete-item {
  padding: 9px 12px;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--accent-soft); }

.list-item {
  background: var(--bg-sub);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.svg-chart-container {
  width: 100%;
  overflow-x: auto;
}
.svg-chart-container svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-bar-wrap { margin-bottom: 10px; }
.chart-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 4px;
}
.chart-bar-track {
  height: 10px;
  background: var(--bg-sub);
  border-radius: 999px;
  overflow: hidden;
}
.chart-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-head h3 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.field-group { margin-bottom: 12px; }
.field-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.field-group input, .field-group select {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 0.9rem;
}

.recovery-box {
  background: var(--warn-soft);
  border: 1px dashed var(--warn);
  border-radius: 12px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86rem;
  word-break: break-all;
  margin: 10px 0;
}

.hidden { display: none !important; }

footer {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 14px 16px 28px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
footer a { color: var(--accent); text-decoration: none; font-weight: 600; }


/* Paywall-Style Blurred Backdrop & Entry Gate Dialogue */
#app-shell {
  transition: filter 0.25s ease, transform 0.25s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
#app-shell.workspace-locked {
  filter: blur(11px) saturate(0.85);
  pointer-events: none;
  user-select: none;
  height: 100vh;
  overflow: hidden;
}

.gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 13, 23, 0.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
}

.gate-dialog {
  width: 100%;
  max-width: 540px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  margin: auto;
}

.gate-dialog-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.gate-dialog h1 {
  margin: 0 0 8px;
  font-size: 1.32rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.gate-dialog > p {
  margin: 0 0 14px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.gate-notice {
  background: var(--info-soft);
  border: 1px solid var(--info);
  color: var(--text-main);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.8rem;
  margin-bottom: 14px;
}

.gate-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gate-option-card {
  background: var(--bg-sub);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.gate-option-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.gate-option-copy strong {
  font-size: 0.92rem;
}

.gate-option-copy span {
  font-size: 0.77rem;
  color: var(--text-muted);
}

.gate-option-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.tile-featured {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.tile-kicker {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.gate-dialog-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.gate-dialog-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
