:root {
    --bg: #eef2f7;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --ink: #172033;
    --muted: #697586;
    --line: #dbe2ea;
    --line-strong: #c8d2de;
    --primary: #08766e;
    --primary-dark: #075c57;
    --primary-soft: #e5f4f2;
    --sidebar: #172231;
    --sidebar-soft: #223247;
    --warn: #986000;
    --danger: #b43b43;
    --danger-dark: #923039;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 22px rgba(15, 23, 42, .04);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    display: grid;
    grid-template-columns: 258px minmax(0, 1fr);
    font-family: "Segoe UI", Inter, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

body.login-page {
    display: grid;
    grid-template-columns: 1fr;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(8, 118, 110, .12), transparent 34%),
        linear-gradient(135deg, #f5f8fb, #e9eff6);
}

.login-shell {
    width: min(440px, 100%);
}

.login-panel {
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(200, 210, 222, .8);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .14);
    padding: 30px 28px 28px;
}

.login-brand {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: center;
    margin: -4px 0 18px;
    padding-bottom: 20px;
}

.login-brand h1 {
    margin: 0;
    text-align: center;
}

.login-logo {
    display: block;
    height: auto;
    max-height: 84px;
    max-width: min(280px, 100%);
    object-fit: contain;
    width: 100%;
}

.login-form {
    display: grid;
    gap: 14px;
    margin-top: 20px;
}

.sidebar {
    align-self: start;
    background: linear-gradient(180deg, #182433 0%, #131d2a 100%);
    box-shadow: 5px 0 18px rgba(15, 23, 42, .08);
    color: #fff;
    height: 100vh;
    overflow-y: auto;
    padding: 20px 14px;
    position: sticky;
    top: 0;
}

.brand {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 66px;
    margin-bottom: 18px;
    padding: 4px;
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.02em;
    text-align: center;
}

.brand-logo {
    background: #fff;
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 9px;
    height: auto;
    max-height: 74px;
    object-fit: contain;
    padding: 7px;
    width: 100%;
}

.company-logo-preview {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    height: 72px;
    object-fit: contain;
    padding: 6px;
    width: 120px;
}

nav {
    display: grid;
    gap: 6px;
}

.nav-section {
    display: grid;
    gap: 3px;
}

.nav-group {
    align-items: center;
    background: transparent;
    border: 0;
    color: #91a1b6;
    cursor: pointer;
    display: flex;
    font: inherit;
    font-size: 10px;
    font-weight: 700;
    justify-content: space-between;
    letter-spacing: .11em;
    margin: 0;
    padding: 9px 10px 5px;
    text-align: left;
    text-transform: uppercase;
    width: 100%;
}

.nav-chevron {
    color: #71839a;
    font-size: 15px;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform .18s ease;
}

.nav-section.open .nav-chevron {
    transform: rotate(90deg);
}

.nav-items {
    display: grid;
    gap: 3px;
}

.nav-items[hidden] {
    display: none !important;
}

nav a {
    border: 1px solid transparent;
    border-radius: 7px;
    color: #d4dde9;
    padding: 8px 11px;
    text-decoration: none;
    transition: background .16s ease, border-color .16s ease, color .16s ease;
}

nav a:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
}

nav a.active {
    background: #08766e;
    border-color: rgba(255, 255, 255, .1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .14);
    color: #fff;
    font-weight: 700;
}

.main {
    min-width: 0;
    overflow-x: auto;
    padding: 0 28px 30px;
}

.topbar {
    align-items: center;
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin: 0 -28px 22px;
    min-height: 82px;
    padding: 16px 28px;
    position: sticky;
    top: 0;
    z-index: 5;
    backdrop-filter: blur(12px);
}

.eyebrow {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    margin: 0 0 3px;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    color: var(--ink);
    margin: 0;
}

h1 {
    font-size: 25px;
    letter-spacing: -.035em;
}

h2 {
    font-size: 16px;
    letter-spacing: -.01em;
    margin-bottom: 14px;
}

h3 {
    font-size: 14px;
}

.panel,
.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel {
    margin-bottom: 16px;
    padding: 17px;
}

.stats {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    margin-bottom: 16px;
}

.summary-groups {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.summary-group {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.summary-group summary {
    align-items: center;
    cursor: pointer;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    list-style: none;
    padding: 14px 16px;
}

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

.summary-group summary::before {
    background: var(--primary-soft);
    border-radius: 999px;
    color: var(--primary);
    content: "+";
    display: grid;
    flex: 0 0 26px;
    font-size: 18px;
    font-weight: 800;
    height: 26px;
    line-height: 1;
    place-items: center;
    width: 26px;
}

.summary-group[open] summary::before {
    content: "-";
}

.summary-group summary span {
    color: var(--ink);
    flex: 1;
    font-size: 15px;
    font-weight: 800;
}

.summary-group summary small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.summary-group .stats {
    margin: 0;
    padding: 0 16px 16px;
}

.purchase-month-groups {
    display: grid;
    gap: 10px;
}

.purchase-month-group {
    box-shadow: none;
}

.purchase-month-group summary {
    background: var(--panel);
}

.purchase-month-totals {
    align-items: flex-end;
    display: flex;
    flex: 0 1 auto !important;
    flex-direction: column;
    gap: 3px;
    text-align: right;
}

.purchase-month-totals strong {
    color: var(--muted);
    font-size: 13px;
}

.purchase-month-totals strong.has-pending {
    color: var(--danger);
}

.purchase-month-totals small {
    text-transform: none !important;
}

.purchase-month-table {
    border-top: 1px solid var(--line);
    overflow-x: auto;
}

.purchase-month-table table {
    margin: 0;
}

.purchase-month-table th {
    position: static;
}

.stat {
    --stat-accent: var(--primary);
    --stat-bg: var(--panel);
    --stat-accent-soft: var(--primary-soft);
    background: var(--stat-bg);
    border-left: 5px solid var(--stat-accent);
    min-height: 104px;
    padding: 16px;
    position: relative;
}

.stat::before {
    background: var(--stat-accent);
    border-radius: 999px;
    content: "";
    display: block;
    height: 3px;
    margin-bottom: 14px;
    width: 34px;
}

.stat strong {
    color: var(--ink);
    display: block;
    font-size: 24px;
    letter-spacing: -.035em;
    line-height: 1.12;
}

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

.stat span {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-top: 6px;
}

.stat-ops {
    --stat-accent: #2f6fd0;
    --stat-bg: #f5f9ff;
    --stat-accent-soft: #e4efff;
}

.stat-device {
    --stat-accent: #7c4dba;
    --stat-bg: #f8f5ff;
    --stat-accent-soft: #ede6fb;
}

.stat-debt {
    --stat-accent: #c2413c;
    --stat-bg: #fff6f4;
    --stat-accent-soft: #ffe4df;
}

.stat-income {
    --stat-accent: #16855e;
    --stat-bg: #f1fbf6;
    --stat-accent-soft: #dff6ea;
}

.stat-cash {
    --stat-accent: #b56a14;
    --stat-bg: #fff8ec;
    --stat-accent-soft: #fbe7c5;
}

.stat-neutral {
    --stat-accent: #607086;
    --stat-bg: #f8fafc;
    --stat-accent-soft: #e7edf4;
}

.stat::after {
    background: var(--stat-accent-soft);
    border-radius: 999px;
    color: var(--stat-accent);
    content: "Resumen";
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    padding: 4px 7px;
    position: absolute;
    right: 12px;
    text-transform: uppercase;
    top: 12px;
}

.stat-ops::after {
    content: "Operacion";
}

.stat-device::after {
    content: "Equipos";
}

.stat-debt::after {
    content: "Deuda";
}

.stat-income::after {
    content: "Cobros";
}

.stat-cash::after {
    content: "Caja";
}

.cash-headline {
    background: linear-gradient(135deg, #172033 0%, #243451 100%);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: #fff;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(180px, .85fr) repeat(3, minmax(190px, 1fr));
    margin-bottom: 18px;
    padding: 18px;
}

.cash-headline-title {
    align-self: center;
    padding: 8px;
}

.cash-headline-title span,
.cash-headline-title strong {
    display: block;
}

.cash-headline-title span {
    color: #aebbd0;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.cash-headline-title strong {
    font-size: 22px;
    line-height: 1.15;
    margin-top: 7px;
}

.cash-kpi {
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 12px;
    padding: 16px;
}

.cash-kpi > span,
.cash-kpi > strong,
.cash-kpi > small {
    display: block;
}

.cash-kpi > span {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.cash-kpi > strong {
    font-size: clamp(21px, 2vw, 29px);
    letter-spacing: -.035em;
    margin: 7px 0 5px;
}

.cash-kpi > small {
    color: #cad3e2;
    font-size: 11px;
    line-height: 1.35;
}

.cash-kpi.income { border-top: 4px solid #3dd598; }
.cash-kpi.income > span, .cash-kpi.income > strong { color: #7ef0bd; }
.cash-kpi.expense { border-top: 4px solid #ff7771; }
.cash-kpi.expense > span, .cash-kpi.expense > strong { color: #ffaaa6; }
.cash-kpi.balance { background: #fff; border-color: #fff; border-top: 4px solid #f4bd50; color: #172033; }
.cash-kpi.balance > span, .cash-kpi.balance > strong { color: #9a5b0f; }
.cash-kpi.balance > small { color: #68758a; }
.cash-kpi.balance.negative { border-top-color: #d94841; }
.cash-kpi.balance.negative > span, .cash-kpi.balance.negative > strong { color: #b52f2a; }

.cash-evolution-panel {
    overflow: hidden;
}

.cash-evolution-panel .section-head p {
    margin: 5px 0 0;
}

.chart-scale {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    padding: 7px 10px;
}

.cash-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 14px;
    margin: 14px 0 18px;
}

.cash-chart-legend span {
    align-items: center;
    color: var(--muted);
    display: inline-flex;
    font-size: 11px;
    font-weight: 700;
    gap: 6px;
}

.cash-chart-legend i {
    background: var(--legend-color);
    border-radius: 3px;
    display: inline-block;
    height: 9px;
    width: 9px;
}

.cash-chart {
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(12, minmax(72px, 1fr));
    min-width: 920px;
    overflow: visible;
    padding: 18px 4px 4px;
}

.cash-evolution-panel {
    overflow-x: auto;
}

.cash-chart-month {
    min-width: 0;
    text-align: center;
}

.cash-chart-values {
    align-items: end;
    display: grid;
    gap: 5px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cash-chart-column small {
    color: var(--muted);
    display: block;
    font-size: 9px;
    font-weight: 800;
    margin-top: 5px;
    text-transform: uppercase;
}

.cash-chart-total {
    display: block;
    font-size: 9px;
    font-weight: 800;
    margin-bottom: 5px;
    white-space: nowrap;
}

.cash-chart-total.income { color: #16855e; }
.cash-chart-total.expense { color: #c2413c; }

.cash-chart-bar {
    align-content: end;
    background: #edf1f6;
    border-radius: 6px 6px 2px 2px;
    display: flex;
    flex-direction: column-reverse;
    height: 190px;
    justify-content: flex-start;
    overflow: hidden;
}

.cash-chart-segment {
    background: var(--segment-color);
    display: block;
    flex: 0 0 var(--segment-height);
    min-height: 2px;
}

.cash-chart-month-label {
    display: block;
    font-size: 11px;
    margin-top: 8px;
}

.cash-chart-balance {
    display: block;
    font-size: 9px;
    font-weight: 800;
    margin-top: 3px;
    white-space: nowrap;
}

.cash-chart-balance.positive { color: #16855e; }
.cash-chart-balance.negative { color: #c2413c; }
.cash-debt-summary { margin-bottom: 18px; }

.status-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.status-card {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px;
}

.status-card strong,
.status-card span {
    display: block;
}

.status-card span {
    color: var(--muted);
    font-size: 12px;
    margin-top: 5px;
}

.status-card.ok {
    background: #edf9f2;
    border-color: #c7e8d4;
}

.status-card.warn {
    background: #fff8e9;
    border-color: #f0d9a9;
}

.grid-form {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

label {
    color: #596679;
    display: grid;
    font-size: 12px;
    font-weight: 600;
    gap: 5px;
}

label.wide,
.grid-form .wide {
    grid-column: 1 / -1;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    color: var(--ink);
    font: inherit;
    min-height: 38px;
    padding: 8px 10px;
    transition: border-color .16s ease, box-shadow .16s ease;
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(8, 118, 110, .14);
    outline: none;
}

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

.select-search-field {
    align-self: stretch;
}

.select-search {
    min-height: 35px;
}

.select-search-field select[multiple] {
    min-height: 150px;
}

.table-tools {
    align-items: end;
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.table-tools label {
    max-width: 420px;
    width: min(420px, 100%);
}

.table-search {
    background: var(--panel-soft);
    min-height: 36px;
}

.permission-grid {
    display: grid;
    gap: 9px;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.permission-option {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.checkbox-form {
    margin: 0;
}

.checkbox-line {
    align-items: center;
    color: var(--ink);
    display: flex;
    gap: 8px;
}

.checkbox-line input {
    accent-color: var(--primary);
    min-height: 0;
    width: auto;
}

.contract-installment-scope {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 14px;
    display: grid;
    gap: 8px;
    padding: 14px;
}

.contract-installment-scope > span {
    color: var(--ink);
    font-weight: 800;
}

.installment-choice-list {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    display: grid;
    gap: 6px;
    max-height: 220px;
    overflow: auto;
    padding: 10px;
}

.history-snapshot {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    margin: 0;
    max-width: 360px;
    padding: 8px;
    white-space: pre-wrap;
}

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

.form-actions,
.report-actions {
    align-items: center;
}

.section-head {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    margin: -2px 0 14px;
    padding-bottom: 11px;
}

.section-head h2 {
    margin-bottom: 0;
}

.inline-form {
    align-items: end;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 0;
}

.inline-form label {
    min-width: 170px;
}

.inline-action {
    display: inline-flex;
    margin: 0;
}

.button {
    align-items: center;
    background: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 7px;
    box-shadow: 0 1px 1px rgba(15, 23, 42, .05);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    justify-content: center;
    line-height: 1.2;
    min-height: 38px;
    padding: 9px 13px;
    text-decoration: none;
    transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .08s ease;
}

.button:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 10px rgba(8, 118, 110, .18);
}

.button:active {
    transform: translateY(1px);
}

.button.ghost {
    background: #fff;
    border-color: var(--line-strong);
    color: #3d4b5f;
}

.button.ghost:hover {
    background: var(--panel-soft);
    border-color: #aebac8;
    box-shadow: 0 3px 8px rgba(15, 23, 42, .08);
    color: var(--primary-dark);
}

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

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

.button.small {
    font-size: 12px;
    min-height: 30px;
    padding: 6px 9px;
}

table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    line-height: 1.35;
    width: 100%;
}

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

th {
    background: #f6f8fb;
    border-top: 1px solid var(--line);
    color: #657286;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    position: sticky;
    top: 81px;
    text-transform: uppercase;
    z-index: 2;
}

th:first-child {
    border-left: 1px solid var(--line);
    border-top-left-radius: 7px;
}

th:last-child {
    border-right: 1px solid var(--line);
    border-top-right-radius: 7px;
}

tbody tr {
    transition: background .14s ease;
}

tbody tr:nth-child(even) {
    background: #fbfcfd;
}

tbody tr:hover {
    background: #f1f7f7;
}

tbody td:first-child {
    color: #647287;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

td .muted {
    font-size: 12px;
}

td.actions {
    display: table-cell;
    min-width: 178px;
    white-space: normal;
}

td.actions > * {
    margin: 2px 4px 2px 0;
    vertical-align: middle;
}

td.actions .button,
td .badge {
    white-space: nowrap;
}

td:nth-child(n+2) {
    font-variant-numeric: tabular-nums;
}

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

.row-actions > * {
    margin: 0;
}

.row-actions-primary {
    align-items: end;
    background: #f7fafc;
    border: 1px solid var(--line);
    border-radius: 7px;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
}

.row-actions-primary label {
    min-width: 132px;
}

.row-actions-secondary {
    align-items: center;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cell-main {
    color: var(--ink);
    display: block;
    font-weight: 700;
}

.cell-sub {
    color: var(--muted);
    display: block;
    font-size: 12px;
    margin-top: 3px;
}

.group-row td {
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 700;
}

.group-row .button {
    margin-right: 9px;
}

.customer-has-contract td {
    background: #edf8f2;
}

.customer-has-contract td:first-child {
    border-left: 3px solid #2b9b69;
}

.badge {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 999px;
    display: inline-flex;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 4px 7px;
}

.badge.contract-active {
    background: #ddf4e7;
    color: #17633a;
    margin-left: 6px;
}

.badge.pending {
    background: #fff5df;
    color: var(--warn);
}

.badge.paid {
    background: #e7f7ee;
    color: #17633a;
}

.badge.partial {
    background: #fff7cf;
    color: #705600;
}

.badge.voided,
.badge.cancelled {
    background: #fdecec;
    color: var(--danger);
}

.customer-has-contract-option {
    background: #d8f3e5;
    color: #17633a;
    font-weight: 700;
}

.installment-keep-row td {
    background: #eef8f2;
}

.installment-extra-row td {
    background: #fff8e8;
}

.selected-device-summary {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    display: grid;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
}

.selected-device-summary strong {
    font-size: 12px;
}

.selected-device-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.selected-device-item {
    background: #e7f7ee;
    border: 1px solid #b8d6c4;
    border-radius: 999px;
    color: #17633a;
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 9px;
}

.selected-device-item::after {
    content: " x";
}

.alert {
    background: #e8f7ef;
    border: 1px solid #c1e5cf;
    border-radius: 8px;
    color: #145637;
    margin-bottom: 16px;
    padding: 11px 13px;
}

.alert.warn {
    background: #fff6e6;
    border-color: #eed5a4;
    color: var(--warn);
}

@media (max-width: 1100px) {
    .stats,
    .status-grid {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }
}

@media (max-width: 900px) {
    body {
        grid-template-columns: 1fr;
    }

    .sidebar {
        height: auto;
        position: static;
    }

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

    .main {
        padding: 0 16px 22px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        margin: 0 -16px 16px;
        padding: 14px 16px;
        position: static;
    }

    th {
        top: 0;
    }

    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .table-tools {
        align-items: stretch;
        flex-direction: column;
    }

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

    .cash-headline {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cash-headline-title {
        grid-column: 1 / -1;
    }
}

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

    .panel {
        padding: 14px;
    }

    .cash-headline {
        grid-template-columns: 1fr;
        padding: 13px;
    }

    .cash-headline-title {
        grid-column: auto;
    }
}
