:root {
    color-scheme: light;
    --ink: #172b4d;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #146c5a;
    --brand-dark: #0e5144;
    --surface: #ffffff;
    --background: #f4f7f8;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--background);
    color: var(--ink);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
    min-height: 64px;
    padding: 12px max(24px, calc((100% - 1240px) / 2));
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.brand { color: var(--brand); font-size: 21px; font-weight: 800; letter-spacing: -.5px; }
.topbar nav { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; }
.topbar nav a, .link-button { color: #334155; font-size: 14px; }
.nav-user { color: var(--muted); font-size: 14px; }
.container { width: min(1240px, calc(100% - 40px)); margin: 32px auto 60px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 28px; letter-spacing: -.6px; }
h2 { margin-bottom: 18px; font-size: 18px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.page-heading p, .muted { color: var(--muted); margin-bottom: 0; }
.panel, .stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, .035);
}
.panel { padding: 22px; min-width: 0; }
.narrow { max-width: 520px; margin: 40px auto; }
.two-column { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(0, 1.4fr); gap: 20px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { padding: 18px 20px; }
.stat-card span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat-card strong { display: block; font-size: 24px; letter-spacing: -.4px; }
form label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 13px; color: #334155; }
input, select {
    display: block;
    width: 100%;
    min-height: 42px;
    margin-top: 6px;
    padding: 9px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}
input:focus, select:focus { outline: 2px solid rgba(20, 108, 90, .22); border-color: var(--brand); }
button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 15px;
    border: 0;
    border-radius: 7px;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
}
button:hover, .button:hover { background: var(--brand-dark); color: #fff; text-decoration: none; }
.button.secondary { background: #e7f2ef; color: var(--brand-dark); }
.button.secondary:hover { background: #d7e9e4; }
.button.danger { background: #fff1f2; color: #be123c; }
.button.danger:hover { background: #ffe4e6; }
.inline-form { display: inline; margin: 0; }
.link-button { min-height: 0; padding: 0; background: none; border: 0; font-weight: 400; }
.link-button:hover { color: var(--brand); background: none; text-decoration: underline; }
.notice { margin: 0 0 16px; padding: 12px 14px; border-radius: 8px; background: #eff6ff; color: #1e40af; }
.notice.success { background: #ecfdf5; color: #047857; }
.notice.error { background: #fff1f2; color: #be123c; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 650; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.amount { text-align: right; white-space: nowrap; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 99px; font-size: 12px; }
.badge.income { background: #ecfdf5; color: #047857; }
.badge.expense { background: #fff1f2; color: #be123c; }
.count { display: inline-block; margin-left: 5px; color: var(--muted); font-size: 12px; font-weight: 400; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-heading h2 { margin-bottom: 14px; }
.valuation-preview { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 8px; padding: 14px; border: 1px solid #cfe4de; border-radius: 8px; background: #f0f9f6; color: var(--brand-dark); }
.valuation-preview span { font-size: 13px; font-weight: 600; }
.valuation-preview strong { font-size: 20px; white-space: nowrap; }
.valuation-note { margin: 0 0 16px; font-size: 12px; }
.inventory-value { color: var(--brand-dark); font-size: 14px; text-align: right; }
.quick-links a { display: block; padding: 13px 0; border-top: 1px solid var(--line); }
.quick-links strong, .quick-links span { display: block; }
.quick-links span { margin-top: 2px; color: var(--muted); font-size: 13px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sale-line { display: grid; grid-template-columns: minmax(0, 1fr) 150px auto; align-items: end; gap: 12px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.sale-line label { margin-bottom: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.section-gap { margin-top: 20px; }
.small-button { min-height: 32px; padding: 5px 10px; font-size: 12px; white-space: nowrap; }
.item-edit-form { display: grid; grid-template-columns: minmax(150px, 1.4fr) minmax(100px, .8fr) minmax(80px, .6fr) minmax(110px, .8fr) minmax(110px, .8fr) auto; gap: 8px; align-items: end; margin: 0; }
.item-edit-form label { margin: 0; }
.item-edit-form input { min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.admin-sale-line { grid-template-columns: minmax(0, 1fr) 90px minmax(120px, .7fr); }

@media (max-width: 880px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .two-column { grid-template-columns: 1fr; }
    .item-edit-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
    .topbar { padding: 12px 18px; align-items: flex-start; flex-direction: column; }
    .topbar nav { gap: 12px; }
    .container { width: calc(100% - 28px); margin-top: 22px; }
    .stats { gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card strong { font-size: 20px; }
    .panel { padding: 17px; }
    .section-heading { align-items: flex-start; flex-direction: column; }
    .inventory-value { text-align: left; }
    .valuation-preview { align-items: flex-start; flex-direction: column; }
    .sale-line, .admin-sale-line { grid-template-columns: 1fr 105px; }
    .sale-line .danger { grid-column: 1 / -1; justify-self: start; }
}
