:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #667085;
    --border: #e1e4ea;
    --accent: #1f5fd6;
    --accent-soft: #e8effc;
    --danger: #c62828;
    --danger-soft: #fdecec;
    --warn: #b26a00;
    --warn-soft: #fff4e0;
    --ok: #1b7f3b;
    --ok-soft: #e6f4ea;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .75rem; }

/* ---------- Top bar ---------- */
.topbar {
    background: #14213d;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar .inner {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 16px;
    height: 52px;
    max-width: 1400px;
    margin: 0 auto;
}
.brand { font-weight: 700; color: #fff; text-decoration: none; white-space: nowrap; }
.nav {
    display: flex;
    gap: .25rem;
    overflow-x: auto;
    flex: 1;
    scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
    color: #c9d3e8;
    text-decoration: none;
    padding: .4rem .65rem;
    border-radius: 6px;
    white-space: nowrap;
    font-size: .95rem;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a.active { color: #fff; background: rgba(255,255,255,.16); }
.logout button {
    background: none;
    border: 0;
    color: #c9d3e8;
    font: inherit;
    font-size: .9rem;
    cursor: pointer;
    white-space: nowrap;
}

/* ---------- Layout ---------- */
.page { max-width: 1400px; margin: 0 auto; padding: 16px; }
.page.narrow { max-width: 720px; }

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
}
.toolbar .spacer { flex: 1; }

.flash {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    background: var(--ok-soft);
    color: var(--ok);
}
.flash.warning { background: var(--warn-soft); color: var(--warn); }
.flash.error { background: var(--danger-soft); color: var(--danger); }

.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 40px;
    padding: .45rem .9rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .95rem;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { border-color: #c4c9d4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #194fb4; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 32px; padding: .25rem .6rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }

.badge {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .8rem;
    background: var(--accent-soft);
    color: var(--accent);
    white-space: nowrap;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.grey { background: #eef0f3; color: var(--muted); }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) {
    .form-grid.two { grid-template-columns: 1fr 1fr; }
    .form-grid .full { grid-column: 1 / -1; }
}
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; font-size: 1rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date],
input[type=time], input[type=number], select, textarea {
    width: 100%;
    min-height: 44px;
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    color: inherit;
}
input[type=color] { width: 60px; height: 40px; border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
input[type=checkbox] { width: 20px; height: 20px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.hint { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
.error { color: var(--danger); font-size: .85rem; margin-top: .25rem; }
.weekdays { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.form-actions { display: flex; gap: .5rem; margin-top: 1.25rem; flex-wrap: wrap; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr.dim td { color: var(--muted); }

/* ---------- Login ---------- */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { text-align: center; }

/* ---------- Import ---------- */
.dropzone {
    border: 2px dashed #b9c2d3;
    border-radius: var(--radius);
    padding: 2.5rem 1rem;
    text-align: center;
    background: var(--surface);
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.dropzone.over { background: var(--accent-soft); border-color: var(--accent); }
.dropzone strong { display: block; font-size: 1.1rem; margin-bottom: .25rem; }

/* ---------- Driver trip cards ---------- */
.day-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.day-nav h1 { margin: 0; text-align: center; font-size: 1.2rem; }
.day-nav .btn { min-width: 44px; justify-content: center; }
.trip {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    overflow: hidden;
    border-left: 5px solid var(--accent);
}
.trip.fixed { border-left-color: #7c3aed; }
.trip-head { display: flex; align-items: baseline; gap: .75rem; padding: 12px 14px 4px; }
.trip-time { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.trip-meta { color: var(--muted); font-size: .85rem; }
.stops { list-style: none; margin: 0; padding: 4px 14px 12px; }
.stop { display: flex; gap: .6rem; padding: 8px 0; border-top: 1px solid var(--border); }
.stop:first-child { border-top: 0; }
.stop-icon {
    flex: 0 0 26px; height: 26px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700; color: #fff; background: var(--ok);
}
.stop.dropoff .stop-icon { background: var(--danger); }
.stop-body { flex: 1; min-width: 0; }
.stop-addr { font-weight: 600; color: var(--text); text-decoration: none; display: block; }
.stop-addr:active { color: var(--accent); }
.stop-sub { color: var(--muted); font-size: .875rem; }
.trip-notes { padding: 0 14px 12px; font-size: .9rem; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

/* ---------- Day board ---------- */
.board-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
#timeline { min-height: 300px; }
.board-layout { display: grid; gap: 16px; }
@media (min-width: 1100px) { .board-layout { grid-template-columns: 1fr 340px; } }
.details { position: sticky; top: 68px; align-self: start; }
.details h3 { margin: 0 0 .25rem; font-size: 1.05rem; }
.details dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem .75rem; margin: .75rem 0; font-size: .9rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.warnings { margin: .5rem 0; padding: 0; list-style: none; }
.warnings li { background: var(--warn-soft); color: var(--warn); padding: .35rem .6rem; border-radius: 6px; margin-bottom: .3rem; font-size: .875rem; }

.vis-timeline { border: 0 !important; font-family: inherit; }
.vis-labelset .vis-label .vis-inner { padding: 6px 10px; }
.group-label { line-height: 1.2; }
.group-label .name { font-weight: 600; }
.group-label .sub { font-size: .75rem; color: var(--muted); }
.vis-item.booking {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--text);
    border-radius: 6px;
    font-size: .8rem;
}
.vis-item.booking .vis-item-content { padding: 3px 6px; line-height: 1.25; }
.vis-item.booking.fixed { background: #f1eafe; border-color: #7c3aed; }
.vis-item.booking.warning { background: var(--warn-soft); border-color: var(--warn); }
.vis-item.booking.unassigned { background: #fff; border-style: dashed; }
.vis-item.booking.changed { box-shadow: inset 3px 0 0 #f59e0b; }
.vis-item.booking.vis-selected { border-color: #14213d; border-width: 2px; }
.vis-item.vis-background.off { background: repeating-linear-gradient(45deg, #f3d6d6, #f3d6d6 6px, #fbeaea 6px, #fbeaea 12px); }
.vis-item.vis-background.offhours { background: rgba(100, 110, 130, .08); }
.vis-item .lock { font-size: .7rem; }

/* ---------- Fixed trips ---------- */
.exceptions { list-style: none; margin: .6rem 0 0; padding: 0; font-size: .9rem; }
.exceptions li { padding: .2rem 0; }
form.inline { display: inline; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
.trip-actions { margin-top: .6rem; }
.trip-actions summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.row-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row-form input, .row-form select { width: auto; flex: 1 1 140px; min-height: 36px; padding: .3rem .5rem; }

/* ---------- Board extras ---------- */
.board-help { font-size: .875rem; }
.board-help li { margin-bottom: .3rem; }
.regular { background: #f1eafe; color: #6d28d9; padding: .35rem .6rem; border-radius: 6px; font-size: .875rem; margin: .5rem 0; }

/* Short trips are narrow on the timeline: let the label run past the box. */
.vis-item.booking .vis-item-overflow { overflow: visible; }
.vis-item.booking .vis-item-content { white-space: nowrap; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; background: var(--surface); padding: .45rem .8rem; font: inherit; font-size: .9rem; cursor: pointer; min-height: 40px; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- Board list view ---------- */
.list-group { padding: 12px 16px; }
.list-group h3 { margin: 0 0 .5rem; font-size: 1rem; }
.list-row {
    display: grid;
    grid-template-columns: 7.5rem 1fr minmax(9rem, 12rem);
    gap: .75rem;
    align-items: center;
    padding: .55rem .5rem;
    border-top: 1px solid var(--border);
    cursor: pointer;
    border-left: 3px solid transparent;
}
.list-row.fixed { border-left-color: #7c3aed; }
.list-row.selected { background: var(--accent-soft); }
.list-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.list-warn { color: var(--warn); font-size: .85rem; margin-top: .15rem; }
.list-move { min-height: 36px; padding: .3rem .5rem; }
.fixed-badge { background: #f1eafe; color: #6d28d9; }
@media (max-width: 640px) {
    .list-row { grid-template-columns: 1fr; gap: .35rem; }
}

/* Trip drag between drivers */
.vis-item.booking { cursor: grab; touch-action: none; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }
.drag-ghost {
    position: fixed; top: 0; left: 0; z-index: 100; pointer-events: none;
    background: #14213d; color: #fff; padding: .35rem .6rem; border-radius: 6px;
    font-size: .85rem; white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

/* ---------- Address suggestions ---------- */
.address-field { position: relative; }
.address-suggestions {
    position: absolute; left: 0; right: 0; z-index: 30; margin: 2px 0 0; padding: 4px 0; list-style: none;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 6px 16px rgba(16, 24, 40, .12); max-height: 280px; overflow-y: auto;
}
.address-suggestions li { padding: .55rem .75rem; cursor: pointer; }
.address-suggestions li[aria-selected="true"], .address-suggestions li:hover { background: var(--accent-soft); }
.address-suggestions li.empty { color: var(--muted); cursor: default; }
.address-status { font-size: .8rem; min-height: 1.1em; margin-top: .2rem; }
.address-status.ok { color: var(--ok); }
.address-status.pending { color: var(--warn); }

/* ---------- Date/time pickers ---------- */
.flatpickr-input[readonly] { background: #fff; cursor: pointer; }
.flatpickr-calendar { font-family: inherit; }
.vis-item.booking.manual { background: #e7f6ec; border-color: var(--ok); }
.danger-link { color: var(--danger) !important; }

/* Board date navigation: ‹ [date] › Weekday – one compact group. The date picker
   replaces the input with its own text field, which must not take the full width. */
.date-nav { display: flex; align-items: center; gap: .4rem; flex-wrap: nowrap; }
.date-nav input { width: 8.5rem; flex: 0 0 auto; text-align: center; }
.date-nav strong { white-space: nowrap; margin-left: .25rem; }
.date-nav .btn { min-width: 40px; justify-content: center; }
/* Inline date/time fields elsewhere (e.g. "Avlys én dag") */
.row-form .flatpickr-input { width: auto; flex: 1 1 140px; }
@media (max-width: 440px) {
    .date-nav { flex-wrap: wrap; }
    .date-nav strong { flex-basis: 100%; margin: .15rem 0 0; }
}

/* ---------- Report / printing ---------- */
.report { overflow-x: auto; }
@media print {
    .topbar, .no-print, .flash { display: none !important; }
    body { background: #fff; }
    .page { padding: 0; max-width: none; }
    .card { box-shadow: none; padding: 0; }
    table { page-break-inside: auto; }
    tr { page-break-inside: avoid; }
}

/* ---------- Trip details: side panel on wide screens, bottom sheet on narrow ---------- */
.details-head { display: flex; align-items: flex-start; gap: .5rem; }
.details-head h3 { flex: 1; }
.details-close {
    border: 0; background: #eef0f3; color: var(--text); width: 36px; height: 36px; border-radius: 50%;
    font-size: 1rem; cursor: pointer; flex: 0 0 auto;
}
.sheet-backdrop { display: none; }
@media (max-width: 1099px) {
    .details.open {
        position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 60;
        max-height: 85vh; overflow-y: auto; margin: 0;
        border-radius: 16px 16px 0 0; box-shadow: 0 -8px 24px rgba(0, 0, 0, .2);
        padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
        animation: sheet-up .18s ease-out;
    }
    .details.open::before {
        content: ""; display: block; width: 40px; height: 4px; border-radius: 2px;
        background: #cfd4dc; margin: 0 auto 10px;
    }
    body.sheet-open .sheet-backdrop {
        display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15, 23, 42, .35);
    }
    body.sheet-open { overflow: hidden; }
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }

/* Changed pickup time */
.retimed { color: var(--warn); font-weight: 600; }
.vis-item .retimed { font-weight: 400; }
tr.cancelled td:not(:last-child) { text-decoration: line-through; }
