:root {
    --bg: #0a0a0a;
    --fg: #f0f0f0;
    --muted: #888;
    --accent: #4ade80;
    --line: #2a2a2a;
    --input-bg: #161616;
    --error: #f87171;
}

* { box-sizing: border-box; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.series-strip { color: var(--muted); font-size: 0.9rem; margin: -0.5rem 0 1rem; }
.series-strip a { color: var(--muted); }
.similar-toggle { display: block; margin: 0.5rem 0; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

#app {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

h1 {
    font-size: 2.5rem;
    margin: 0 0 1.5rem;
    font-weight: 600;
}

h1 .shared-tag {
    color: var(--muted);
    font-size: 1rem;
    font-weight: 400;
    margin-left: 0.5rem;
}

.create-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 4rem;
}

.create-form label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--muted);
}

input, button {
    font: inherit;
    border-radius: 6px;
    border: 1px solid var(--line);
    padding: 0.6rem 0.8rem;
    background: var(--input-bg);
    color: var(--fg);
}

input:focus {
    outline: none;
    border-color: var(--accent);
}

button {
    background: var(--accent);
    color: #000;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.eta-block {
    background: var(--input-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    text-align: center;
}

.eta-delta {
    font-size: 2rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.eta-arrival {
    color: var(--muted);
    font-size: 0.95rem;
}

.eta-empty {
    color: var(--muted);
    font-size: 1.1rem;
}

.chart-wrap {
    background: var(--input-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1rem;
    margin: 1.5rem 0;
    height: 320px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

th, td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--line);
}

th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }

.add-row td { padding: 0.5rem; }
.add-row input { width: 100%; }
.add-row .add-cell { width: 100px; }

.share-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--input-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.9rem;
}

.share-row code {
    flex: 1;
    overflow-x: auto;
    white-space: nowrap;
    color: var(--muted);
}

.share-row button {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.error { color: var(--error); margin-top: 1rem; }

.eta-block.cancelled {
    border-color: var(--error);
}
.eta-block.cancelled .eta-delta {
    color: var(--error);
}

.eta-block.warning {
    border-color: #fbbf24;
}
.eta-block.warning .eta-delta {
    color: #fbbf24;
}

.cancel-row {
    margin-top: 1.5rem;
    text-align: right;
}
button.danger {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
    font-weight: 500;
    padding: 0.4rem 0.9rem;
}
button.danger:hover { background: rgba(248, 113, 113, 0.1); filter: none; }

/* ---------- Landing page ---------- */

.blurb {
    color: var(--muted);
    font-size: 1.05rem;
    margin-bottom: 2.5rem;
}

.card-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr 1fr;
}

.card-single {
    max-width: 50%;
    width: 100%;
}

@media (max-width: 600px) {
    .card-grid { grid-template-columns: 1fr; }
    .card-single { max-width: 100%; }
}

.card {
    display: block;
    background: var(--input-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.5rem;
    color: var(--fg);
    text-decoration: none;
    transition: border-color 0.15s, transform 0.15s;
}

.card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.card h2 {
    margin: 0 0 0.5rem;
    font-size: 1.3rem;
    color: var(--accent);
}

.card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.section-heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 1rem;
}

.landing-section {
    margin-top: 2.5rem;
}

.api-band {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--line);
}

.api-band p {
    color: var(--muted);
    font-size: 0.95rem;
    margin: 0.5rem 0 0;
    line-height: 1.5;
}

.api-band a {
    color: var(--accent);
    text-decoration: none;
}

.api-band a:hover { text-decoration: underline; }

.subtitle {
    color: var(--muted);
    margin: -0.5rem 0 1.5rem;
}

/* ---------- Project create form ---------- */

textarea {
    font: inherit;
    border-radius: 6px;
    border: 1px solid var(--line);
    padding: 0.6rem 0.8rem;
    background: var(--input-bg);
    color: var(--fg);
    resize: vertical;
    min-height: 4em;
}
textarea:focus { outline: none; border-color: var(--accent); }

.create-form .help {
    color: var(--muted);
    font-size: 0.8rem;
    margin-top: 0.3rem;
    line-height: 1.4;
}

.row {
    display: flex;
    gap: 0.75rem;
}
.row > label { flex: 1; }
.row > input { flex: 1; }

/* ---------- Project read view ---------- */

.dod {
    color: var(--muted);
    font-style: italic;
    margin: -1rem 0 1.5rem;
    line-height: 1.5;
}

.eta-delta.big {
    font-size: 3rem;
    color: var(--accent);
}

.eta-detail {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.eta-age {
    color: var(--muted);
    font-size: 0.8rem;
    margin-top: 0.4rem;
    font-style: italic;
}

.eta-block.completed {
    border-color: var(--accent);
}
.eta-block.completed .eta-delta {
    color: var(--accent);
}

/* ---------- Project history / forms ---------- */

.add-row-project td { padding: 0.75rem 0.5rem; }
.estimate-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.estimate-form input[type="date"] { width: 9rem; }
.estimate-form input[type="text"] { flex: 1; min-width: 10rem; }

.target-row td {
    color: var(--accent);
    background: rgba(74, 222, 128, 0.05);
}

.note {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 0.2rem;
}

.target-update {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--input-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
}
.target-update label {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
}
.target-update .row {
    margin-top: 0.4rem;
    align-items: stretch;
}

/* ---------- Owner action row ---------- */

.owner-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.done-inline {
    display: flex;
    gap: 0.5rem;
}

/* ---------- Dashboard ---------- */

.add-item-row {
    display: flex;
    gap: 0.5rem;
    margin: 1.5rem 0;
}
.add-item-row input { flex: 1; }
.add-item-row button { white-space: nowrap; }

.dashboard-section {
    margin-top: 2rem;
}
.dashboard-section h2 {
    font-size: 1.15rem;
    margin: 0 0 0.5rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.dashboard-section table {
    margin: 0;
}

/* Counter cards: SVG thumbnails of the same share image, in a responsive
   grid. minmax bottoms out around 320px so the title/status/value stay
   legible on small screens, and the column count grows on wider viewports. */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.dashboard-card {
    position: relative;
    display: block;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border, #2a2a2a);
    background: #0a0a0a;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.dashboard-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}
.dashboard-card-img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1200 / 630;
}
.dashboard-card-remove {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #ddd;
    border: none;
    padding: 0;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
}
.dashboard-card:hover .dashboard-card-remove,
.dashboard-card-remove:focus {
    opacity: 1;
}
.dashboard-card-remove:hover {
    background: rgba(220, 60, 60, 0.85);
    color: #fff;
}

.row-link {
    color: var(--fg);
    text-decoration: none;
    font-weight: 500;
}
.row-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.row-action-col {
    width: 2.5rem;
    text-align: right;
}

.row-remove {
    background: transparent;
    color: var(--muted);
    border: none;
    padding: 0.2rem 0.5rem;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    font-weight: 400;
}
.row-remove:hover {
    color: var(--error);
    background: transparent;
    filter: none;
}

.dimmed {
    color: var(--muted);
    font-style: italic;
}

.tag-complete {
    color: var(--accent);
    font-weight: 500;
}

@media (max-width: 480px) {
    h1 { font-size: 1.8rem; }
    .eta-delta { font-size: 1.4rem; }
    #app { padding: 1.5rem 1rem 3rem; }
}

/* ---------- Datetime input pair (picker + ISO paste override) ---------- */

.datetime-pair {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.datetime-pair input[type="datetime-local"] {
    width: 100%;
}
.datetime-pair input.iso-paste {
    font-size: 0.85rem;
    font-family: ui-monospace, monospace;
    width: 100%;
    color: var(--muted);
}
.datetime-pair input.iso-paste:focus {
    color: var(--fg);
}

/* ---------- Add-measurement row (counter owner view) ---------- */

.measurement-add {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}
.measurement-add .field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--muted);
    flex: 1;
    min-width: 9rem;
}
.measurement-add button {
    height: 2.4rem;
    align-self: flex-end;
}

/* ---------- Mode toggle on create form ---------- */

fieldset.mode-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.75rem 1rem 1rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
fieldset.mode-group legend {
    padding: 0 0.4rem;
    color: var(--muted);
    font-size: 0.85rem;
}
.mode-option {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: var(--fg);
    cursor: pointer;
}
.seed-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-left: 1.5rem;
    border-left: 2px solid var(--line);
    margin-left: 0.25rem;
}
.seed-fields.hidden {
    display: none;
}

/* ---------- CSV import panel ---------- */

.csv-panel {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.csv-help {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.4;
}
.csv-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.csv-controls textarea {
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
    min-height: 6em;
}
.csv-controls input[type="file"] {
    font-size: 0.85rem;
    padding: 0.4rem 0;
    border: none;
    background: transparent;
}
.csv-actions {
    display: flex;
    justify-content: flex-end;
}
button.secondary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    font-weight: 500;
}
button.secondary:hover { background: rgba(74, 222, 128, 0.1); filter: none; }
.csv-status {
    color: var(--muted);
    font-size: 0.85rem;
    min-height: 1.2em;
}

/* ---------- Bulk import on owner view ---------- */

details.bulk-import {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--input-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
}
details.bulk-import summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--muted);
    list-style: revert;
}
details.bulk-import[open] summary {
    margin-bottom: 0.75rem;
    color: var(--fg);
}

/* ---------- Forecast settings + deadline forms ---------- */

.forecast-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.forecast-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    color: var(--muted);
    font-size: 0.9rem;
}
.forecast-form select {
    font: inherit;
    border-radius: 6px;
    border: 1px solid var(--line);
    padding: 0.5rem 0.7rem;
    background: var(--input-bg);
    color: var(--fg);
}
.forecast-form select:focus { outline: none; border-color: var(--accent); }
.forecast-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.eta-detail.strong {
    color: var(--fg);
    font-size: 1rem;
    margin-top: 0.6rem;
    font-weight: 500;
}

/* Inline denominator select in the rate row. Sized to sit flush with
   surrounding text so the dropdown reads as part of the unit "/sec". */
.rate-line .rate-denom {
    font: inherit;
    color: inherit;
    background: transparent;
    border: 1px solid var(--border, #444);
    border-radius: 4px;
    padding: 0 0.3em;
    margin: 0;
    cursor: pointer;
}

/* ---------- Measurements: add-row above the table; scrollable table ---------- */

.measurement-add-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin: 1.5rem 0 0.5rem;
    padding: 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
}
.measurement-add-row .field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--muted);
    flex: 1;
    min-width: 9rem;
}
.measurement-add-row button {
    height: 2.4rem;
    align-self: flex-end;
}

.table-scroll {
    max-height: 22rem;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--input-bg);
    margin: 0 0 1rem;
}
.table-scroll table.measurements {
    margin: 0;
}
.table-scroll table.measurements thead th {
    position: sticky;
    top: 0;
    background: var(--input-bg);
    z-index: 1;
    border-bottom: 1px solid var(--line);
}

/* Numeric columns are right-aligned (digits read better lined up on the
 * decimal). Apply by adding class="num" to both the <th> and matching
 * <td> in any table. Tabular-numerals make the column align cleanly even
 * when individual values have different glyph widths. */
th.num, td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---------- Wider chart-heavy views ---------- */

/* The read-only share view and the counter admin view both want the chart to
   use a big screen. `wide-view` carries the width/height; the spectator font
   tweaks below stay scoped to share-view only. */
body.share-view #app,
body.wide-view #app {
    max-width: 1100px;
}
body.share-view .chart-wrap,
body.wide-view .chart-wrap {
    height: 60vh;
    min-height: 360px;
}
body.share-view .eta-block {
    /* Slightly larger hero for read-only spectator mode. */
    padding: 2rem;
}
body.share-view .eta-delta {
    font-size: 2.5rem;
}
body.share-view .eta-delta.big {
    font-size: 4rem;
}

/* ---------- Chart toolbar + fullscreen ---------- */

.chart-wrap {
    position: relative;  /* anchor for the chart tool buttons */
}
.chart-tools {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.5rem;
    z-index: 2;
}
.chart-tool {
    background: rgba(22, 22, 22, 0.85);
    color: var(--fg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    backdrop-filter: blur(4px);
}
.chart-tool:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(22, 22, 22, 0.95);
    filter: none;
}
.chart-tool.active {
    border-color: var(--accent);
    color: var(--accent);
}

.chart-wrap.fullscreen {
    position: fixed;
    inset: 1rem;
    height: auto;
    z-index: 100;
    box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.6);
    padding: 1.5rem;
}
/* When a chart is fullscreen, hide page scroll so it really takes over. */
body.chart-fullscreen {
    overflow: hidden;
}
/* Dim/disable the page underneath via a fixed overlay rather than a
 * `filter:` on #app. Filters (and transforms, perspective, etc.) create a
 * containing block for fixed-position descendants — which would constrain
 * our fullscreen chart back to #app's max-width. The overlay is a sibling
 * z-layer instead, leaving the chart's position:fixed pinned to the viewport.
 */
body.chart-fullscreen::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99;
    pointer-events: auto;
}
