:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --border: #e3e6eb;
    --text: #1f2937;
    --muted: #6b7280;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --positive: #16a34a;
    --negative: #dc2626;
    --warn: #d97706;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #1f2937;
    color: #e5e7eb;
    padding: 1rem 0.5rem;
}

.sidebar h2 {
    color: #fff;
    font-size: 1.05rem;
    margin: 0.25rem 0.75rem 1rem 0.75rem;
}

.sidebar nav a {
    display: block;
    padding: 0.5rem 0.75rem;
    color: #d1d5db;
    border-radius: 4px;
    margin: 0.1rem 0;
}
.sidebar nav a:hover { background: #374151; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--accent); color: #fff; }

.content {
    padding: 1.5rem 2rem;
    max-width: 1100px;
}

h1 { margin: 0 0 1rem 0; font-size: 1.6rem; }
h2 { margin: 1rem 0 0.75rem 0; font-size: 1.25rem; }

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

table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
th { font-weight: 600; color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: #f9fafb; }

.amount { font-variant-numeric: tabular-nums; text-align: right; }
.amount.pos { color: var(--positive); }
.amount.neg { color: var(--negative); }

.badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge.unidentified { background: #fef3c7; color: #92400e; }
.badge.pretagged { background: #dbeafe; color: #1e40af; }
.badge.approved { background: #dcfce7; color: #166534; }

button, .btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:disabled { background: #9ca3af; cursor: not-allowed; }
button.secondary { background: #e5e7eb; color: var(--text); }
button.secondary:hover { background: #d1d5db; }
button.danger { background: var(--negative); }

input[type=text], input[type=number], input[type=date], select {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 180px;
    background: #fff;
}

label { display: block; margin: 0.5rem 0 0.25rem 0; font-weight: 500; color: var(--muted); font-size: 0.85rem; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.col { flex: 1; min-width: 200px; }

.muted { color: var(--muted); }
.error { color: var(--negative); }
.warn { color: var(--warn); }
.success { color: var(--positive); }

.person-switcher {
    background: #111827;
    border: 1px solid #374151;
    border-radius: 4px;
    margin: 0 0.25rem 1rem 0.25rem;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.person-switcher label {
    color: #9ca3af;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0;
}
.person-switcher select {
    flex: 1;
    background: #1f2937;
    color: #e5e7eb;
    border: 1px solid #374151;
    min-width: 0;
}
.person-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
    vertical-align: middle;
}

.colour-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}
.swatch-btn {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    border: 2px solid rgba(0,0,0,0.05);
    cursor: pointer;
    padding: 0;
}
.swatch-btn:hover { transform: scale(1.08); }
.swatch-btn.selected { border-color: #111827; box-shadow: 0 0 0 1px #fff inset; }

tr.archived td { opacity: 0.55; }

.bulk-bar { background: #eff6ff; border-color: #93c5fd; }
.bulk-bar .col { display:flex; flex-direction:column; gap:0.25rem; }
.bulk-bar select { background:#fff; }
tr.row-selected td { background: #eff6ff; }

.tag-pill, .cat-pill {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 10px;
    color: #fff;
    font-size: 0.75rem;
    margin: 0 0.2rem 0.2rem 0;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}
.tag-pill button {
    background: rgba(255,255,255,0.25);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    line-height: 12px;
    margin-left: 0.25rem;
    padding: 0;
    cursor: pointer;
    font-size: 0.7rem;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    color: var(--text);
    font-weight: 500;
    font-size: 0.9rem;
}
.inline-check input[type=checkbox] { margin: 0; }

code {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 0.85rem;
    background: #f3f4f6;
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
}
.auth-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem 2rem;
    width: min(420px, 100%);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.auth-panel h1 { font-size: 1.3rem; margin-bottom: 1rem; }
.auth-panel .field { margin-bottom: 0.75rem; }
.auth-panel .field label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.25rem; }
.auth-panel .field input { width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 4px; font-size: 0.95rem; }
.auth-panel button[type="submit"] { width: 100%; margin-top: 0.5rem; }
.auth-panel .error { color: var(--negative); margin-bottom: 0.75rem; }

.user-strip {
    border-top: 1px solid #374151;
    margin-top: 1rem;
    padding: 0.75rem;
    font-size: 0.8rem;
    color: #d1d5db;
}
.user-strip .muted { color: #9ca3af; display: block; margin-bottom: 0.4rem; }
.user-strip strong { color: #fff; }
.user-strip form { margin: 0; }
.user-strip button { padding: 0.3rem 0.6rem; font-size: 0.8rem; background: #374151; }
.user-strip button:hover { background: #4b5563; }

@media print {
    .sidebar, .no-print, #blazor-error-ui { display: none !important; }
    .app-shell { grid-template-columns: 1fr; }
    .content { padding: 0; max-width: none; }
    .panel { box-shadow: none; border-color: #ccc; page-break-inside: avoid; }
    a { color: inherit; text-decoration: none; }
    h1, h2, h3 { page-break-after: avoid; }
}

/* Scenario builder rows — labelled inline field groups so the row wraps
   readably and each input has an unambiguous descriptor above it. */
.sc-field {
    display: inline-flex;
    flex-direction: column;
    margin-right: 0.6rem;
    margin-bottom: 0.25rem;
    vertical-align: top;
}
.sc-field-label {
    font-size: 0.7rem;
    color: #6b7280;
    margin-bottom: 0.1rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.sc-row td {
    /* Allow inputs to wrap nicely within the cell */
    white-space: normal;
}
.sc-sub-row {
    background: #fafafa;
}
.sc-sub-row td:first-child {
    text-align: right;
    color: #6b7280;
    font-size: 0.85rem;
    padding-right: 0.75rem;
}
