:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --ink: #1e293b;
    --muted: #64748b;
    --line: #d9e1ea;
    --accent: #0f766e;
    --accent-dark: #115e59;
    --danger: #b91c1c;
    --ok: #166534;
    --warn: #92400e;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    letter-spacing: 0;
    line-height: 1.35;
}

a {
    color: inherit;
}

.app {
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: #172033;
    color: #eef4f8;
    height: 100vh;
    padding: 18px 14px;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    width: 220px;
    z-index: 10;
}

.brand {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.sidebar nav {
    display: grid;
    gap: 8px;
}

.sidebar nav a,
.user-box a {
    border-radius: 6px;
    color: #dbe7ef;
    padding: 9px 10px;
    text-decoration: none;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: #253551;
    color: #ffffff;
}

.user-box {
    display: grid;
    gap: 8px;
    margin-top: auto;
    color: #b6c6d3;
    font-size: 14px;
}

.user-box a {
    background: #0f766e;
    color: #ffffff;
    text-align: center;
}

.content {
    display: grid;
    align-content: start;
    gap: 14px;
    margin-left: 220px;
    min-width: 0;
    padding: 20px;
}

.page-head h1 {
    margin: 0 0 6px;
    font-size: 24px;
}

.page-head p {
    margin: 0;
    color: var(--muted);
}

.section-title {
    font-size: 18px;
    margin: 6px 0 -4px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.form,
.form-grid,
.filters {
    display: grid;
    gap: 14px;
}

.form-grid,
.filters {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    align-items: end;
    padding: 14px;
}

.check-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    grid-column: span 2;
    margin: 0;
    min-width: 0;
    padding: 10px;
}

.check-group legend {
    color: #334155;
    font-size: 14px;
    font-weight: 700;
    padding: 0 6px;
}

.check-list {
    display: grid;
    gap: 6px;
    max-height: 145px;
    overflow: auto;
    padding: 2px;
}

.option-check {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    min-height: 32px;
    padding: 6px 8px;
}

.permissions-box {
    grid-column: 1 / -1;
}

.permission-grid {
    align-items: center;
    border-top: 1px solid #e2e8f0;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(130px, 1.4fr) repeat(3, minmax(95px, 1fr));
    padding: 8px 0;
}

.permission-grid:first-of-type {
    border-top: 0;
}

.permission-head {
    color: #334155;
    font-size: 13px;
    padding-top: 0;
}

.compact-check {
    font-size: 13px;
    min-height: auto;
}

.select-all {
    background: #e6f3f1;
    border-color: #9ccfca;
    color: var(--accent-dark);
}

.wide {
    grid-column: span 2;
}

label {
    display: grid;
    gap: 6px;
    color: #334155;
    font-size: 14px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 34px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: var(--ink);
    font: inherit;
    padding: 6px 9px;
}

button,
.link-button {
    min-height: 34px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 8px 12px;
    text-align: center;
    text-decoration: none;
}

button:hover,
.link-button:hover {
    background: var(--accent-dark);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

button.danger {
    background: var(--danger);
}

button.danger:hover {
    background: #7f1d1d;
}

button.secondary {
    background: #334155;
}

button.secondary:hover {
    background: #1e293b;
}

.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.actions-cell {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    min-width: 150px;
}

.actions-cell form {
    margin: 0;
}

.check {
    align-items: center;
    display: flex;
    gap: 8px;
    min-height: 40px;
}

.check input {
    min-height: auto;
    width: auto;
}

.table-wrap {
    overflow-x: auto;
    width: 100%;
}

table {
    border-collapse: collapse;
    min-width: 760px;
    width: 100%;
}

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

th {
    background: #edf2f7;
    color: #334155;
    font-size: 13px;
    text-transform: uppercase;
}

.group-row td {
    background: #f8fafc;
    border-top: 2px solid #cbd5e1;
    color: #0f172a;
    font-weight: 700;
}

.money {
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.badge {
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 9px;
    text-transform: uppercase;
}

.badge.ingreso {
    background: #dcfce7;
    color: var(--ok);
}

.badge.gasto {
    background: #ffedd5;
    color: var(--warn);
}

.badge.sueldo {
    background: #e0f2fe;
    color: #0369a1;
}

.badge.arriendo {
    background: #f3e8ff;
    color: #7e22ce;
}

.badge.venta {
    background: #dcfce7;
    color: var(--ok);
}

.badge.retiro {
    background: #fee2e2;
    color: var(--danger);
}

.stats {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(5, 1fr);
}

.stats div {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.stats span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    margin-bottom: 8px;
}

.stats strong {
    font-size: 21px;
}

.alert {
    border-radius: 6px;
    font-weight: 700;
    padding: 12px 14px;
}

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

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

.empty {
    color: var(--muted);
    text-align: center;
}

.empty-panel {
    color: var(--muted);
    padding: 18px;
    text-align: center;
}

.cash-summary {
    display: grid;
    gap: 12px;
}

.cash-company {
    overflow: hidden;
}

.cash-company-head {
    align-items: center;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(160px, 1fr) auto;
    padding: 14px;
}

.cash-company-head h3 {
    font-size: 18px;
    margin: 0;
}

.cash-company-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.cash-company-totals span {
    background: #ffffff;
    border: 1px solid #dbe3ec;
    border-radius: 6px;
    color: var(--muted);
    min-width: 132px;
    padding: 8px 10px;
}

.cash-company-totals strong {
    color: var(--ink);
    display: block;
    font-size: 16px;
    margin-top: 2px;
}

.cash-branches {
    display: grid;
}

.cash-branch {
    align-items: center;
    border-top: 1px solid #edf2f7;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(160px, 1.4fr) repeat(3, minmax(115px, 1fr));
    padding: 10px 14px;
}

.cash-branch:first-child {
    border-top: 0;
}

.cash-branch-name {
    font-weight: 700;
}

.cash-branch-metric {
    color: var(--muted);
    display: grid;
    font-size: 12px;
    font-weight: 700;
    gap: 3px;
    justify-items: end;
    text-transform: uppercase;
}

.cash-branch-metric .money {
    color: var(--ink);
    font-size: 15px;
    line-height: 1.2;
}

.strong-money {
    color: #0f172a;
}

.site-footer {
    color: var(--muted);
    font-size: 13px;
    justify-self: center;
    padding: 10px 0;
    text-align: center;
    width: 100%;
}

.login-page {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: 14px;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.12);
    max-width: 390px;
    padding: 28px;
    width: 100%;
}

.login-card h1 {
    margin: 0 0 8px;
}

.login-card p {
    color: var(--muted);
    margin: 0 0 20px;
}

.login-footer {
    max-width: 390px;
    width: 100%;
}

@media (max-width: 980px) {
    .sidebar {
        height: auto;
        position: static;
        width: auto;
    }

    .sidebar nav {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-grid,
    .filters,
    .stats {
        grid-template-columns: 1fr;
    }

    .content {
        margin-left: 0;
        padding: 14px;
    }

    .cash-company-head {
        grid-template-columns: 1fr;
    }

    .cash-company-totals {
        justify-content: stretch;
    }

    .cash-company-totals span {
        flex: 1 1 150px;
    }

    .wide,
    .check-group {
        grid-column: auto;
    }

    .permissions-box {
        grid-column: auto;
    }
}

@media (max-width: 560px) {
    .sidebar nav {
        grid-template-columns: 1fr;
    }

    .page-head h1 {
        font-size: 21px;
    }

    .login-card {
        padding: 20px;
    }

    .permission-grid {
        grid-template-columns: 1fr;
    }

    .permission-head {
        display: none;
    }

    .cash-branch {
        align-items: start;
        grid-template-columns: 1fr;
    }

    .cash-branch-metric {
        justify-items: start;
    }
}
