/* M+R Travel Tracker */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #677085;
    --border: #dde1e8;
    --primary: #1f5fbf;
    --primary-hover: #194f9f;
    --danger: #b42318;
    --ok-bg: #e8f5ec;
    --ok-text: #1e6b38;
    --err-bg: #fdecea;
    --err-text: #9b1c13;
    --flight: #1f5fbf;
    --hotel: #7a4bc2;
    --restaurant: #b45309;
    --radius: 8px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171d;
        --surface: #1c2028;
        --text: #e6e9ef;
        --muted: #98a1b3;
        --border: #2f3542;
        --primary: #4d8ef0;
        --primary-hover: #6aa1f3;
        --danger: #f07167;
        --ok-bg: #173323;
        --ok-text: #8fdba7;
        --err-bg: #3a1a18;
        --err-text: #f4a29b;
        --flight: #6aa1f3;
        --hotel: #b294e6;
        --restaurant: #f0a54a;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

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

a { color: var(--primary); }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.92em; }
.muted { color: var(--muted); font-size: 0.9em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Header ─────────────────────────────────────────────── */

.app-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner {
    max-width: 1100px; margin: 0 auto; padding: 12px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.header-brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-user { color: var(--muted); font-size: 0.9em; }

.app-main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }

.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 1.5rem; }

/* ── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-block; padding: 7px 14px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font: inherit; font-size: 0.92rem; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--border); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.inline-form { display: inline; margin: 0; }

/* ── Alerts ─────────────────────────────────────────────── */

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }
.alert-error { background: var(--err-bg); color: var(--err-text); }

/* ── Trip list ──────────────────────────────────────────── */

.trip-table {
    width: 100%; border-collapse: collapse; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.trip-table th, .trip-table td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.trip-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.trip-table tbody tr:last-child td { border-bottom: none; }
.trip-table tr.is-past { opacity: 0.55; }
.trip-table .when { white-space: nowrap; }
.trip-table .actions { white-space: nowrap; text-align: right; }
.trip-title { font-weight: 600; }
.notes { margin-top: 4px; font-size: 0.88em; color: var(--muted); white-space: pre-line; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; border: 1px solid currentColor; }
.badge-flight { color: var(--flight); }
.badge-hotel { color: var(--hotel); }
.badge-restaurant { color: var(--restaurant); }

.empty { text-align: center; padding: 48px 16px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

@media (max-width: 760px) {
    .trip-table thead { display: none; }
    .trip-table, .trip-table tbody, .trip-table tr, .trip-table td { display: block; width: 100%; }
    .trip-table tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
    .trip-table td { border: none; padding: 4px 12px; }
    .trip-table td[data-label]::before {
        content: attr(data-label); display: block; font-size: 0.75rem; text-transform: uppercase; color: var(--muted);
    }
    .trip-table .actions { text-align: left; padding-top: 8px; }
}

/* ── Forms ──────────────────────────────────────────────── */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.trip-form { display: flex; flex-direction: column; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2, .grid-4 { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 760px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > span, .field > legend { font-size: 0.88rem; font-weight: 600; padding: 0; }
.req { font-style: normal; font-weight: 400; color: var(--muted); font-size: 0.8rem; margin-left: 4px; }
.hint { margin: -8px 0 0; font-size: 0.85rem; color: var(--muted); }

input[type=text], input[type=password], input[type=date], input[type=time], textarea {
    width: 100%; padding: 8px 10px; font: inherit; color: var(--text);
    background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
input:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
textarea { resize: vertical; }

.type-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.type-option input { position: absolute; opacity: 0; }
.type-option span {
    display: inline-block; padding: 7px 18px; border: 1px solid var(--border);
    border-radius: 999px; cursor: pointer; background: var(--bg);
}
.type-option input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.type-option input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.form-actions { display: flex; gap: 10px; }

/* ── Login ──────────────────────────────────────────────── */

.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
    width: 100%; max-width: 360px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 12px; padding: 28px;
}
.login-title { margin: 0; font-size: 1.4rem; }
.login-subtitle { margin: 4px 0 20px; color: var(--muted); }
.btn-ms { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 14px; }
.login-note { margin: 14px 0 0; font-size: 0.85rem; color: var(--muted); text-align: center; }
