/* Tokens copied verbatim from TripIO-Web's own design system (src/constants/Colors.ts) — the
   design handoff for this panel (BE53) reuses that exact palette, so this isn't a new one. */
:root {
  color-scheme: light dark;
  --primary: #4558E4;
  --primary-light: #EEF0FF;
  --primary-dark: #3244CC;
  --secondary: #0A9488;
  --secondary-light: #E6F7F6;

  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --surface2: #F2F2F0;
  --border: #E5E5EA;

  --text-primary: #1C1C1E;
  --text-secondary: #6E6E73;
  --text-tertiary: #AEAEB2;
  --text-on-accent: #FFFFFF;

  --success: #25A244;
  --success-bg: #E6F4EA;
  --warning: #D4700A;
  --warning-bg: #FEF3E2;
  --error: #D93025;
  --error-bg: #FDECEA;
  --info: #0078D7;
  --info-bg: #E3F2FD;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #8E9BFF;
    --primary-light: #1E2040;
    --primary-dark: #B0BAFF;
    --secondary: #34C7B5;
    --secondary-light: #0D2E2B;

    --bg: #1C1C1E;
    --surface: #2C2C2E;
    --surface2: #3A3A3C;
    --border: #38383A;

    --text-primary: #EBEBF5;
    --text-secondary: rgba(235,235,245,0.60);
    --text-tertiary: rgba(235,235,245,0.30);

    --success: #30D158;
    --success-bg: #0D2E17;
    --warning: #FF9F0A;
    --warning-bg: #2E1F00;
    --error: #FF453A;
    --error-bg: #2E0D0A;
    --info: #64D2FF;
    --info-bg: #0A1E2E;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
}

[hidden] { display: none !important; }

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: var(--primary);
  color: var(--text-on-accent);
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button:hover { background: var(--primary-dark); }
button:disabled { opacity: 0.5; cursor: default; }
button.secondary { background: var(--surface2); color: var(--text-primary); }
button.secondary:hover { background: var(--border); }
button.danger { background: var(--error-bg); color: var(--error); }
button.danger:hover { filter: brightness(0.95); }

input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }

.muted { color: var(--text-secondary); }
.error-text { color: var(--error); font-size: 13px; }

/* ── Auth screens ──────────────────────────────────────────────────────── */

#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-brand .logo-badge { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), var(--secondary)); display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.auth-brand .brand-text { line-height: 1.15; }
.auth-brand .brand-text strong { display: block; font-size: 16px; font-weight: 800; }
.auth-brand .brand-text span { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--primary); }

.auth-card h1 { font-size: 19px; font-weight: 800; margin: 0 0 4px; }
.auth-card p.subtitle { margin: 0 0 20px; color: var(--text-secondary); font-size: 13px; }
.auth-card label { display: block; font-size: 12px; font-weight: 700; margin: 14px 0 6px; color: var(--text-secondary); }
.auth-card button[type=submit] { width: 100%; margin-top: 20px; padding: 12px; justify-content: center; }
.auth-switch { margin-top: 16px; text-align: center; font-size: 13px; }
.auth-switch a { color: var(--primary); cursor: pointer; text-decoration: none; font-weight: 600; }

/* ── App shell ─────────────────────────────────────────────────────────── */

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

#sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}

#sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
#sidebar .brand .logo-badge { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--primary), var(--secondary)); display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
#sidebar .brand .brand-text { line-height: 1.15; }
#sidebar .brand .brand-text strong { display: block; font-size: 15px; font-weight: 800; }
#sidebar .brand .brand-text span { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--primary); }

#sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }

#sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
#sidebar nav a:hover { background: var(--surface2); }
#sidebar nav a.active { background: var(--primary-light); color: var(--primary); }
#sidebar nav a svg { flex-shrink: 0; }

#sidebar .who { display: flex; align-items: center; gap: 10px; padding: 12px 8px; margin-top: 8px; border-top: 1px solid var(--border); }
#sidebar .who .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; flex-shrink: 0; }
#sidebar .who .who-text { line-height: 1.2; overflow: hidden; }
#sidebar .who .who-text strong { display: block; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sidebar .who .who-text span { display: block; font-size: 11px; color: var(--text-secondary); }
#sidebar .logout { width: 100%; background: none; color: var(--text-secondary); font-weight: 600; padding: 8px; justify-content: flex-start; }
#sidebar .logout:hover { background: var(--surface2); color: var(--text-primary); }

#main { flex: 1; padding: 28px 36px; overflow-x: auto; }

.main-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.main-header h2 { margin: 0 0 4px; font-size: 19px; font-weight: 800; }
.main-header .section-sub { color: var(--text-secondary); margin: 0; font-size: 13px; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.ok { background: var(--success-bg); color: var(--success); }
.status-pill.warn { background: var(--warning-bg); color: var(--warning); }

/* ── Shared widgets ────────────────────────────────────────────────────── */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; margin-bottom: 16px; }
.card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 800; }

.kpi-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; flex: 1; min-width: 180px; }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.kpi .icon-badge { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; }
.kpi .pct { font-size: 12px; font-weight: 700; }
.kpi .pct.up { color: var(--secondary); }
.kpi .pct.down { color: var(--error); }
.kpi .value { font-size: 24px; font-weight: 800; }
.kpi .label { color: var(--text-secondary); font-size: 12px; margin-top: 3px; }

.simple-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; flex: 1; min-width: 160px; }
.simple-kpi .label { color: var(--text-secondary); font-size: 12px; margin-bottom: 8px; }
.simple-kpi .value { font-size: 22px; font-weight: 800; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-tertiary); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.off { background: var(--surface2); color: var(--text-secondary); }
.badge.warn { background: var(--warning-bg); color: var(--warning); }
.badge.danger { background: var(--error-bg); color: var(--error); }
.badge.info { background: var(--primary-light); color: var(--primary); }

.origin-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.origin-badge.ai { background: var(--primary-light); color: var(--primary); }
.origin-badge.manual { background: var(--surface2); color: var(--text-secondary); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search-box { position: relative; max-width: 320px; flex: 1; min-width: 220px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); }
.search-box input { padding-left: 36px; }
.toolbar .count { color: var(--text-secondary); font-size: 13px; white-space: nowrap; }

.pagination { display: flex; gap: 8px; align-items: center; margin-top: 14px; justify-content: flex-end; }

.empty-state { color: var(--text-secondary); padding: 32px 0; text-align: center; }

.bar-chart { display: flex; align-items: flex-end; gap: 5px; height: 130px; margin-top: 10px; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 4px; }
.bar-chart .bar-col .bar-value { font-size: 10px; color: var(--text-tertiary); font-weight: 700; }
.bar-chart .bar-col .bar { width: 100%; background: var(--primary); border-radius: 5px 5px 0 0; min-height: 3px; }
.bar-chart .bar-col .bar-label { font-size: 10px; color: var(--text-tertiary); margin-top: 4px; }
.bar-chart .bar:hover { background: var(--primary-dark); }

.progress-list .progress-row { margin-bottom: 14px; }
.progress-list .progress-row:last-child { margin-bottom: 0; }
.progress-list .progress-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.progress-list .progress-head .name { font-weight: 600; }
.progress-list .progress-head .pct { color: var(--text-secondary); font-weight: 700; }
.progress-track { height: 6px; border-radius: 999px; background: var(--surface2); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--primary); }

.filter-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.filter-tabs button { background: var(--surface2); color: var(--text-primary); font-weight: 700; padding: 8px 16px; border-radius: 999px; }
.filter-tabs button:hover { background: var(--border); }
.filter-tabs button.active { background: var(--primary); color: var(--text-on-accent); }

.list-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; margin-bottom: 12px; display: flex; gap: 14px; align-items: flex-start; }
.list-card .leading-icon { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.list-card .body { flex: 1; min-width: 0; }
.list-card .title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-card .title-row strong { font-size: 14px; font-weight: 700; }
.list-card .subtitle { color: var(--text-secondary); font-size: 12px; margin-top: 1px; }
.list-card .text { margin-top: 8px; font-size: 13px; }
.list-card .meta { margin-top: 8px; font-size: 12px; color: var(--text-tertiary); }
.list-card .trailing { flex-shrink: 0; text-align: right; }
.list-card.accent { border-left: 4px solid var(--border); }
.list-card.accent.crit { border-left-color: var(--error); }
.list-card.accent.high { border-left-color: var(--warning); }
.list-card.accent.med { border-left-color: #E0A500; }
.list-card.accent.low { border-left-color: var(--text-tertiary); }

.stars { color: var(--border); letter-spacing: 1px; font-size: 15px; }
.stars .filled { color: var(--primary); }

.provider-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.provider-row:last-child { border-bottom: none; }
.provider-row .leading-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.provider-row .body { flex: 1; min-width: 0; }
.provider-row .body strong { font-size: 13px; }
.provider-row .body .subtitle { font-size: 12px; color: var(--text-secondary); }
.provider-row .controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.provider-row .controls select, .provider-row .controls input { width: auto; min-width: 110px; padding: 7px 10px; font-size: 12px; }
.provider-row .controls button { padding: 7px 12px; font-size: 12px; }

.avatar-sm { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 11px; margin-right: 8px; vertical-align: middle; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--surface); border-radius: 16px; padding: 24px; width: 100%; max-width: 380px; }
.modal h3 { margin-top: 0; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal.wide { max-width: 640px; max-height: 85vh; overflow-y: auto; }
.poi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.poi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.poi-card .thumb { width: 100%; height: 140px; background: var(--surface2); object-fit: cover; display: block; }
.poi-card .thumb-empty { width: 100%; height: 140px; background: var(--surface2); display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); }
.poi-card .body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.poi-card .title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.poi-card .title-row strong { font-size: 14px; font-weight: 700; }
.poi-card .coords { font-size: 11px; color: var(--text-tertiary); }
.poi-card .desc { font-size: 12px; color: var(--text-secondary); flex: 1; }
.poi-card .actions-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.poi-card .actions-row button { flex: 1; padding: 6px 10px; font-size: 12px; }
.trip-row { cursor: pointer; }
.trip-row:hover { background: var(--surface2); }
.block-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.block-row:last-child { border-bottom: none; }
.block-row .leading-icon { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
