:root {
    --brand: #f79726;
    --brand-dark: #e08616;
    --ink: #1c1c1c;
    --muted: #5c6570;
    --line: #e6e8eb;
    --bg: #f4f5f7;
    --sidebar: #1b1b1b;
    --danger: #b42318;
    --ok: #166534;
    --warn: #92400e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

a { color: #9a5410; }

h1, h2 { margin: 0; }

img { max-width: 100%; }

button, input, select, textarea { font: inherit; color: inherit; }

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

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

.sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: var(--sidebar);
    color: #f5f5f5;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
}

.brand {
    background: #fff;
    border-radius: 12px;
    padding: 10px;
    display: block;
}

.brand img { display: block; width: 100%; height: auto; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-link, .button-link {
    display: block;
    color: #f5f5f5;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 8px;
    border-left: 3px solid transparent;
}

.nav-link:hover, .button-link:hover { background: rgba(255, 255, 255, 0.06); }

.nav-link.active {
    background: rgba(247, 151, 38, 0.16);
    color: var(--brand);
    border-left-color: var(--brand);
}

.sidebar-foot { margin-top: auto; }

.user-name { margin: 0; font-weight: 700; }

.user-role { margin: 2px 0 8px; color: #bdbdbd; font-size: 13px; }

.button-link {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    cursor: pointer;
}

.main { flex: 1; min-width: 0; padding: 24px 28px 48px; }

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.topbar h1 { font-size: 28px; }

.top-actions { margin-left: auto; }

.menu-btn { display: none; }

.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 16px;
}

.card h2 { font-size: 18px; margin-bottom: 12px; }

.button, .button.secondary, .button.ghost, .button.danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 9px 14px;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 700;
}

.button { background: var(--brand); color: #1c1c1c; }

.button:hover { background: var(--brand-dark); }

.button.secondary, .button.ghost {
    background: #fff;
    border-color: var(--line);
    color: var(--ink);
}

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

.button.disabled { opacity: 0.45; pointer-events: none; }

.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }

.alert ul { margin: 0; padding-left: 18px; }

.alert.ok { background: #ecfdf3; color: var(--ok); }

.alert.error { background: #fef3f2; color: var(--danger); }

.alert.warn { background: #fff7ed; color: var(--warn); }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
}

label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 650; }

input, select, textarea {
    border: 1px solid #d5d8de;
    border-radius: 8px;
    padding: 9px 10px;
    background: #fff;
    font-weight: 400;
    width: 100%;
}

textarea { resize: vertical; }

input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.form { display: flex; flex-direction: column; gap: 14px; }

.check { flex-direction: row; align-items: center; font-weight: 600; }

.check input { width: auto; }

.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.form-actions form { margin: 0; }

.muted { color: var(--muted); font-size: 14px; }

.table-wrap { overflow-x: auto; }

.grid { width: 100%; border-collapse: collapse; }

.grid th, .grid td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.grid th { font-size: 13px; color: var(--muted); }

.num { text-align: right; white-space: nowrap; }

.row-actions { display: flex; gap: 8px; align-items: center; }

.pager { display: flex; gap: 10px; align-items: center; margin-top: 14px; }

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
    background: #eef0f3;
}

.badge-issued { background: #dbeafe; color: #1d4ed8; }
.badge-partial, .badge-active { background: #fff1dc; color: #9a5410; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-void { background: #fee2e2; color: #b42318; }

.stats, .chart-grid, .columns { display: grid; gap: 14px; margin-bottom: 16px; }

.stats { grid-template-columns: repeat(3, 1fr); }

.stat {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat span { color: var(--muted); font-size: 13px; font-weight: 700; }

.stat strong { font-size: 22px; }

.chart-grid, .columns { grid-template-columns: 1.4fr 1fr; }

.chart-box { position: relative; height: 280px; }

.split { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

.preview-totals { min-width: 240px; }

.preview-totals div, .total-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 0;
}

.field-link { margin: 0; align-self: end; }

.logo-preview { width: 220px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }

fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0; }

legend { font-weight: 700; padding: 0 6px; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card, .setup-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.setup-card { width: min(760px, 100%); }

.login-card img, .setup-card img { width: 220px; display: block; margin: 0 auto 8px; }

.tagline-login { text-align: center; color: var(--muted); margin-top: 0; }

.login-card h1, .setup-card h1 { text-align: center; margin-bottom: 16px; }

.login-card form, .setup-card form { display: flex; flex-direction: column; gap: 12px; }

.login-card .button, .setup-card .button { width: 100%; }

.setup-steps { margin: 0 0 16px; padding-left: 18px; color: var(--muted); }

.confirm-list { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; }

.confirm-list dt { font-weight: 700; }

.confirm-list dd { margin: 0; }

@media (max-width: 980px) {
    .stats, .chart-grid, .columns, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .menu-btn {
        display: inline-flex;
        border: 1px solid var(--line);
        background: #fff;
        border-radius: 8px;
        padding: 8px 10px;
        font-weight: 700;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 20;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }

    .nav-toggle:checked ~ .shell .sidebar { transform: translateX(0); }

    .main { padding: 16px; }
}

@media print {
    .sidebar, .topbar, .filters, .pager, .no-print { display: none !important; }
    .shell, .main { display: block; }
    body { background: #fff; }
}
