/* Project & Invoice Manager – plain CSS, no build step */
:root {
    color-scheme: dark;
    --bg: #14171c;
    --card: #1c2027;
    --raised: #242a33;
    --text: #d6dae0;
    --muted: #8b93a1;
    --border: #2f3640;
    --accent: #6ea8fe;
    --accent-soft: #1f2d45;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--accent); }

.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .6rem 1.2rem;
    background: #0d0f13;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.topbar .brand { color: var(--text); font-weight: 600; text-decoration: none; }
.topbar .notice { margin-left: auto; font-size: .8rem; color: var(--warn); }

.shell { display: flex; min-height: calc(100vh - 44px); }

.sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--card);
    border-right: 1px solid var(--border);
}
.sidebar ul { list-style: none; margin: 0; padding: .5rem 0; }
.sidebar a {
    display: block;
    padding: .45rem 1.2rem;
    color: var(--text);
    text-decoration: none;
}
.sidebar a:hover { background: var(--raised); }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.content { flex: 1; padding: 1.2rem 1.6rem; min-width: 0; }
.content h1 { margin: 0 0 1rem; font-size: 1.5rem; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem 1.2rem;
    margin-bottom: 1rem;
}
.card h2 { margin: 0 0 .6rem; font-size: 1.1rem; }
.placeholder { color: var(--muted); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .4rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-weight: 600; white-space: nowrap; }
.table.compact { width: auto; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.status-icon { width: 2rem; }

.flash { padding: .6rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid var(--border); }
.flash-ok { background: #13281b; border-color: #22543a; color: var(--ok); }
.flash-error { background: #2c1618; border-color: #5c2a2e; color: var(--bad); }
.flash-warn { background: #2b2410; border-color: #5c4a14; color: var(--warn); }

.debug { background: #0d0f13; color: var(--text); border: 1px solid var(--border); padding: 1rem; border-radius: 6px; overflow: auto; font-size: .8rem; }

/* View as user banner */
.viewas-bar {
    display: flex; align-items: center; gap: 1rem;
    padding: .5rem 1.2rem;
    background: #3b2a06; color: var(--warn);
    border-bottom: 1px solid #5c4a14;
}
.viewas-bar form { margin: 0 0 0 auto; }

/* Topbar user box */
.topbar .user { display: flex; align-items: center; gap: .8rem; font-size: .9rem; }
.topbar .user a { color: var(--text); }
.topbar form { margin: 0; }

/* Forms */
.form { max-width: 420px; }
.form label { display: block; margin: 0 0 .9rem; }
.form label > span { display: block; margin-bottom: .25rem; color: var(--muted); font-size: .9rem; }
.form label.check { display: flex; align-items: center; gap: .5rem; }
input[type=text], input[type=email], input[type=password], input[type=url] {
    width: 100%;
    padding: .5rem .6rem;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.code { font-family: ui-monospace, monospace; font-size: 1.3rem; letter-spacing: .3em; text-align: center; }

.btn {
    display: inline-block;
    padding: .5rem 1rem;
    font: inherit;
    color: #0d0f13;
    background: var(--accent);
    border: 0;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { filter: brightness(1.1); }
.btn-secondary { color: var(--text); background: var(--raised); border: 1px solid var(--border); }
.btn-small { padding: .2rem .6rem; font-size: .85rem; }
.btn-link { padding: 0; color: var(--accent); background: none; border: 0; font: inherit; cursor: pointer; text-decoration: underline; }

/* Login / setup pages without menu */
.auth-box { max-width: 440px; margin: 3rem auto; }
.muted { color: var(--muted); }
.qr { display: block; padding: 12px; background: #fff; border-radius: 6px; margin: .5rem 0 1rem; }
.secret { font-family: ui-monospace, monospace; word-break: break-all; }
.backup-codes { columns: 2; font-family: ui-monospace, monospace; font-size: 1.1rem; padding-left: 1.2rem; }

/* Admin */
select, input[type=number] {
    padding: .45rem .5rem;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
}
.form select { width: 100%; }
input.narrow { width: 6rem; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; align-items: start; }
.columns .card { margin-bottom: 0; }
.form-wide > p { margin-top: 1rem; }
.inline { display: flex; gap: .8rem; }
.inline label { flex: 1; }
.help { font-size: .85rem; margin: -.5rem 0 .9rem 1.6rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.actions form { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.tile { color: var(--text); text-decoration: none; }
.tile:hover { border-color: var(--accent); }
.badge { display: inline-block; margin-left: .4rem; padding: 0 .4rem; font-size: .75rem; border: 1px solid var(--border); border-radius: 4px; color: var(--muted); }
tr.inactive td { color: var(--muted); }
.warn { color: var(--warn); }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: .8rem; }
.filters label > span { display: block; color: var(--muted); font-size: .9rem; }
.nowrap { white-space: nowrap; }
td.details { font-family: ui-monospace, monospace; font-size: .8rem; word-break: break-word; }
.pager { display: flex; gap: 1rem; justify-content: center; margin: 1rem 0 0; }

/* Data pages */
textarea {
    width: 100%;
    padding: .5rem .6rem;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
}
input[type=date], input[type=file] {
    padding: .4rem .5rem;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    color-scheme: dark;
}
.table input[type=text], .table select { width: 100%; }
input.medium { width: 9rem; }
.table input.narrow, .table input.medium { width: auto; max-width: 9rem; }
.push-right { margin-left: auto; }
.pre { white-space: pre-wrap; }
.help-block { font-size: .85rem; margin-top: -.4rem; }
.table tfoot th { border-top: 2px solid var(--border); border-bottom: 0; }
.table tfoot th.num { text-align: right; }
.btn-danger { color: #fff; background: #b4232c; }
.inline-form { display: flex; gap: .5rem; align-items: center; margin: 0; }

.dir { display: inline-block; min-width: 4.2rem; padding: 0 .4rem; border-radius: 4px; font-size: .78rem; text-align: center; }
.dir-in { background: #3a2318; color: #fdba74; }
.dir-out { background: #15302a; color: #6ee7b7; }
.status { display: inline-block; padding: 0 .45rem; border-radius: 4px; font-size: .78rem; white-space: nowrap; }
.status-paid { background: #13281b; color: var(--ok); }
.status-partial { background: #2b2410; color: var(--warn); }
.status-unpaid { background: #2c1618; color: var(--bad); }
.status-overpaid { background: #2a1838; color: #d8b4fe; }

.items .item-row td { border-bottom: 0; padding-top: .6rem; }
.items .alloc-row td { padding-top: 0; color: var(--muted); font-size: .9rem; }
.items .alloc-row a { color: var(--accent); }
.alloc { font-variant-numeric: tabular-nums; white-space: nowrap; }
.alloc-none { color: var(--bad); }
.alloc-part { color: var(--warn); }
.alloc-full { color: var(--ok); }

.item-form { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.item-form h3 { margin: 0 0 .6rem; font-size: 1rem; }
.item-fields { display: flex; flex-wrap: wrap; gap: .6rem; }
.item-fields label > span { display: block; color: var(--muted); font-size: .85rem; }
.item-fields input, .item-fields select { width: 100%; }
.item-fields .w-xs { width: 4.5rem; }
.item-fields .w-sm { width: 7rem; }
.item-fields .w-md { width: 9.5rem; }
.item-fields .w-lg { flex: 1 1 14rem; }
.new-row td { background: var(--raised); }
.ticks { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.ticks label { margin: 0; }
.share-row { display: flex; align-items: center; gap: .6rem; }
.share-row > span { flex: 1; margin: 0; }

/* Phase 6: badges, colour checks, checks, comments, dashboard */
.menu-badge { display: inline-block; margin-left: .5rem; min-width: 1.4rem; padding: 0 .35rem; border-radius: 9px; background: var(--warn); color: #0d0f13; font-size: .75rem; font-weight: 700; text-align: center; }
.check-ok { color: var(--ok); }
.check-bad { color: var(--bad); font-weight: 600; text-decoration: underline dotted; }
.comment { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.comment-resolved { opacity: .6; }
.comment-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .2rem; }
.comment-action { margin: 0 0 0 auto; }
.comment-form { margin-top: .8rem; max-width: none; }
.counters { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.counter { display: flex; flex-direction: column; gap: .2rem; }
.counter-number { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.counter-label { color: var(--text); }
.counter-warn { border-color: #5c4a14; }
.counter-warn .counter-number, .counter-warn .counter-label { color: var(--warn); }
.year-filter { margin-bottom: 1rem; }
.quick-assign select { max-width: 11rem; }

.tabs { display: flex; gap: .3rem; margin-bottom: .8rem; }
.tabs a { padding: .4rem .9rem; border: 1px solid var(--border); border-radius: 5px; color: var(--text); text-decoration: none; }
.tabs a.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Import */
.review { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.2fr); gap: 1rem; align-items: start; }
.review-file { position: sticky; top: 1rem; }
.review-file iframe { width: 100%; height: 80vh; border: 0; background: #fff; border-radius: 4px; }
.review-file img { max-width: 100%; background: #fff; border-radius: 4px; }
.review-form h3 { margin: 1rem 0 .4rem; font-size: 1rem; }
.review-items td { padding: .25rem .3rem; }
.review-items input, .review-items select { width: 100%; }
.review-items .memo-input { margin-top: .2rem; font-size: .85rem; }
.field-low { background: #2b2410 !important; border-color: #8a6d1a !important; }
.field-bad { background: #2c1618 !important; border-color: #a33 !important; }
.row-flag td { background: #2b2410; }
.raw-text { max-height: 50vh; overflow: auto; font-size: .8rem; white-space: pre; }
details.card summary { cursor: pointer; color: var(--muted); }
.import-status { display: inline-block; padding: 0 .45rem; border-radius: 4px; font-size: .78rem; border: 1px solid var(--border); white-space: nowrap; }
.import-needs_review, .import-error { color: var(--bad); border-color: #5c2a2e; }
.import-parsed, .import-new { color: var(--warn); border-color: #5c4a14; }
.import-imported, .import-linked { color: var(--ok); border-color: #22543a; }
.import-duplicate, .import-ignored { color: var(--muted); }
.link-row { margin: .4rem 0; gap: .6rem; flex-wrap: wrap; }
@media (max-width: 1100px) { .review { grid-template-columns: 1fr; } .review-file { position: static; } }

@media (max-width: 700px) {
    .shell { flex-direction: column; }
    .sidebar { width: auto; border-right: 0; border-bottom: 1px solid var(--border); }
    .sidebar ul { display: flex; flex-wrap: wrap; }
    .sidebar a { padding: .35rem .7rem; }
}

/* Import templates */
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; white-space: pre; tab-size: 2; }
.row-template td strong { color: #8fd18f; }
