:root {
    --bg: #0f1419;
    --surface: #1a1f26;
    --surface-2: #232932;
    --border: #2a3038;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #4493f8;
    --accent-hover: #58a6ff;
    --good: #3fb950;
    --warn: #d29922;
    --bad: #f85149;
    --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
}
nav { display: flex; gap: 1.5rem; }
nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.15s;
}
nav a:hover { color: var(--text); }

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
}

h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 0.5rem; }
h2 { font-size: 1.25rem; font-weight: 600; margin: 2rem 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* Hero */
.hero {
    margin-bottom: 2rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
}
.hero-text { flex: 1; min-width: 260px; }

/* Page header */
.page-header { margin-bottom: 1.5rem; }
.page-header .title-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
}
.back-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 0.5rem;
}
.back-link:hover { color: var(--text); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-family: inherit;
}
.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--muted); }
.btn-danger {
    background: rgba(248, 81, 73, 0.1);
    color: #ffa198;
    border-color: rgba(248, 81, 73, 0.4);
}
.btn-danger:hover { background: rgba(248, 81, 73, 0.2); border-color: var(--bad); }
.btn-small { padding: 0.375rem 0.75rem; font-size: 0.85rem; }
.header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.hero-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.muted-tag { font-size: 0.75rem; padding: 0.125rem 0.5rem; border-radius: 999px; background: var(--surface-2); }

/* Trip card with action buttons (archive view) */
.trip-card-wrap { display: flex; flex-direction: column; gap: 0.5rem; }
.trip-card-wrap .trip-card { flex: 1; }
.trip-delete-form { margin: 0; }
.trip-delete-form button { width: 100%; }

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.stat .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.5rem;
}
.stat .value {
    font-size: 1.5rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Empty state */
.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
}
.empty-state h2 { margin: 0 0 0.5rem; }
.empty-state p { color: var(--muted); }
.empty-state ul { text-align: left; max-width: 400px; margin: 1rem auto; color: var(--muted); padding-left: 1.5rem; }

/* Trip cards grid */
.trips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}
.trip-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, transform 0.15s;
}
.trip-card:hover { border-color: var(--accent); }
.trip-route {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}
.trip-name { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.5rem; }
.trip-dates { font-size: 0.85rem; margin-bottom: 0.75rem; }
.trip-price { display: flex; align-items: baseline; gap: 0.5rem; }
.trip-price .price {
    font-size: 1.25rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Form */
.trip-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 720px;
}
.field { margin-bottom: 1rem; }
.field label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.375rem;
}
.field input,
.field select,
.field textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 0.625rem 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.field-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: end;
    margin-bottom: 1rem;
}
.field-row .field { margin-bottom: 0; }
.field-row .arrow {
    font-size: 1.5rem;
    color: var(--muted);
    padding-bottom: 0.625rem;
}
/* second .field-row variant: 4 cols */
.trip-form .field-row:nth-of-type(3) {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}
.trip-form .field-row:nth-of-type(2) {
    grid-template-columns: 1fr 1fr;
}
.form-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Alert */
.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border: 1px solid;
}
.alert-error {
    background: rgba(248, 81, 73, 0.1);
    border-color: rgba(248, 81, 73, 0.4);
    color: #ffa198;
}

/* Trip detail */
.trip-meta {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}
.meta-row { display: flex; flex-direction: column; gap: 0.25rem; }
.meta-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}
.meta-value { font-weight: 500; }

/* Price table */
.price-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.price-table th,
.price-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}
.price-table th {
    background: var(--surface-2);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}
.price-table tr:last-child td { border-bottom: 0; }
.price-table tr.cheapest { background: rgba(63, 185, 80, 0.06); }
.price-table .price-cell {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--surface-2);
    color: var(--muted);
}
.badge-exact { background: rgba(63, 185, 80, 0.15); color: var(--good); }
.badge-approximate { background: rgba(210, 153, 34, 0.15); color: var(--warn); }
.badge-failed { background: rgba(248, 81, 73, 0.15); color: var(--bad); }
.badge-direct {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(63, 185, 80, 0.15);
    color: var(--good);
}

.time-cell {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.time-strong { font-weight: 500; }

/* Verdict badge in featured card */
.verdict {
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
}
.verdict-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.verdict-low .verdict-badge { background: rgba(63, 185, 80, 0.15); color: var(--good); border-color: rgba(63, 185, 80, 0.4); }
.verdict-typical .verdict-badge { background: rgba(210, 153, 34, 0.15); color: var(--warn); border-color: rgba(210, 153, 34, 0.4); }
.verdict-high .verdict-badge { background: rgba(248, 81, 73, 0.15); color: var(--bad); border-color: rgba(248, 81, 73, 0.4); }
.verdict-building .verdict-badge,
.verdict-no_history .verdict-badge { background: var(--surface-2); color: var(--muted); }

/* Chart section */
.chart-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin: 2rem 0;
}
#price-chart { width: 100%; min-height: 320px; }

/* Featured cheapest card */
.featured {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-left: 3px solid var(--accent);
}
.featured-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.featured-price {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.leg {
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: 70px 90px 1fr;
    gap: 1rem;
    align-items: center;
}
.leg:last-child { padding-bottom: 0; }
.leg-empty { grid-template-columns: 70px 90px 1fr; }
.leg-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--muted);
}
.leg-date {
    font-size: 0.85rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.leg-route {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-variant-numeric: tabular-nums;
    flex-wrap: wrap;
}
.leg-route .iata {
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
}
.leg-route .time-strong {
    font-size: 1.1rem;
    font-weight: 600;
}
.leg-meta {
    grid-column: 3;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

@media (max-width: 600px) {
    .leg { grid-template-columns: 1fr; gap: 0.25rem; }
    .leg-meta { grid-column: 1; }
}

/* Clickable option list (andere heen-opties) */
.option-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.option-row {
    display: grid;
    grid-template-columns: 110px 1fr 1.4fr 1.6fr 1fr;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 1rem;
    text-align: left;
    width: 100%;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    background: transparent;
    color: var(--text);
    border-left: none; border-right: none; border-top: none;
    font-family: inherit;
}
.option-row:last-child { border-bottom: 0; }
.option-head {
    background: var(--surface-2);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 600;
}
.option-clickable {
    cursor: pointer;
    transition: background 0.12s;
}
.option-clickable:hover { background: rgba(68, 147, 248, 0.08); }
.option-clickable:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
.option-form { margin: 0; padding: 0; }
.option-form .option-row { border-bottom: 1px solid var(--border); }
.option-form:last-child .option-row { border-bottom: 0; }

@media (max-width: 700px) {
    .option-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.25rem 0.75rem;
    }
    .option-head { display: none; }
}

details { margin-top: 1rem; }
summary { cursor: pointer; color: var(--muted); padding: 0.5rem 0; }

@media (max-width: 600px) {
    header { padding: 1rem; }
    main { padding: 1rem; }
    .hero h1 { font-size: 1.5rem; }
    .field-row,
    .trip-form .field-row:nth-of-type(2),
    .trip-form .field-row:nth-of-type(3) {
        grid-template-columns: 1fr !important;
    }
    .field-row .arrow { display: none; }
}
