/* ─── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg-base:        #0d1117;
  --bg-surface:     #161b22;
  --bg-card:        #1c2230;
  --bg-hover:       #21293a;
  --border:         rgba(255,255,255,0.08);
  --border-focus:   rgba(59,130,246,0.6);

  --blue-500:       #3b82f6;
  --blue-600:       #2563eb;
  --blue-400:       #60a5fa;
  --teal-500:       #14b8a6;
  --red-400:        #f87171;
  --amber-400:      #fbbf24;
  --green-400:      #4ade80;

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 20px rgba(59,130,246,0.25);

  --font-body: 'Inter', system-ui, sans-serif;
  --font-head: 'Outfit', 'Inter', sans-serif;
}

/* ─── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--blue-400); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Header ────────────────────────────────────────────────────────────────── */
.app-header {
  background: rgba(13,17,23,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex; align-items: center; gap: 24px;
}
.logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--blue-500), var(--teal-500));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.logo-icon svg { width: 16px; height: 16px; color: white; }
.logo-text { font-family: var(--font-head); font-size: 18px; font-weight: 700; color: var(--text-primary); }
.header-nav { display: flex; gap: 4px; flex: 1; }
.nav-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--radius-sm);
  border: none; background: transparent; color: var(--text-secondary);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all 0.2s;
}
.nav-btn svg { width: 16px; height: 16px; }
.nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-btn.active { background: var(--bg-card); color: var(--blue-400); box-shadow: inset 0 0 0 1px var(--border-focus); }
.rgpd-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--green-400);
  background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.2);
  padding: 4px 10px; border-radius: 20px; flex-shrink: 0;
  white-space: nowrap;
}
.rgpd-badge svg { width: 12px; height: 12px; }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.view { min-height: calc(100vh - 120px); }

/* ─── Section Headers ───────────────────────────────────────────────────────── */
section { padding: 40px 0; border-bottom: 1px solid var(--border); }
section:last-child { border-bottom: none; }
.section-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
}
.section-header h2 { font-family: var(--font-head); font-size: 20px; font-weight: 700; }
.step-badge {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-500), var(--teal-500));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
}
.count-badge {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 2px 10px; border-radius: 20px; font-size: 12px; color: var(--text-secondary);
}

/* ─── Config ────────────────────────────────────────────────────────────────── */
.config-section { background: var(--bg-base); }
.config-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.form-group input {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 10px 14px;
  color: var(--text-primary); font-size: 14px; font-family: var(--font-body);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus { outline: none; border-color: var(--border-focus); box-shadow: var(--shadow-glow); }
.field-hint { font-size: 11px; color: var(--text-muted); }

/* ─── Format Table ──────────────────────────────────────────────────────────── */
.format-info {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; margin-bottom: 24px;
}
.format-info h3 { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 14px; }
.table-wrapper { overflow-x: auto; border-radius: var(--radius-md); }
.format-table, .data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.format-table th, .data-table th {
  background: var(--bg-card); color: var(--text-secondary);
  font-weight: 600; text-align: left; padding: 10px 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.format-table td, .data-table td {
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  color: var(--text-primary); vertical-align: middle;
}
.format-table tr:last-child td, .data-table tr:last-child td { border-bottom: none; }
.format-table tr:hover td, .data-table tr:hover td { background: var(--bg-hover); }
.badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge.req { background: rgba(59,130,246,0.15); color: var(--blue-400); }
.badge.opt { background: rgba(139,148,158,0.15); color: var(--text-secondary); }
.badge.ajeun { background: rgba(251,191,36,0.15); color: var(--amber-400); }
.download-template { margin-top: 14px; }

/* ─── Dropzone ──────────────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl); padding: 48px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; transition: all 0.25s; background: var(--bg-surface);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--blue-500);
  background: rgba(59,130,246,0.05);
  box-shadow: var(--shadow-glow);
}
.dropzone-icon { margin-bottom: 8px; }
.dropzone-icon svg { width: 48px; height: 48px; color: var(--text-muted); transition: color 0.2s; }
.dropzone:hover .dropzone-icon svg { color: var(--blue-400); }
.dropzone-text { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.dropzone-subtext { color: var(--text-secondary); font-size: 13px; }
.dropzone-formats { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.test-actions { margin-top: 12px; display: flex; justify-content: center; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
  color: white; font-weight: 600; font-size: 14px;
  padding: 11px 22px; border-radius: var(--radius-md);
  border: none; cursor: pointer; transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(59,130,246,0.4);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(59,130,246,0.5); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary svg { width: 16px; height: 16px; }
.btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-card); color: var(--text-primary);
  font-weight: 600; font-size: 14px; padding: 11px 22px;
  border-radius: var(--radius-md); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.2s;
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--blue-400); }
.btn-secondary svg { width: 16px; height: 16px; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--text-secondary);
  font-size: 13px; font-weight: 500; padding: 8px 14px;
  border-radius: var(--radius-md); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.2s;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }
.btn-ghost svg { width: 15px; height: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.desktop-map {
  height: 400px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  z-index: 10;
}

/* ─── Error / Status Panels ─────────────────────────────────────────────────── */
.error-panel {
  background: rgba(248,113,113,0.08); border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius-md); padding: 16px; margin-bottom: 20px;
}
.error-panel-header { display: flex; align-items: center; gap: 8px; color: var(--red-400); font-weight: 600; margin-bottom: 10px; }
.error-panel-header svg { width: 18px; height: 18px; flex-shrink: 0; }
.error-panel ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.error-panel li { font-size: 13px; color: #fca5a5; padding-left: 8px; border-left: 2px solid var(--red-400); }
.geocode-error-panel {
  background: rgba(251,191,36,0.06); border: 1px solid rgba(251,191,36,0.25);
  border-radius: var(--radius-md); padding: 20px; margin-top: 20px;
}
.geocode-error-panel h3 { display: flex; align-items: center; gap: 8px; color: var(--amber-400); font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.geocode-error-panel h3 svg { width: 16px; height: 16px; }
.geocode-fix-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.geocode-fix-row span { color: var(--text-secondary); font-size: 13px; min-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.geocode-fix-row input { flex: 1; }
.geocode-fix-row button { padding: 8px 14px; font-size: 12px; }
.vroom-error { padding: 0 0 24px; }
.pdf-warn-panel {
  background: rgba(251,191,36,0.07); border: 1px solid rgba(251,191,36,0.28);
  border-radius: var(--radius-md); padding: 16px; margin-bottom: 20px;
}
.pdf-warn-panel ul { list-style: none; display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }

/* ─── Preview & Data Table ──────────────────────────────────────────────────── */
.preview-section, .results-section { background: var(--bg-base); }
.preview-actions, .export-actions { margin-top: 24px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ─── Stats Grid ────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.stat-value { font-family: var(--font-head); font-size: 28px; font-weight: 700; color: var(--text-primary); }
.stat-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ─── Route Cards ───────────────────────────────────────────────────────────── */
.route-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: 24px; overflow: hidden;
}
.route-card-header {
  padding: 16px 20px; background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.route-card-header h3 { font-family: var(--font-head); font-size: 15px; font-weight: 700; flex: 1; }
.route-meta { font-size: 12px; color: var(--text-secondary); }
.stop-row {
  display: flex; align-items: center; padding: 14px 20px;
  border-bottom: 1px solid var(--border); gap: 14px;
  transition: background 0.15s;
}
.stop-row:last-child { border-bottom: none; }
.stop-row:hover { background: var(--bg-hover); }
.stop-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--blue-500); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.stop-time { font-weight: 700; font-size: 15px; color: var(--blue-400); min-width: 50px; }
.stop-name { flex: 1; font-weight: 500; }
.stop-addr { font-size: 12px; color: var(--text-secondary); }
.stop-links { display: flex; gap: 6px; }
.link-btn {
  padding: 4px 10px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600; border: none; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
  transition: opacity 0.2s;
}
.link-btn:hover { opacity: 0.8; text-decoration: none; }
.link-btn.gm { background: rgba(66,133,244,0.2); color: #7aacf8; border: 1px solid rgba(66,133,244,0.3); }
.link-btn.wz { background: rgba(5,205,153,0.15); color: #33ccaa; border: 1px solid rgba(5,205,153,0.3); }

/* ─── QR Panel ──────────────────────────────────────────────────────────────── */
.qr-panel {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px; margin-top: 24px;
  text-align: center;
}
.qr-panel h3 { margin-bottom: 20px; font-size: 15px; color: var(--text-secondary); }
.qr-panel canvas { border-radius: var(--radius-md); }
.qr-hint { margin-top: 12px; font-size: 12px; color: var(--text-muted); }

/* ─── Mobile View ───────────────────────────────────────────────────────────── */
.mobile-view { padding: 0; }
.mobile-placeholder {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; padding: 80px 24px; text-align: center;
}
.placeholder-icon svg { width: 64px; height: 64px; color: var(--text-muted); }
.mobile-placeholder h2 { font-family: var(--font-head); font-size: 22px; }
.mobile-placeholder p { color: var(--text-secondary); max-width: 300px; }
.mobile-header {
  padding: 14px 20px; background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.mobile-progress { font-weight: 700; font-size: 15px; }
.mobile-eta { font-size: 13px; color: var(--text-secondary); }
.mobile-map { height: 240px; background: var(--bg-card); border-bottom: 1px solid var(--border); position: relative; }
.mobile-stop-card {
  padding: 20px; background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.stop-info { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.stop-initials {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-500), var(--teal-500));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-size: 18px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.stop-number-badge {
  position: absolute; /* positioned via JS */ background: var(--blue-500);
  color: white; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; margin-bottom: 12px;
}
.stop-time { font-size: 22px; font-weight: 700; color: var(--blue-400); }
.stop-ajeun { font-size: 13px; color: var(--amber-400); font-weight: 600; }
.stop-nav-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.nav-btn-large {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; border-radius: var(--radius-md);
  font-weight: 700; font-size: 14px; text-decoration: none;
  transition: opacity 0.2s;
}
.nav-btn-large:hover { opacity: 0.85; text-decoration: none; }
.nav-btn-large svg { width: 20px; height: 20px; }
.nav-btn-large.gmaps { background: rgba(66,133,244,0.2); color: #7aacf8; border: 1px solid rgba(66,133,244,0.35); }
.nav-btn-large.waze { background: rgba(5,205,153,0.15); color: #33ccaa; border: 1px solid rgba(5,205,153,0.35); }
.btn-arrive {
  width: 100%; padding: 15px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--teal-500), #0ea5e9);
  border: none; color: white; font-size: 15px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity 0.2s;
}
.btn-arrive:hover { opacity: 0.9; }
.btn-arrive svg { width: 18px; height: 18px; }
.stops-list { padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; }
.stop-list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--bg-card); border-radius: var(--radius-md);
  border: 1px solid var(--border); transition: opacity 0.3s;
}
.stop-list-item.done { opacity: 0.4; }
.stop-list-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-hover); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.stop-list-item.active .stop-list-num { background: var(--blue-500); color: white; }
.stop-list-info { flex: 1; }
.stop-list-initials { font-weight: 600; font-size: 13px; }
.stop-list-time { font-size: 11px; color: var(--text-secondary); }

/* ─── Loading ───────────────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(13,17,23,0.85);
  backdrop-filter: blur(6px); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.loading-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 40px 56px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  box-shadow: var(--shadow-card);
}
.loading-spinner {
  width: 44px; height: 44px; border: 3px solid var(--border);
  border-top-color: var(--blue-500); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { font-size: 14px; color: var(--text-secondary); }

/* ─── Footer ────────────────────────────────────────────────────────────────── */
.app-footer {
  border-top: 1px solid var(--border); padding: 16px 0;
  background: var(--bg-base); color: var(--text-muted); font-size: 12px;
}
.app-footer .container { display: flex; align-items: center; gap: 8px; }
.app-footer svg { width: 13px; height: 13px; color: var(--green-400); flex-shrink: 0; }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner { padding: 0 16px; gap: 12px; }
  .logo-text { display: none; }
  .rgpd-badge span { display: none; }
  .config-grid { grid-template-columns: 1fr; }
  .container { padding: 0 16px; }
  .stop-row { flex-wrap: wrap; }
  .stop-links { width: 100%; justify-content: flex-end; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── File Queue (multi-PDF) ─────────────────────────────────────────────────── */
.file-queue {
  margin-top: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  animation: fadeIn 0.3s ease;
}
.file-queue-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.file-queue-header svg { width: 18px; height: 18px; color: var(--blue-400); flex-shrink: 0; }
#file-queue-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: background 0.2s;
}
.file-queue-item svg { width: 16px; height: 16px; color: var(--blue-400); flex-shrink: 0; }
.fq-name {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fq-size {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.fq-status {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  flex-shrink: 0;
  min-width: 90px;
  text-align: right;
}
.fq-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.fq-remove:hover { color: var(--red-400); background: rgba(248,113,113,0.1); }

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