/* ═══════════════════════════════════════════════════════════════════════════
   CargoX Relayer — Shared Styles
   Default theme (tracker, analytics, admin, landing).
   Dashboard overrides via body.theme-dashboard.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variables ── */
:root {
  --bg: #0a0f1a; --surface: #111827; --surface2: #1a2234; --border: #1f2937;
  --text: #f3f4f6; --muted: #9ca3af; --accent: #3b82f6;
  --green: #10b981; --red: #ef4444; --yellow: #f59e0b;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  --radius: 8px;
}

/* Dashboard theme override */
body.theme-dashboard {
  --bg: #0d1117; --surface: #161b22; --surface2: #21262d;
  --border: #30363d; --text: #e6edf3; --muted: #7d8590;
  --accent: #58a6ff; --green: #3fb950; --yellow: #d29922; --red: #f85149;
  --blue: #58a6ff; --purple: #bc8cff;
}

/* ── Reset ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.6; }

/* ── Navbar ── */
nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  padding: 10px 24px; gap: 8px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 10; }
nav a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; transition: color .15s; }
nav a:hover, nav a.active { color: var(--accent); }
.nav-brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 16px; text-decoration: none; }
.nav-brand img { width: 32px; height: 32px; border-radius: 8px; }
.nav-links { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.nav-user-row { display: flex; gap: 10px; align-items: center; width: 100%; justify-content: flex-end; font-size: 12px; }

/* ── Container ── */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ── Buttons ── */
button { cursor: pointer; border: none; border-radius: 6px; padding: 6px 14px; font-size: 12px;
  font-weight: 600; font-family: var(--font); transition: all .15s; }
button:hover { opacity: .85; }
button:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-danger  { background: #3d1a1a; color: var(--red); border: 1px solid #5a2424; }
.btn-success { background: #1a3d24; color: var(--green); border: 1px solid #245a33; }
.btn-neutral { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-neutral:hover { border-color: var(--accent); }
.btn-warning { background: #3d2e00; color: var(--yellow); border: 1px solid #5a4400; }
.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.stat-card .label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 2px; }
.stat-card .value { font-size: 24px; font-weight: 800; color: #fff; line-height: 1.2; }
.stat-card .sub { font-size: 12px; margin-top: 2px; color: var(--muted); }
.sub.green { color: var(--green); }
.sub.red { color: var(--red); }

/* ── Chart cards ── */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(480px, 100%), 1fr)); gap: 16px; margin-bottom: 24px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.chart-card h3 { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.chart-card canvas { width: 100% !important; max-height: 280px; }
.chart-card.chart-wide { grid-column: 1 / -1; }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }
.chart-filters { display: flex; gap: 4px; }
.cfilt { background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  color: var(--muted); font-size: 11px; padding: 3px 8px; cursor: pointer; transition: all .15s; }
.cfilt:hover { border-color: var(--accent); color: var(--text); }
.cfilt.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.cfilt-sep { width: 1px; height: 16px; background: var(--border); margin: 0 4px; flex-shrink: 0; align-self: center; }

/* ── Modals ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 24px; width: 90%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal-header { padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 11px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal .error { color: var(--red); font-size: 12px; margin-top: 4px; }

/* ── Forms ── */
input, select, textarea {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 7px 10px; font-size: 13px; width: 100%; font-family: var(--font); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
select option { background: var(--surface); }
textarea { resize: vertical; min-height: 60px; }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.form-group { display: flex; flex-direction: column; gap: 3px; margin-bottom: 12px; }

/* ── Sync bar ── */
.sync-bar { text-align: center; color: var(--muted); font-size: 12px; margin: 24px 0 8px;
  padding: 8px 16px; background: var(--surface); border-radius: 8px; border: 1px solid var(--border); }

/* ── Info section ── */
.info-section { margin-top: 32px; }
.info-section h2 { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; }
.info-card h3 { font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--accent); }
.info-card p { font-size: 12px; color: var(--muted); }
.info-card a { color: var(--accent); text-decoration: none; }
.info-card a:hover { text-decoration: underline; }
.info-card code { background: rgba(255,255,255,.06); padding: 2px 6px; border-radius: 4px; font-size: 11px; word-break: break-all; }

/* ── Tables ── */
.perf-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.perf-table th { padding: 6px 10px; text-align: left; color: var(--muted); font-size: 10px;
  text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.perf-table td { padding: 5px 10px; border-bottom: 1px solid #21262d; }
.perf-table tr:hover td { background: #1c2128; }
.perf-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.perf-table .green { color: var(--green); }
.perf-table .yellow { color: var(--yellow); }
.perf-table .red { color: var(--red); }

/* Admin table */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { padding: 8px 12px; text-align: left; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:hover td { background: rgba(255,255,255,.02); }
.admin-table code { font-size: 11px; background: rgba(255,255,255,.06); padding: 2px 6px; border-radius: 4px; word-break: break-all; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-admin { background: rgba(59,130,246,.15); color: var(--accent); }
.badge-user { background: rgba(156,163,175,.15); color: var(--muted); }
.badge-customer { background: rgba(245,158,11,.15); color: #f59e0b; }
.badge-on { background: rgba(16,185,129,.15); color: var(--green); }
.badge-off { background: rgba(239,68,68,.15); color: var(--red); }

/* ── Toolbar ── */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.toolbar label { font-size: 12px; color: var(--muted); }
.toolbar select { background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; font-size: 12px; }

/* ── Mobile ── */
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card .value { font-size: 18px; }
  .charts-grid { grid-template-columns: 1fr; }
  .container { padding: 12px; }
  .nav-links { gap: 12px; }
  .nav-links a { font-size: 13px; }
  .toolbar { flex-direction: column; align-items: stretch; }
}
