/* Admin styling. Deliberately small and dependency-free: the admin area is
   four screens of forms and tables used by one or two people a few times a
   year, so a CSS framework would outweigh what it is styling. */

:root {
    --bg: #FAF7F2;
    --surface: #FFFFFF;
    --text: #1a1a1a;
    --muted: #747474;
    --line: #e7e2d9;
    --accent: #7FA87E;
    --accent-soft: #C7DDBC;
    --accent-wash: rgba(163, 192, 162, 0.18);
    --danger: #c0392b;
    --warn: #b7791f;
    --radius: 18px;
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Top bar ──────────────────────────────────────────────────────────── */
.topbar {
    display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
    padding: .85rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: inherit; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
}
.brand strong { display: block; font-size: .95rem; line-height: 1.2; }
.brand small { display: block; font-size: .72rem; color: var(--muted); }

.nav { display: flex; gap: .35rem; flex-wrap: wrap; }
.nav a {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .4rem .8rem; border-radius: 999px;
    text-decoration: none; color: var(--muted); font-size: .88rem;
}
.nav a:hover { background: var(--accent-wash); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent); color: #fff; font-weight: 600; }
.logout { margin-left: auto; }

.badge {
    min-width: 1.35rem; padding: 0 .35rem;
    border-radius: 999px; background: var(--warn); color: #fff;
    font-size: .72rem; font-weight: 700; text-align: center;
}
.nav a[aria-current="page"] .badge { background: rgba(255, 255, 255, .3); }

/* ── Layout ───────────────────────────────────────────────────────────── */
.page { max-width: 1180px; margin: 0 auto; padding: 1.5rem; display: grid; gap: 1.25rem; }
.grid-2 { display: grid; gap: 1.25rem; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); } }

.card {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.5rem;
}
.card-narrow { max-width: 420px; margin: 3rem auto; }
.card h1 { margin: 0 0 .35rem; font-size: 1.15rem; }
.card h2 { margin: 0 0 .5rem; font-size: .95rem; }

.muted { color: var(--muted); font-size: .85rem; margin: 0 0 1.25rem; }
.empty { color: var(--muted); font-size: .9rem; padding: 1.5rem 0; text-align: center; margin: 0; }
.hint {
    margin: 0 0 1rem; padding: .55rem .85rem; border-radius: 10px;
    background: #fdf6e3; color: #7a5c11; font-size: .85rem;
}
code { background: var(--accent-wash); padding: .05rem .3rem; border-radius: 4px; font-size: .85em; }

/* ── Forms ────────────────────────────────────────────────────────────── */
.stack { display: grid; gap: .8rem; }
.field { display: grid; gap: .3rem; }
.field-row { display: grid; gap: .8rem; grid-template-columns: 1fr 1fr; }
label { font-size: .85rem; font-weight: 500; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; font-size: .88rem; }

input[type="text"], input[type="number"], input[type="password"], input[type="file"], select {
    font: inherit; font-size: .9rem;
    padding: .45rem .6rem;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface); color: var(--text);
    width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type="color"] { width: 42px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.input-narrow { width: 5rem; }

.btn {
    font: inherit; font-size: .88rem; cursor: pointer;
    padding: .45rem 1rem; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-danger { color: var(--danger); border-color: #f0d8d4; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-quiet { border-color: transparent; color: var(--muted); }
.btn-small { padding: .25rem .7rem; font-size: .8rem; }

/* ── Feedback ─────────────────────────────────────────────────────────── */
.flash { padding: .7rem 1rem; border-radius: 12px; font-size: .88rem; }
.flash-ok { background: var(--accent-wash); color: #2f5c2e; }
.flash-err { background: #fbeae7; color: #8c2c20; }
.inline-error { color: var(--danger); font-size: .85rem; margin: 0 0 .5rem; }

.result { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1rem; margin: 0 0 .75rem; }
.kv div { display: flex; justify-content: space-between; gap: .5rem; }
.kv dt { color: var(--muted); font-size: .82rem; }
.kv dd { margin: 0; font-weight: 600; font-size: .88rem; }
.pos { color: #4a8c48; }
.neg { color: var(--danger); }

/* ── Tables ───────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
    text-align: left; font-size: .74rem; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted); font-weight: 600;
    padding: .45rem .5rem; border-bottom: 1px solid var(--line);
}
.table td { padding: .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table small { display: block; font-size: .72rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.row-open { background: #fffdf5; }

/* A form cannot be a child of <tr>, so the cost-centre rows use display roles
   to keep the markup valid while still laying out as a table row. */
.table tr > form { display: contents; }

.tag {
    display: inline-block; padding: .1rem .5rem; border-radius: 999px;
    font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.tag-ok { background: var(--accent-wash); color: #2f5c2e; }
.tag-warn { background: #fdf1d8; color: #7a5c11; }
.tag-open { background: #f0eeea; color: var(--muted); }
.tag-in { background: #e6f0e5; color: #2f5c2e; }
.tag-out { background: #f3efe8; color: #6b5a3e; }

.table form { margin: 0; }
