:root {
    --bg: #faf7f1;
    --sidebar: #f7f3ea;
    --surface: #ffffff;
    --text: #2b2f36;
    --muted: #6b7280;
    --border: #e6e0d4;
    --primary: #1b2747;
    --primary-dark: #0f1830;
    --highlight: #f0e6cc;
    --danger: #b91c1c;
    --success-bg: #e7f6ec;
    --success-text: #166534;
    --error-bg: #fdecec;
    --error-text: #991b1b;
}

* {
    box-sizing: border-box;
}

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

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1,
.brand {
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
}

h1 {
    font-size: 1.6rem;
    margin: 0 0 0.5rem;
}

h2 {
    font-size: 1.15rem;
    margin: 1.5rem 0 0.75rem;
}

.card h2 {
    margin-top: 0;
}

/* Layout */

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    flex: 0 0 220px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
}

.sidebar-head {
    position: sticky;
    top: 0;
    padding: 1.5rem 0.75rem;
}

.brand {
    display: block;
    padding: 0 0.5rem 1.5rem;
    font-size: 1.3rem;
    color: var(--text);
}

.brand:hover {
    text-decoration: none;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.side-nav hr {
    width: 100%;
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.5rem 0;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.nav-group summary,
.nav-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.5rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    list-style: none;
}

.nav-heading {
    cursor: default;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-group summary::after {
    content: "";
    border: 4px solid transparent;
    border-top-color: currentColor;
    margin-top: 4px;
}

.nav-group[open] summary::after {
    border-top-color: transparent;
    border-bottom-color: currentColor;
    margin-top: -4px;
}

.nav-sub {
    display: block;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    color: var(--muted);
    font-size: 0.93rem;
}

.nav-sub:hover {
    background: var(--highlight);
    color: var(--text);
    text-decoration: none;
}

.nav-sub.active {
    color: var(--text);
    font-weight: 700;
}

.side-nav .disabled {
    color: #b3ada2;
    cursor: default;
}

.side-nav .disabled:hover {
    background: none;
}

.nav-toggle,
.nav-toggle-label {
    display: none;
}

.container {
    flex: 1;
    min-width: 0;
    max-width: 1100px;
    padding: 1.5rem 2rem;
}

@media (max-width: 760px) {
    .shell {
        flex-direction: column;
    }

    .sidebar {
        flex: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .sidebar-head {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        padding: 0.6rem 1rem;
    }

    .brand {
        padding: 0;
    }

    .nav-toggle-label {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 40px;
        height: 40px;
        padding: 8px;
        cursor: pointer;
    }

    .nav-toggle-label span {
        display: block;
        height: 2px;
        background: var(--text);
        border-radius: 2px;
    }

    .side-nav {
        display: none;
        width: 100%;
        padding-top: 0.5rem;
    }

    .nav-toggle:checked ~ .side-nav {
        display: flex;
    }

    .container {
        padding: 1rem;
    }
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

details.card summary {
    cursor: pointer;
    font-weight: 600;
}

.muted,
.hint,
.empty {
    color: var(--muted);
}

.muted {
    margin: 0;
}

.hint {
    font-size: 0.9rem;
}

/* Tables */

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

.table th,
.table td {
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.table th {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
}

.table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.statement .section td {
    padding-top: 0.9rem;
    font-weight: 700;
    border-bottom: none;
}

.table .total td {
    font-weight: 700;
    border-top: 2px solid var(--text);
}

.item-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.item:last-child {
    border-bottom: none;
}

.item:hover {
    background: var(--highlight);
    text-decoration: none;
}

.item strong,
.item span {
    display: block;
}

.item span {
    font-size: 0.85rem;
}

.list {
    padding-left: 1.2rem;
}

/* Forms */

.form {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-width: 480px;
}

.form label {
    margin-top: 0.75rem;
    font-weight: 600;
}

.form input[type="text"],
.form input[type="number"] {
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}

.actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.button {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.button:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.button-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.button-danger:hover {
    background: var(--danger);
    color: #fff;
}

.danger-zone {
    margin-top: 2rem;
}

/* Messages */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.alert ul {
    margin: 0;
    padding-left: 1.2rem;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
}

@media print {
    .sidebar,
    .button,
    .danger-zone {
        display: none;
    }

    .card {
        border: none;
        padding: 0;
    }
}
