/* =============================================================================
   Tour Bike Booking — admin panel styles
   Plain CSS on purpose: no npm, no build step. Edit and refresh.
   ========================================================================== */

:root {
    --navy: #16233b;
    --navy-soft: #1f3153;
    --navy-line: #2a3b5c;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --page: #f4f6fb;
    --card: #ffffff;
    --line: #e5e9f2;
    --line-soft: #eef1f7;
    --ink: #1f2937;
    --ink-soft: #556074;
    --muted: #8a93a6;
    --green: #15803d;
    --green-bg: #e8f8ef;
    --amber: #b45309;
    --amber-bg: #fff5e3;
    --red: #b91c1c;
    --red-bg: #fdecec;
    --purple: #6d28d9;
    --purple-bg: #f2ecfd;
    --blue-bg: #e9f1fe;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
    --sidebar-w: 236px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--page);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--ink); }

/* ------------------------------------------------------------------ shell */

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

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--navy);
    color: #c7d0e0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid var(--navy-line);
}
.brand svg { flex: 0 0 auto; color: #fff; }
.brand-text { line-height: 1.2; }
.brand-text strong { display: block; color: #fff; font-size: 15px; font-weight: 600; }
.brand-text span { font-size: 11px; color: #8fa0bd; }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-label {
    font-size: 10px;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #6f7f9c;
    padding: 14px 10px 6px;
}
.nav a, .nav button, .sidebar-foot button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 11px;
    margin-bottom: 2px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #c7d0e0;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.nav a:hover, .nav button:hover, .sidebar-foot button:hover { background: var(--navy-soft); color: #fff; text-decoration: none; }
.nav a.active { background: var(--blue); color: #fff; font-weight: 500; }
.nav a.active svg { color: #fff; }
.nav svg { flex: 0 0 18px; opacity: .9; }

.nav-group > button .caret { margin-left: auto; transition: transform .15s; }
.nav-group.open > button .caret { transform: rotate(90deg); }
.nav-sub { display: none; padding-left: 26px; }
.nav-group.open .nav-sub { display: block; }
.nav-sub a { padding: 7px 11px; font-size: 13px; }

.sidebar-foot { padding: 12px 10px 16px; border-top: 1px solid var(--navy-line); }
.sidebar-foot .who { display: flex; align-items: center; gap: 10px; padding: 8px 11px; font-size: 13px; }
.sidebar-foot .who span { color: #e2e8f4; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 0 22px;
    height: 58px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar h1 { font-size: 17px; }
.topbar .spacer { flex: 1; }
.hamburger { display: none; background: none; border: 0; cursor: pointer; color: var(--ink); padding: 6px; }

.page { padding: 20px 22px 44px; }

/* ------------------------------------------------------------------ cards */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    overflow: hidden;
}
.card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { font-size: 14.5px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
/* A grid child that runs the whole width, under the columns. */
.grid > .span-all { grid-column: 1 / -1; min-width: 0; }

/* ------------------------------------------------------------------ stats */

.stat {
    border-radius: var(--radius);
    padding: 15px 16px;
    border: 1px solid transparent;
}
.stat .k { font-size: 12.5px; font-weight: 600; opacity: .85; }
.stat .v { font-size: 27px; font-weight: 700; letter-spacing: -.5px; margin: 4px 0 2px; }
.stat .l { font-size: 12px; }
.stat.blue { background: var(--blue-bg); border-color: #d3e3fd; color: #1e40af; }
.stat.green { background: var(--green-bg); border-color: #cdeedd; color: #14532d; }
.stat.amber { background: var(--amber-bg); border-color: #f6e3bd; color: #7c2d12; }
.stat.purple { background: var(--purple-bg); border-color: #e3d9fb; color: #4c1d95; }
.stat a { color: inherit; opacity: .8; }

.metric { display: flex; justify-content: space-between; align-items: baseline; padding: 9px 0; }
.metric + .metric { border-top: 1px dashed var(--line); }
.metric .k { color: var(--ink-soft); }
.metric .v { font-weight: 600; font-size: 15px; }
.metric .v.green { color: var(--green); }
.metric .v.red { color: var(--red); }
.metric .v.big { font-size: 19px; }

/* ----------------------------------------------------------------- tables */

.table-wrap { width: 100%; overflow-x: auto; }

/* When a table is too wide to fit, the sideways scrollbar is the way to reach
   the rest of it — so make it obvious instead of the thin default. */
.table-wrap { scrollbar-width: thin; scrollbar-color: #c3cbdb transparent; }
.table-wrap::-webkit-scrollbar { height: 11px; }
.table-wrap::-webkit-scrollbar-track { background: #f2f5fa; border-radius: 6px; }
.table-wrap::-webkit-scrollbar-thumb {
    background: #c3cbdb;
    border: 2px solid #f2f5fa;
    border-radius: 6px;
}
.table-wrap::-webkit-scrollbar-thumb:hover { background: #a7b2c7; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.table th {
    text-align: left;
    font-size: 11px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    padding: 10px 14px;
    background: #fafbfd;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
table.table tbody tr:last-child td { border-bottom: 0; }
table.table tbody tr:hover { background: #fbfcfe; }
table.table tfoot td {
    padding: 11px 14px;
    background: #f7f9fc;
    border-top: 1px solid var(--line);
    font-weight: 600;
}
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* `table.table th` sets text-align:left and outranks a bare .num, so a numeric
   heading needs to say so explicitly or it sits over the wrong edge. */
table.table th.num, .repeater th.num, table.table tfoot td.num { text-align: right; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------------ pills */

.pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.pill.in_progress { background: var(--blue-bg); color: #1e40af; }
.pill.completed { background: var(--green-bg); color: var(--green); }
.pill.cancelled { background: #f1f3f7; color: #667085; }
.pill.yes { background: var(--green-bg); color: var(--green); }
.pill.no { background: #f1f3f7; color: #667085; }
.pill.due { background: var(--red-bg); color: var(--red); }
.pill.paid { background: var(--green-bg); color: var(--green); }

/* --------------------------------------------------------------- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: #f7f9fc; text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-danger { background: #fff; border-color: #f0c9c9; color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-icon { padding: 5px 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ----------------------------------------------------------------- forms */

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: 1 / -1; }

.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 5px;
}
.field label .req { color: #dc2626; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], select, textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid #d8dee9;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 13.5px;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
input[readonly], input:disabled, select:disabled {
    background: #f4f6fa;
    color: var(--ink-soft);
    cursor: not-allowed;
}
textarea { resize: vertical; min-height: 62px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.checkline input { width: auto; }

/* A field that only ever shows a calculated figure. */
.readout {
    padding: 8px 11px;
    border: 1px solid #dfe4ee;
    border-radius: 8px;
    background: #f4f6fa;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.error-text { color: var(--red); font-size: 12px; margin-top: 4px; }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: #e59a9a; }

.section-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 4px 0 12px;
}
.divider { height: 1px; background: var(--line-soft); margin: 20px 0 18px; }

/* --------------------------------------------------------------- filters */

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}
.filters .field { min-width: 140px; }
.filters .field.wide { min-width: 210px; flex: 1; }

/* ---------------------------------------------------------------- alerts */

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 14px;
    border-radius: 9px;
    margin-bottom: 16px;
    font-size: 13.5px;
    border: 1px solid;
}
.alert-success { background: var(--green-bg); border-color: #c6ead8; color: #14532d; }
.alert-error { background: var(--red-bg); border-color: #f3cccc; color: #7f1d1d; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ------------------------------------------------------------ pagination */

.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-top: 1px solid var(--line-soft);
}
.pagination .p-info { color: var(--muted); font-size: 12.5px; margin-right: auto; }
.pagination a, .pagination span.pg {
    display: inline-block;
    min-width: 32px;
    text-align: center;
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    font-size: 13px;
}
.pagination a:hover { background: #f4f7fc; text-decoration: none; }
.pagination span.pg.current { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.pagination span.pg.disabled { color: #c2c8d4; }

/* ------------------------------------------------------- tour form extras */

/* This table holds real inputs and date pickers, so it must keep its shape.
   Below min-width the wrapper scrolls sideways rather than crushing the fields. */
/* Sized so the whole row still fits a 1366px laptop, the smallest screen
   this is likely to run on. Anything narrower scrolls rather than squeezes. */
.repeater {
    width: 100%;
    min-width: 1010px;
    border-collapse: collapse;
    font-size: 13.5px;
}
.repeater th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    font-weight: 600;
    padding: 8px 8px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.repeater td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.repeater input, .repeater select { padding: 6px 9px; font-size: 13px; }
.repeater .col-vendor { width: 165px; }
.repeater .col-days { width: 68px; }
.repeater .col-num { width: 96px; }
.repeater .col-rate { width: 118px; }
.repeater .col-date { width: 146px; }
.repeater .col-act { width: 40px; text-align: center; }
.repeater tr.empty-row td { color: var(--muted); text-align: center; padding: 18px 8px; }

/* ------------------------------------------------------------- daily log */

/* Narrower than the hired table — no date pickers, just ticks. */
.repeater.daily { min-width: 860px; }
.repeater.daily .col-tick { width: 112px; text-align: center; }
.repeater.daily td.col-tick { text-align: center; }
.repeater.daily .col-date { width: 168px; }
.day-date { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }

/* A long tour scrolls inside the card instead of stretching the page. */
.daily-wrap { max-height: 520px; overflow-y: auto; }
.daily-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card);
    box-shadow: inset 0 -1px 0 var(--line);
}

.tick-head {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    text-transform: none;
    font-size: 11px;
    letter-spacing: .04em;
}
.tick-head span { max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------- crew settings */

.crew-head, .crew-row {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr) 132px 52px 118px;
    gap: 10px;
    align-items: center;
}
.crew-head {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    font-weight: 600;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
}
.crew-row { padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.crew-row:last-child { border-bottom: 0; }
.crew-label { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.crew-days {
    text-align: center;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}
.crew-row .checkline { font-size: 12.5px; color: var(--ink-soft); }

/* The bike lines reuse the crew grid, but the last column is money not a tick. */
.bike-grid .crew-head, .bike-grid .crew-row {
    grid-template-columns: minmax(0, 1fr) 110px 132px 78px 110px;
}
.bike-grid .crew-head span:nth-child(n+2),
.bike-grid .crew-days { text-align: right; }
.bike-grid .crew-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bike-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 12px;
    padding-top: 11px;
    border-top: 1px solid var(--line);
    font-size: 13.5px;
    color: var(--ink-soft);
}
.bike-total strong { font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }

.alert-warn { background: var(--amber-bg); color: var(--amber); }
.icon-btn {
    background: none;
    border: 0;
    color: #c2554f;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    line-height: 0;
}
.icon-btn:hover { background: var(--red-bg); }

.calc-box {
    background: #f8fafd;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.calc-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 13.5px; }
.calc-row + .calc-row { border-top: 1px dashed var(--line); }
.calc-row .lbl { color: var(--ink-soft); }
.calc-row .lbl small { display: block; color: var(--muted); font-size: 11.5px; }
.calc-row .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.calc-row.total { border-top: 2px solid var(--line); margin-top: 4px; padding-top: 11px; }
.calc-row.total .lbl, .calc-row.total .amt { font-size: 16px; font-weight: 700; color: var(--blue); }

.sticky-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid var(--line);
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    z-index: 5;
}

/* ------------------------------------------------------------ login page */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #16233b 0%, #22355a 55%, #2c4776 100%);
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(9, 17, 35, .35);
    padding: 28px 26px 24px;
}
.login-card .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; color: var(--navy); }
.login-card .logo strong { font-size: 17px; }
.login-card h1 { font-size: 18px; margin-bottom: 4px; }
.login-card p.sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; padding: 10px; }
.login-foot { text-align: center; color: #93a3c0; font-size: 12px; margin-top: 16px; }

/* --------------------------------------------------------------- summary */

.summary-head {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
    justify-content: space-between;
}
.kv { display: grid; grid-template-columns: 118px 1fr; gap: 8px 10px; font-size: 13.5px; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; font-weight: 500; }

.print-only { display: none; }

/* ----------------------------------------------------------------- print */

@media print {
    .sidebar, .topbar, .no-print, .sticky-actions, .pagination { display: none !important; }
    body { background: #fff; font-size: 12px; }
    .page { padding: 0; }
    .card { box-shadow: none; border: 1px solid #d5d9e2; break-inside: avoid; margin-bottom: 12px; }
    .print-only { display: block; }
    .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; }
    /* the "record a payment" panel is hidden on paper, so let the history use the width */
    .grid-main { grid-template-columns: 1fr; }
    a { color: #000; }
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main, .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform .18s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, .3);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .45);
        z-index: 50;
    }
    .hamburger { display: inline-flex; }
    .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .field.span-2, .field.span-3 { grid-column: auto; }
    .page { padding: 16px 14px 40px; }
}
