:root {
    --bg: #fafaf9;
    --surface: #ffffff;
    --text: #1c1917;
    --muted: #78716c;
    --border: #e7e5e4;
    --accent: #0b83d9;
    --radius: 8px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, monospace;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1917;
        --surface: #292524;
        --text: #f5f5f4;
        --muted: #a8a29e;
        --border: #44403c;
        --accent: #4ba8f0;
    }
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 var(--font);
}

a { color: var(--accent); }
code { font-family: var(--mono); font-size: 0.9em; }

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

.brand-mark {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    background: var(--accent);
}

.shell {
    max-width: 64rem;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.hero-intro h1 { margin: 0 0 0.25rem; font-size: 2rem; }
.hero-intro p { margin: 0; color: var(--muted); }

.error h1 { margin: 0; font-size: 3rem; }
.muted { color: var(--muted); }

.site-nav {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 1rem;
}
.site-nav form { margin: 0; }
.site-nav a { text-decoration: none; }
.site-nav a:hover { text-decoration: underline; }

.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
}
.link-button:hover { text-decoration: underline; }

.narrow { max-width: 28rem; }

.stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}
.stack label { font-weight: 600; }
.stack input[type="text"], .stack select { width: 100%; }
.stack button[type="submit"] { margin-top: 0.5rem; }

input[type="text"], select {
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

button[type="submit"]:not(.link-button) {
    padding: 0.5rem 1rem;
    border: 0;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

fieldset {
    margin: 0.5rem 0 0;
    padding: 0;
    border: 0;
}
legend { padding: 0; font-weight: 600; }
label.inline { display: inline-flex; gap: 0.375rem; margin-right: 1rem; font-weight: normal; }

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

.notice {
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.notice.error { border-color: #d92b2b; color: #b42323; }
.notice.success { border-color: #2da44e; color: #1a7f37; }
@media (prefers-color-scheme: dark) {
    .notice.error { color: #ff8182; }
    .notice.success { color: #56d364; }
}

/* Lists of projects, clients and tags */

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.crumb { margin: 0 0 0.25rem; font-size: 0.875rem; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
}
.toolbar input[type="search"], .toolbar input[type="text"] { flex: 1 1 16rem; }

input[type="search"] {
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.group h2 {
    margin: 1.5rem 0 0.5rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.rows {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.875rem;
}
.row + .row { border-top: 1px solid var(--border); }
.row form { margin: 0; }
.row.is-archived .row-title { color: var(--muted); }

.row-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    text-decoration: none;
}
.row-title:hover { text-decoration: underline; }

.row-meta {
    margin-left: auto;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    text-decoration: none;
}
.row-error { flex-basis: 100%; }

.inline-form {
    display: flex;
    flex: 1;
    gap: 0.5rem;
}
.inline-form input[type="text"] { flex: 1; min-width: 0; }

.swatch {
    flex: none;
    width: 0.75rem;
    height: 0.75rem;
}

.badge {
    padding: 0.0625rem 0.4375rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: normal;
    text-transform: none;
    letter-spacing: normal;
}

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

.field-error { margin: 0; color: #b42323; font-size: 0.875rem; }
@media (prefers-color-scheme: dark) { .field-error { color: #ff8182; } }

.palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0 0.75rem;
}
.palette-choice {
    position: relative;
    display: inline-flex;
    padding: 0.25rem;
    border: 2px solid transparent;
    border-radius: 999px;
    cursor: pointer;
}
.palette-choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.palette-choice .swatch { width: 1.5rem; height: 1.5rem; }
.palette-choice:has(input:checked) { border-color: var(--text); }
.palette-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

input.short { width: 8rem !important; }

.danger-zone {
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.danger-zone h2 { font-size: 1.125rem; }
.danger-zone form { margin-bottom: 1.25rem; }
.danger-zone p { margin: 0 0 0.5rem; }

a.button, button.secondary, button.danger {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
a.button { background: var(--accent); color: #fff; }
button[type="submit"].secondary {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}
button[type="submit"].danger { background: #d92b2b; color: #fff; }
.danger-link { color: #d92b2b; }

/* Reports ------------------------------------------------------------------ */

/* Chart colors: the validated categorical palette, light and dark steps
   (checked against these surfaces with the dataviz validator). Slots follow
   the entity, so a client keeps its color across ranges and filters. */
:root {
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --series-4: #eda100;
    --series-5: #e87ba4;
    --series-6: #008300;
    --series-7: #6250d6;
    --series-other: #898781;
    --grid: #e7e5e4;
    --axis: #c3c2b7;
}
@media (prefers-color-scheme: dark) {
    :root {
        --series-1: #3987e5;
        --series-2: #d95926;
        --series-3: #199e70;
        --series-4: #c98500;
        --series-5: #d55181;
        --series-6: #008300;
        --series-7: #9085e9;
        --series-other: #898781;
        --grid: #3a3532;
        --axis: #57534e;
    }
}

.series-1 { fill: var(--series-1); background: var(--series-1); }
.series-2 { fill: var(--series-2); background: var(--series-2); }
.series-3 { fill: var(--series-3); background: var(--series-3); }
.series-4 { fill: var(--series-4); background: var(--series-4); }
.series-5 { fill: var(--series-5); background: var(--series-5); }
.series-6 { fill: var(--series-6); background: var(--series-6); }
.series-7 { fill: var(--series-7); background: var(--series-7); }
.series-other { fill: var(--series-other); background: var(--series-other); }

.card {
    margin: 1.25rem 0;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.filter { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.875rem; }
.filter span { color: var(--muted); }
.filter select, .filter input { max-width: 14rem; }
.filter-reset { align-self: center; font-size: 0.875rem; }

input[type="date"] {
    padding: 0.4375rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.report-head { margin-bottom: 0.5rem; }
.range-nav { display: flex; align-items: center; gap: 0.75rem; }
.range-nav h1 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.range-nav .step {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    font-size: 1.25rem;
    line-height: 1;
    text-decoration: none;
}
.range-nav .step:hover { background: var(--surface); }

/* The one hero figure: same sans, proportional digits. */
.hero { margin: 0.75rem 0 0; font-size: 3.25rem; font-weight: 600; line-height: 1.1; }
.hero-sub { margin: 0.25rem 0 0; }

.viz-caption { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.875rem; }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem 1rem;
    margin: 0.75rem 0 0.5rem;
    padding: 0;
    list-style: none;
    font-size: 0.875rem;
}
.legend li { display: inline-flex; align-items: center; gap: 0.375rem; }
.legend-key { width: 0.625rem; height: 0.625rem; }

.viz-plot { position: relative; }
.viz-svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz-svg text { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.viz-svg .tick-y { text-anchor: end; }
.viz-svg .tick-x { text-anchor: middle; }
.viz-svg .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.viz-svg .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.viz-svg .bars g { transition: opacity 120ms; }
.viz-svg .bars:has(.is-active) g:not(.is-active) { opacity: 0.55; }
.viz-svg .hit { fill: transparent; cursor: default; outline: none; }
.viz-svg .hit:focus-visible { stroke: var(--accent); stroke-width: 2; }

/* On a phone the 720-wide chart is drawn at about half size, so its text is
   set larger in chart units, and every other column label is left out. */
@media (max-width: 600px) {
    .viz-svg text { font-size: 22px; }
    .viz-svg .tick-x.minor, .viz-svg .tick-y.zero { display: none; }
}

.viz-tip {
    position: absolute;
    z-index: 2;
    min-width: 11rem;
    max-width: 16rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    font-size: 0.8125rem;
    pointer-events: none;
}
.viz-tip-title { color: var(--muted); }
.viz-tip-total { margin-bottom: 0.25rem; font-size: 1rem; font-weight: 600; }
.viz-tip-row { display: flex; align-items: center; gap: 0.5rem; }
.viz-tip-row strong { font-variant-numeric: tabular-nums; }
.viz-tip-name { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
/* A short line key, not a box. */
.viz-tip-key { flex: none; width: 0.75rem; height: 2px; border-radius: 1px; }

.viz-table { margin-top: 0.75rem; font-size: 0.875rem; }
.viz-table summary { color: var(--accent); cursor: pointer; }
.table-scroll { overflow-x: auto; margin-top: 0.5rem; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.375rem 0.5rem; text-align: left; font-weight: normal; }
thead th { color: var(--muted); font-size: 0.8125rem; border-bottom: 1px solid var(--border); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.totals { padding: 0.5rem 0.75rem; }
.totals tbody + tbody { border-top: 1px solid var(--border); }
.totals .client-row th, .totals .client-row td { font-weight: 600; padding-top: 0.625rem; }
.totals .project-row th { padding-left: 1.5rem; }
.totals th .swatch { display: inline-block; margin-right: 0.375rem; vertical-align: -0.0625rem; }
.totals .project-row a { color: var(--text); text-decoration: none; }
.totals .project-row a:hover { text-decoration: underline; }

@media (max-width: 600px) {
    .shell { padding-top: 1.25rem; }
    .filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .filter { min-width: 0; }
    .filter select, .filter input { width: 100%; max-width: none; min-width: 0; }
    .filters button { justify-self: start; }
    .hero { font-size: 2.75rem; }
    .card { padding: 0.75rem; }
    .totals .hours { display: none; }
    .totals th, .totals td { padding-left: 0.25rem; padding-right: 0.25rem; }
    .totals .project-row th { padding-left: 1rem; }
}

.section-title { margin: 2.5rem 0 0.75rem; font-size: 1.125rem; }

.consent { margin-top: 1rem; }
.consent-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }

/* Entries ------------------------------------------------------------------ */

.entries-add { margin-left: auto; font-size: 0.875rem; padding: 0.375rem 0.875rem; }

.running-card { display: flex; align-items: center; gap: 1rem; }
.running-card > div { flex: 1; min-width: 0; }
.running-card p { margin: 0; }
.running-label { font-size: 0.8125rem; }
.running-what { display: flex; align-items: center; gap: 0.375rem; font-weight: 600; }
.running-duration { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.running-card form { margin: 0; }

.day { margin-top: 1.5rem; }
.day-head {
    display: flex;
    justify-content: space-between;
    margin: 0 0 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
}
.day-total { font-variant-numeric: tabular-nums; }

.entries {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.entry {
    display: grid;
    grid-template-columns: 12.5rem minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.875rem;
}
.entry + .entry { border-top: 1px solid var(--border); }
.entry-time { font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.entry-what { display: flex; flex-direction: column; min-width: 0; }
.entry-project { display: inline-flex; align-items: center; gap: 0.375rem; }
.entry-description, .entry-project { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-description { color: var(--muted); font-size: 0.875rem; }
.entry-tags { margin-top: 0.125rem; }
.entry-duration { font-variant-numeric: tabular-nums; font-weight: 600; }
.entry-duration.is-long { color: #b42323; }
@media (prefers-color-scheme: dark) { .entry-duration.is-long { color: #ff8182; } }
.entry-edit { font-size: 0.875rem; }
.entry.is-running .entry-duration { color: var(--accent); }

.undo { display: flex; align-items: center; gap: 0.5rem; }
.undo .link-button { font-weight: 600; }

.more { text-align: center; margin-top: 1.5rem; }

.time-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; width: 100%; }
.time-fields > div { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
input[type="datetime-local"] {
    padding: 0.4375rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
.entry-form input[type="text"] { width: 100%; }

@media (max-width: 600px) {
    .entry { grid-template-columns: minmax(0, 1fr) auto; }
    .entry-time { grid-column: 1 / -1; color: var(--muted); }
    .entry-what { grid-column: 1; grid-row: 2 / span 2; }
    .entry-duration { grid-column: 2; grid-row: 2; justify-self: end; }
    .entry-edit { grid-column: 2; grid-row: 3; justify-self: end; }
    .time-fields { grid-template-columns: 1fr; }
    .filter-search { grid-column: 1 / -1; }
}
