/* Design tokens. Light is the base; the dark block redefines only the values. */
:root {
    color-scheme: light;

    --surface-0: #f4f3f0;
    --surface-1: #fcfcfb;
    --surface-2: #ffffff;

    --text-primary: #0b0b0b;
    --text-secondary: #52514e;
    --text-muted: #86847d;

    --border: #dedcd6;
    --border-strong: #c4c1b8;
    --chart-grid: #e6e4df;

    --accent: #2a78d6;
    --accent-ink: #ffffff;
    --danger: #c0362f;
    --success: #0f7a4a;

    --radius: 6px;
    --navbar-height: 52px;
    --gap: 16px;

    --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;

        --surface-0: #121211;
        --surface-1: #1a1a19;
        --surface-2: #232322;

        --text-primary: #ffffff;
        --text-secondary: #c3c2b7;
        --text-muted: #8e8d84;

        --border: #35342f;
        --border-strong: #4a4842;
        --chart-grid: #2e2d29;

        --accent: #3987e5;
        --accent-ink: #0b0b0b;
        --danger: #e66767;
        --success: #43b581;
    }
}

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

html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    background: var(--surface-0);
    color: var(--text-primary);
    font: 14px/1.5 var(--font-ui);
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* The navigation bar is fixed height; this is the only scrolling region. */
.content {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 24px;
}

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

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

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-inline {
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.field-label {
    color: var(--text-secondary);
    font-size: 12px;
}

.field-input {
    padding: 6px 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text-primary);
    font: inherit;
}

.field-input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.button {
    padding: 6px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text-primary);
    font: inherit;
    cursor: pointer;
}

.button:hover:not(:disabled) {
    border-color: var(--accent);
}

.button:disabled {
    opacity: 0.5;
    cursor: default;
}

.button-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.button-quiet {
    padding: 3px 8px;
    font-size: 12px;
}

.button-quiet.is-active {
    border-color: var(--accent);
    color: var(--accent);
}

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

.table-wrap {
    /* Wide tables scroll inside their own box; the page never scrolls sideways. */
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-1);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.table-caption {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    text-align: left;
}

.data-table th,
.data-table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-weight: 400;
}

.data-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface-1);
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--surface-2);
}

/* Scoped to the table so it outranks the `.data-table th` alignment above. */
.data-table .numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* A summed column, told apart from the values it adds up. */
.data-table .is-total {
    border-left: 1px solid var(--border);
    color: var(--text-primary);
    font-weight: 600;
}

/* Named for a screen reader, taking no space. Used where a column has a control
   but no label worth the width -- the transaction toggle in the user table. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
