/*
 * FareGoal — navy #1F3557, gold #D4AF37, white.
 *
 * Navy does the work and gold is the jewel. That split is forced by contrast,
 * not taste: brand gold on white is 2.10:1, so it can never carry text in the
 * light theme. It appears there only as the logo, borders and fills. On the
 * navy surfaces of the dark theme it reaches 5.86:1 and becomes the accent.
 * Every pair below was measured, not eyeballed.
 */
:root {
    --bg: #e5eaf2;
    --surface: #ffffff;
    --text: #1f3557;
    /* Measured against --bg, not --surface: the marketing page puts muted text
       straight on the page background, where the old #5b6b85 was 4.47:1. */
    --muted: #55647d;
    --border: #d5dce8;
    --field: #f6f8fb;
    --accent: #1f3557;
    --accent-text: #ffffff;
    --gold: #d4af37;
    /* Gold deepened until it passes as text on --bg; the brand gold cannot. */
    --gold-ink: #80630f;
    --danger: #b3261e;
    --good: #80630f;
    --warn: #80630f;
    --logo-navy: #1f3557;
    --logo-gold: #d4af37;
    /* The marketing page's dark bands. Deliberately identical in both themes:
       they are brand surfaces, not UI, and gold only reads on navy. */
    --ink: #142338;
    --ink-text: #eef2f8;
    --ink-muted: #a9b8ce;
    --ink-border: #33496c;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* The brand navy becomes the panel here, on a deeper navy page. */
        --bg: #0d1726;
        --surface: #1f3557;
        --field: #16243a;
        --text: #eef2f8;
        --muted: #a9b8ce;
        --border: #33496c;
        --accent: #d4af37;
        --accent-text: #1f3557;
        --gold: #d4af37;
        --gold-ink: #d4af37;
        --danger: #ff9a92;
        --good: #d4af37;
        --warn: #d4af37;
        /* The globe has to invert on dark; the gold is legible either way. */
        --logo-navy: #eef2f8;
        --logo-gold: #d4af37;
        --ink: #142338;
        --ink-text: #eef2f8;
        --ink-muted: #a9b8ce;
        --ink-border: #33496c;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 2rem 1.25rem 4rem;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, -apple-system, 'Segoe UI', system-ui, sans-serif;
    line-height: 1.5;
}

body.centered {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 1.25rem;
}

.site-header,
main {
    max-width: 60rem;
    margin: 0 auto;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

h1 {
    margin: 0;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    letter-spacing: -0.02em;
}

/* Brand lockup. "Fare" medium, "Goal" bold — the weight shift carries the
   name without needing a second colour, which matters because brand gold
   cannot be read as text on white. */
.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.brand.stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.mark {
    width: 1.6em;
    height: 1.6em;
    flex: none;
    overflow: visible;
}

.brand.stacked .mark {
    width: 2.4em;
    height: 2.4em;
}

.wordmark {
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.word-fare {
    font-weight: 500;
}

.word-goal {
    font-weight: 800;
}

.tagline {
    margin: 0.25rem 0 0;
    color: var(--muted);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}

.panel h2 {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.panel h3 {
    margin: 1.5rem 0 0.4rem;
    font-size: 0.95rem;
}

.login {
    width: min(24rem, 100%);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.login button {
    margin-top: 0.75rem;
}

.banner {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
    border-radius: 0.7rem;
    padding: 0.7rem 0.9rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.usage {
    font-size: 0.85rem;
    color: var(--muted);
}

.usage.warn {
    color: var(--warn);
    font-weight: 600;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.85rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

label {
    font-size: 0.82rem;
    color: var(--muted);
}

input,
select {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 0.55rem;
    background: var(--field);
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button {
    padding: 0.6rem 1.1rem;
    border: none;
    border-radius: 0.55rem;
    background: var(--accent);
    color: var(--accent-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

button:hover:not(:disabled) {
    filter: brightness(1.08);
}

button:disabled {
    opacity: 0.6;
    cursor: default;
}

button.ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    font-weight: 500;
}

button.ghost.danger {
    color: var(--danger);
}

.hint {
    margin: 0 0 0.75rem;
    color: var(--muted);
    font-size: 0.87rem;
}

.cabins {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cabin-row {
    display: grid;
    grid-template-columns: auto 9rem 1fr 1fr;
    align-items: center;
    gap: 0.6rem;
}

.cabin-row label {
    font-size: 0.95rem;
    color: var(--text);
}

.cabin-row input[type='checkbox'] {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--accent);
}

.estimate {
    margin: 1rem 0 0.5rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.estimate.over {
    color: var(--danger);
    font-weight: 600;
}

.watch {
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 0.7rem;
    padding: 0.9rem 1rem;
    margin-bottom: 1rem;
}

.watch.retired {
    border-left-color: var(--border);
    opacity: 0.6;
}

.watch-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.watch h3 {
    margin: 0;
    font-size: 1.05rem;
}

.nickname {
    margin-left: 0.5rem;
    font-weight: 400;
    color: var(--muted);
    font-size: 0.9rem;
}

.watch-meta {
    margin: 0.15rem 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.cabin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.9rem;
    font-size: 0.9rem;
}

.cabin-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
    padding: 0.35rem 0.5rem 0.35rem 0;
    border-bottom: 1px solid var(--border);
}

.cabin-table td {
    padding: 0.5rem 0.5rem 0.5rem 0;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.cabin-table tr:last-child td {
    border-bottom: none;
}

.price {
    font-weight: 600;
}

.price.hit {
    color: var(--good);
}

.price.low {
    color: var(--accent);
}

.price.muted {
    font-weight: 400;
    color: var(--muted);
}

.total,
.basic {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--muted);
}

.basic {
    color: var(--warn);
}

.form-error {
    margin: 0.75rem 0 0;
    color: var(--danger);
    font-size: 0.9rem;
}

.form-error.good {
    color: var(--good);
}

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

.empty-state {
    margin: 0;
    color: var(--muted);
}

/* Summary tiles: the headline answer before the table of numbers. */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
}

.stat-value {
    font-size: 1.65rem;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.stat-detail {
    font-size: 0.8rem;
    color: var(--muted);
}

.stat-good {
    border-color: color-mix(in srgb, var(--good) 45%, transparent);
}

.stat-good .stat-value {
    color: var(--good);
}

.stat-notable {
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.stat-notable .stat-value {
    color: var(--accent);
}

.book-link {
    display: inline-block;
    padding: 0.35rem 0.7rem;
    margin-right: 0.4rem;
    border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
    border-radius: 0.55rem;
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.book-link:hover {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* Stacked at every width. Side by side, these overflow the table somewhere
   between the breakpoints and the second button silently disappears. */
.actions {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    align-items: stretch;
    white-space: nowrap;
}

.actions .book-link {
    margin-right: 0;
    text-align: center;
}

.history-table {
    font-size: 0.87rem;
}

.nowrap {
    white-space: nowrap;
}

.spark-toggle {
    display: block;
    margin-top: 0.3rem;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 0;
}

.spark {
    overflow: visible;
}

.spark-line {
    stroke: var(--muted);
}

.spark-line.falling {
    stroke: var(--good);
}

.spark-line.rising {
    stroke: var(--muted);
}

.chart-row td {
    padding: 0.5rem 0 1rem;
}

.chart-wrap {
    overflow-x: auto;
}

/* Everything inside the history chart is scoped to .chart-wrap. The marketing
   page has its own .chart, .dot and .band, and unscoped rules here bled into
   it — `.band { opacity: 0.15 }` made every section of the home page nearly
   invisible. Keep new chart rules under this prefix. */
.chart-wrap .chart {
    width: 100%;
    min-width: 20rem;
    height: 8rem;
}

.chart-wrap .chart-line {
    stroke: var(--accent);
    fill: none;
}

.chart-wrap .dot {
    fill: var(--accent);
}

.chart-wrap .band {
    fill: var(--muted);
    opacity: 0.15;
}

.chart-wrap .target-line {
    stroke: var(--good);
    stroke-width: 1.5;
    stroke-dasharray: 4 3;
}

.chart-wrap text.axis {
    fill: var(--muted);
    font-size: 10px;
    font-family: inherit;
}

.chart-wrap text.axis.target {
    fill: var(--good);
}

.chart-caption {
    margin: 0.35rem 0 0;
    font-size: 0.78rem;
    color: var(--muted);
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 34rem) {
    .cabin-row {
        grid-template-columns: auto 1fr;
    }

    /* Drop the typical band first, then the timestamp — both are reference
       detail, unlike the price, the target and the check button. */
    .cabin-table th:nth-child(4),
    .cabin-table td:nth-child(4) {
        display: none;
    }
}

@media (max-width: 27rem) {
    .cabin-table th:nth-child(5),
    .cabin-table td:nth-child(5) {
        display: none;
    }

    .cabin-table {
        font-size: 0.85rem;
    }

    .cabin-table button.ghost {
        padding: 0.3rem 0.55rem;
    }

    .book-link {
        padding: 0.3rem 0.55rem;
    }

    body {
        padding: 1.25rem 0.9rem 3rem;
    }

    .panel {
        padding: 1rem 0.85rem;
    }
}
