:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --ink: #152033;
    --muted: #64748b;
    --line: #dbe4ef;
    --primary: #126c83;
    --primary-dark: #0b5264;
    --primary-soft: #e5f4f6;
    --nav: #172235;
    --nav-soft: #22324b;
    --accent: #b7791f;
    --danger: #b42318;
    --success: #027a48;
    --card-radius: 10px;
    --app-font: Arial, Helvetica, sans-serif;
    --shadow: 0 18px 45px rgba(21, 32, 51, .08);
    --shadow-soft: 0 8px 25px rgba(21, 32, 51, .06);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(18, 108, 131, .10), transparent 34rem),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 38%, #eef3f8 100%);
    font-family: var(--app-font);
    font-size: 15px;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 72px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid rgba(219, 228, 239, .85);
    backdrop-filter: blur(14px);
}

.brand, .top-actions, .actions, .stats, .form-actions, .login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 800;
    font-size: 18px;
    min-width: 0;
}

.brand span:last-child, .login-brand div {
    display: grid;
    gap: 2px;
}

.brand small {
    max-width: min(52vw, 560px);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #1f8fa4);
    color: #fff;
    font-weight: 900;
    box-shadow: 0 10px 22px rgba(18, 108, 131, .24);
}

.user-pill {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel-soft);
    color: #344054;
    font-size: 13px;
    font-weight: 700;
}

.shell {
    display: grid;
    grid-template-columns: 264px 1fr;
    min-height: calc(100vh - 120px);
}

.sidebar {
    margin: 18px 0 18px 18px;
    padding: 18px 12px;
    border-radius: var(--card-radius);
    background: linear-gradient(180deg, var(--nav) 0%, #111827 100%);
    color: #e5eef8;
    box-shadow: var(--shadow);
    align-self: start;
    position: sticky;
    top: 90px;
}

.sidebar-section {
    padding: 10px 12px 8px;
    color: #8fa4bd;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 11px 12px;
    margin-bottom: 4px;
    border-radius: 10px;
    color: #d9e4ef;
    font-weight: 700;
}

.sidebar a span {
    width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 22px;
    border-radius: 7px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    font-size: 12px;
}

.sidebar a.active,
.sidebar a:hover {
    background: var(--nav-soft);
    color: #fff;
}

.sidebar a.active {
    box-shadow: inset 3px 0 0 var(--primary);
}

.content {
    min-width: 0;
    padding: 30px;
}

.header-center .topbar {
    justify-content: center;
    gap: 28px;
}

.sidebar-light .sidebar {
    background: rgba(255, 255, 255, .96);
    color: var(--ink);
    border: 1px solid var(--line);
}

.sidebar-light .sidebar-section { color: var(--muted); }
.sidebar-light .sidebar a { color: #344054; }
.sidebar-light .sidebar a span { background: var(--primary-soft); color: var(--primary-dark); }
.sidebar-light .sidebar a.active,
.sidebar-light .sidebar a:hover {
    background: #eef6f8;
    color: var(--primary-dark);
}

.page-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 24px;
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.18; }
h1 { font-size: clamp(26px, 3vw, 36px); letter-spacing: 0; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { color: var(--muted); line-height: 1.58; }

.card {
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(219, 228, 239, .92);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-soft);
    padding: 22px;
}

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.section-gap { margin-top: 18px; }

.stat {
    position: relative;
    overflow: hidden;
}

.stat::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--primary);
}

.stat.money-in::before { background: var(--success); }
.stat.money-out::before { background: var(--accent); }

.stat strong {
    display: block;
    font-size: clamp(25px, 3vw, 32px);
    margin-bottom: 4px;
}

.stat span, .muted { color: var(--muted); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 15px;
    border: 1px solid var(--primary);
    border-radius: calc(var(--card-radius) - 1px);
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.buttons-sharp .btn,
.buttons-sharp input,
.buttons-sharp textarea,
.buttons-sharp select,
.buttons-sharp .card,
.buttons-sharp table {
    border-radius: 4px;
}

.btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 10px 20px rgba(18, 108, 131, .18);
    transform: translateY(-1px);
}

.btn.ghost {
    background: #fff;
    color: var(--primary);
}

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

.btn.small {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 13px;
}

.btn.full { width: 100%; }

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

th, td {
    padding: 14px 15px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f1f6fb;
    font-size: 12px;
    color: #475569;
    text-transform: uppercase;
    font-weight: 900;
}

tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8fbff; }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    background: #eef4ff;
    color: #175cd3;
}

.badge.success { background: #ecfdf3; color: var(--success); }
.badge.warn { background: #fffaeb; color: var(--accent); }
.badge.danger { background: #fef3f2; color: var(--danger); }
.badge.neutral { background: #f2f4f7; color: #344054; }

.density-compact body,
.density-compact {
    font-size: 14px;
}

.density-compact .content { padding: 22px; }
.density-compact .card { padding: 16px; }
.density-compact th,
.density-compact td { padding: 10px 12px; }
.density-compact .sidebar a { min-height: 36px; padding: 9px 10px; }

form.card { max-width: 900px; }
form.card.wide-form { max-width: 1180px; }

label {
    display: block;
    color: #344054;
    font-weight: 800;
    margin-bottom: 7px;
}

input, textarea, select {
    width: 100%;
    min-height: 42px;
    border: 1px solid #c8d2df;
    border-radius: calc(var(--card-radius) - 1px);
    padding: 10px 12px;
    color: var(--ink);
    background: #fff;
    outline: none;
}

input[type="color"] {
    min-height: 46px;
    padding: 4px;
}

input[type="range"] {
    padding: 0;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(18, 108, 131, .12);
}

textarea { min-height: 116px; resize: vertical; }

.field { margin-bottom: 16px; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.alert {
    padding: 13px 15px;
    margin-bottom: 18px;
    border-radius: 12px;
    border: 1px solid #badbcc;
    background: #d1e7dd;
    color: #0f5132;
    font-weight: 700;
}

.alert.error {
    border-color: #f5c2c7;
    background: #f8d7da;
    color: #842029;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        radial-gradient(circle at 18% 15%, rgba(18, 108, 131, .24), transparent 24rem),
        radial-gradient(circle at 78% 68%, rgba(183, 121, 31, .16), transparent 22rem),
        linear-gradient(135deg, #eef7f8 0%, #f8fbff 54%, #edf2f7 100%);
}

.login-shell {
    width: min(1040px, 100%);
    display: grid;
    grid-template-columns: 1.1fr 420px;
    gap: 34px;
    align-items: center;
}

.login-copy h1 {
    max-width: 680px;
    font-size: clamp(34px, 5vw, 58px);
}

.login-copy p {
    max-width: 600px;
    font-size: 17px;
}

.eyebrow {
    display: inline-flex;
    margin-bottom: 14px;
    padding: 7px 11px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 900;
}

.login-card {
    width: 100%;
    padding: 26px;
}

.finance-summary {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.finance-summary div {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: var(--card-radius);
    background: #f8fbff;
}

.finance-summary span {
    color: var(--muted);
    font-weight: 800;
}

.finance-summary strong {
    white-space: nowrap;
}

.login-brand {
    margin-bottom: 20px;
}

.login-brand h2 {
    margin: 0;
}

.login-brand p {
    margin: 0;
}

.footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 30px;
    color: var(--muted);
    background: rgba(255, 255, 255, .72);
    border-top: 1px solid var(--line);
    font-size: 13px;
}

.print-card h2 {
    min-height: 48px;
}

.soft-card {
    background: var(--panel-soft);
    box-shadow: none;
}

.editable-table {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.editable-table table {
    box-shadow: none;
    border: 0;
    border-radius: 0;
}

.editable-table td {
    padding: 8px;
}

.editable-table input {
    min-width: 120px;
    min-height: 36px;
}

.print-sheet {
    overflow: auto;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #eef3f8;
    box-shadow: var(--shadow-soft);
}

.excel-print-table {
    width: auto;
    min-width: min(100%, 900px);
    margin: 0 auto;
    border-collapse: collapse;
    background: #fff;
    table-layout: fixed;
    box-shadow: 0 18px 40px rgba(21, 32, 51, .12);
}

.excel-print-table td {
    min-width: 74px;
    max-width: 220px;
    height: 26px;
    padding: 5px 7px;
    border: 1px solid #b8c3cf;
    color: #111827;
    background: #fff;
    font-size: 12px;
    vertical-align: middle;
    white-space: pre-wrap;
}

.excel-print-table .excel-empty {
    background: #fff;
}

.excel-print-table .is-bold {
    font-weight: 800;
}

.excel-print-table .is-large {
    font-size: 15px;
}

.excel-print-table .is-center {
    text-align: center;
}

.excel-print-table .is-right {
    text-align: right;
}

.print-flow {
    display: grid;
    gap: 10px;
}

.flow-step {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.flow-step span {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 900;
}

.flow-step strong,
.flow-step small {
    display: block;
}

.flow-step small {
    color: var(--muted);
    margin-top: 2px;
}

.editable-excel-table textarea {
    width: 100%;
    min-width: 72px;
    min-height: 24px;
    height: auto;
    padding: 2px 3px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font: inherit;
    resize: vertical;
    overflow: hidden;
}

.editable-excel-table textarea:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(18, 108, 131, .12);
}

@media print {
    @page {
        size: A4;
        margin: 0;
    }
    .topbar, .sidebar, .footer, .actions, .btn, .print-toolbar { display: none !important; }
    .shell { display: block; }
    .content { padding: 0; margin: 0; }
    .card, table, .print-sheet { box-shadow: none; }
    html, body {
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        padding: 0;
        background: #fff;
    }
    .print-sheet {
        padding: 0;
        border: 0;
        overflow: visible;
        background: #fff;
        border-radius: 0;
    }
    .excel-print-table {
        width: 100%;
        margin: 0;
        box-shadow: none;
        page-break-inside: auto;
    }
    .excel-print-table td {
        font-size: 10px;
        padding: 3px 4px;
    }
    .editable-excel-table textarea {
        border: 0;
        padding: 0;
        min-height: 0;
        resize: none;
        overflow: visible;
    }
}

@media (max-width: 980px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        display: flex;
        overflow-x: auto;
        margin: 12px;
        padding: 10px;
    }
    .sidebar-section { display: none; }
    .sidebar a {
        white-space: nowrap;
        margin: 0 6px 0 0;
        flex: 0 0 auto;
    }
    .login-shell { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 18px;
        gap: 12px;
    }
    .brand small { max-width: 82vw; }
    .content { padding: 18px; }
    .page-head, .footer { flex-direction: column; }
    .grid.two, .grid.three, .grid.four, .grid.five, .row { grid-template-columns: 1fr; }
    .flow-step { grid-template-columns: 38px 1fr; }
    table { display: block; overflow-x: auto; }
    .login-page { padding: 18px; }
    .login-copy h1 { font-size: 34px; }
}
