:root {
    color-scheme: light;
    --bg: #f4f6f5;
    --surface: #ffffff;
    --surface-soft: #eef3f1;
    --border: #d8dfdc;
    --text: #17201d;
    --muted: #65736e;
    --primary: #00a651;
    --primary-dark: #00843f;
    --accent: #205c7a;
    --danger: #9d2f35;
    --warning: #8a6914;
    --status-yellow: #ffcf24;
    --status-yellow-dark: #c89400;
    --shadow: 0 10px 30px rgba(22, 32, 29, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    font-size: 15px;
    letter-spacing: 0;
    text-transform: uppercase;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea,
option {
    font: inherit;
    text-transform: inherit;
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    min-height: 46px;
    padding: 0;
    border-radius: 8px;
    background: transparent;
    white-space: nowrap;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: white;
}

.brand-logo {
    display: block;
    width: 176px;
    height: 42px;
    object-fit: contain;
    object-position: left center;
}

.nav {
    display: flex;
    gap: 8px;
    flex: 1;
}

.nav a {
    min-height: 38px;
    padding: 9px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
    font-weight: 700;
    transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.nav a:hover,
.nav a.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 8px 18px rgba(0, 166, 81, .18);
}

.nav a.is-active:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

.nav .nav-alert-link {
    gap: 7px;
}

.nav-alert-count {
    min-width: 22px;
    min-height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    border-radius: 999px;
    background: #c40000;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
}

.nav a:hover .nav-alert-count,
.nav a.is-active .nav-alert-count {
    background: #fff;
    color: #c40000;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 48px;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-heading h1,
.auth-panel h1,
.section-header h2 {
    margin: 0;
}

.page-heading h1 {
    font-size: 30px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.metric,
.panel,
.auth-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.metric {
    padding: 18px;
    min-height: 104px;
}

.metric span {
    display: block;
    color: var(--muted);
    margin-bottom: 10px;
}

.metric strong {
    display: block;
    font-size: 28px;
}

.metric-link {
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.metric-link:hover,
.metric-link:focus-visible,
.metric-link.is-active {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.metric-link.is-active {
    background: #eef8f2;
}

.compact-metrics .metric {
    min-height: 88px;
    padding: 14px 16px;
}

.compact-metrics .metric strong {
    font-size: 24px;
}

.customer-expiry-section {
    display: block;
    width: 100%;
    max-width: none;
    margin-bottom: 18px;
}

.customer-expiry-card {
    width: 100%;
    max-width: none;
    min-height: 88px;
    padding: 14px 16px;
}

.customer-expiry-card strong {
    font-size: 24px;
}

.panel {
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    min-width: 0;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) minmax(180px, .8fr) minmax(180px, .8fr) auto;
    gap: 12px;
    align-items: end;
}

.filter-bar.single {
    grid-template-columns: minmax(220px, 1fr) auto;
}

.agent-filter-bar {
    grid-template-columns: minmax(300px, .7fr) minmax(240px, 1fr) auto;
}

.dashboard-filter-bar {
    grid-template-columns: repeat(2, minmax(180px, 240px)) auto;
}

.notification-list {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.notice {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #b8dfd0;
    background: #e6f5ef;
    color: var(--primary-dark);
    font-weight: 700;
}

.status-toggle > span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.status-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.status-button {
    flex: 1;
    min-width: 88px;
    background: var(--surface);
    border-color: var(--border);
    color: var(--muted);
}

.status-button-active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.status-button-active:hover,
.status-button-active.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.status-button-warning {
    background: var(--status-yellow);
    border-color: var(--status-yellow-dark);
    color: var(--text);
}

.status-button-warning:hover,
.status-button-warning.is-active {
    background: var(--status-yellow);
    border-color: var(--status-yellow-dark);
    color: var(--text);
}

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

label span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text);
    padding: 9px 11px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(29, 107, 85, .16);
    border-color: var(--primary);
}

textarea {
    resize: vertical;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

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

.currency-field {
    position: relative;
}

.currency-field input {
    padding-right: 58px;
}

.currency-field span {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    pointer-events: none;
}

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

.check-row input {
    width: 16px;
    min-height: 16px;
}

.check-row span {
    margin: 0;
    font-weight: 400;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.button {
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

.button-primary {
    background: var(--primary);
    color: white;
}

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

.button-accent {
    background: var(--accent);
    color: white;
}

.button-accent:hover {
    background: #16445c;
}

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

.button-danger:hover {
    background: #7f252a;
}

.button-warning {
    background: var(--status-yellow);
    border-color: var(--status-yellow-dark);
    color: var(--text);
}

.button-warning:hover {
    background: #f2bd00;
    border-color: var(--status-yellow-dark);
    color: var(--text);
}

.button-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--muted);
}

.button-ghost:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.auth-shell {
    min-height: calc(100vh - 130px);
    display: grid;
    place-items: center;
}

.auth-panel {
    width: min(420px, 100%);
    padding: 28px;
    box-shadow: var(--shadow);
}

.auth-heading {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 26px;
}

.auth-logo {
    display: block;
    width: 220px;
    height: 54px;
    object-fit: contain;
    object-position: center;
}

.form-error {
    margin: 0;
    color: var(--danger);
    font-weight: 700;
}

.table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 8px;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.badge-ok {
    background: #e4f2ec;
    color: var(--primary-dark);
}

.badge-muted {
    background: #f3eedf;
    color: var(--warning);
}

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

.badge-warning {
    background: var(--status-yellow);
    color: var(--text);
}

.amount-positive {
    color: var(--primary-dark);
    font-weight: 800;
}

.amount-negative {
    color: var(--danger);
    font-weight: 800;
}

.button-small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

.table-actions {
    text-align: right;
}

.actions-heading {
    text-align: right;
}

.actions-heading span {
    display: inline-block;
    min-width: 138px;
    text-align: left;
}

.quick-bill-stack {
    display: inline-grid;
    justify-items: end;
    gap: 6px;
}

.quick-bill-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    min-width: 196px;
}

.quick-bill-actions form {
    margin: 0;
}

.quick-bill-actions .button {
    min-width: 104px;
    padding-left: 14px;
    padding-right: 14px;
}

.billing-subnote {
    max-width: 100%;
    color: #c40000 !important;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
    text-align: left;
    text-transform: uppercase;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

.billing-note {
    display: inline-block;
    max-width: 100%;
    color: #c40000 !important;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.35;
    text-align: left;
    text-transform: uppercase;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

.debtor-badge {
    margin-left: 6px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(12, 20, 18, .42);
}

.modal-backdrop[hidden] {
    display: none;
}

.confirmation-modal {
    width: min(420px, 100%);
    padding: 22px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.confirmation-modal h2 {
    margin: 0 0 12px;
    font-size: 22px;
}

.confirmation-modal p {
    margin: 0 0 18px;
    color: var(--text);
    line-height: 1.45;
}

.confirmation-modal .billing-warning {
    margin: 0 0 14px;
    color: #c40000 !important;
    font-size: 14px;
    font-weight: 900;
    line-height: 1.4;
    text-transform: uppercase;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

.confirmation-modal .billing-action-error {
    color: #c40000 !important;
    font-weight: 900;
}

.confirmation-modal button:disabled {
    cursor: wait;
    opacity: .65;
}

.month-control {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.month-control[hidden],
.confirmation-total[hidden] {
    display: none;
}

.month-control > span,
.confirmation-total span,
.confirmation-note {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.confirmation-note {
    margin: -4px 0 14px;
    line-height: 1.35;
}

.stepper {
    display: grid;
    grid-template-columns: 42px minmax(80px, 1fr) 42px;
    gap: 8px;
}

.stepper input {
    text-align: center;
    font-weight: 700;
}

.stepper-button,
.month-shortcuts button {
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
}

.stepper-button:hover,
.month-shortcuts button:hover {
    background: var(--surface-soft);
}

.month-shortcuts {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.confirmation-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    padding: 12px;
    border-radius: 8px;
    background: var(--surface-soft);
}

.confirmation-total strong {
    font-size: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.village-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.village-card {
    display: grid;
    gap: 8px;
    min-height: 118px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.village-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.village-card strong {
    font-size: 18px;
}

.village-card span {
    color: var(--muted);
}

.empty-state {
    display: grid;
    gap: 6px;
    padding: 26px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
}

.empty-state strong {
    font-size: 20px;
}

.empty-state span {
    color: var(--muted);
}

.alert-success {
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid #b7dfce;
    border-radius: 8px;
    background: #e7f6ef;
    color: var(--primary-dark);
    font-weight: 700;
}

.alert-danger {
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid #efc5c9;
    border-radius: 8px;
    background: #fde8ea;
    color: var(--danger);
    font-weight: 700;
}

.billing-layout {
    display: grid;
    grid-template-columns: minmax(260px, .9fr) minmax(320px, 1.1fr);
    gap: 16px;
}

.customer-summary h2 {
    font-size: 22px;
}

.details-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.details-list div {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.details-list dt {
    color: var(--muted);
    font-weight: 700;
}

.details-list dd {
    margin: 0;
}

.inline-edit-form {
    display: inline-grid;
    grid-template-columns: minmax(150px, 220px) auto auto;
    align-items: center;
    gap: 8px;
    width: fit-content;
    max-width: 100%;
}

.inline-edit-form[data-phone-edit-form] {
    grid-template-columns: minmax(150px, 220px) auto;
}

.inline-edit-form input {
    width: 220px;
    min-width: 0;
    max-width: 220px;
}

.total-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
    background: var(--surface-soft);
}

.total-box span {
    color: var(--muted);
    font-weight: 700;
}

.total-box strong {
    font-size: 24px;
}

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

.subtext {
    display: block;
    margin-top: 4px;
    font-size: 12px;
}

.radius-username {
    text-transform: lowercase !important;
}

.radius-alert-explanation {
    margin: 6px 0 0;
    line-height: 1.4;
}

.radius-alert-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.radius-alert-critical-metric {
    border-color: #efc5c9;
    background: #fde8ea;
}

.radius-alert-critical-metric strong {
    color: var(--danger);
}

.radius-alert-table {
    min-width: 1120px;
}

.radius-alert-table td {
    vertical-align: top;
}

.radius-alert-critical-row td {
    background: #fff3f4;
}

.radius-alert-critical-row td:first-child {
    border-left: 4px solid var(--danger);
}

.customer-link {
    display: inline-block;
    color: inherit;
}

.customer-link:hover,
.customer-link:hover strong {
    color: var(--primary);
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
}

.pagination-row {
    margin-top: 16px;
}

.agent-customer-table,
.report-table {
    min-width: 0;
}

.payments-report-table {
    min-width: 620px;
}

.payments-search-bar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 14px;
}

.agent-customer-table {
    table-layout: fixed;
}

.agent-customer-table th:nth-child(1),
.agent-customer-table td:nth-child(1) {
    width: 40%;
}

.agent-customer-table th:nth-child(2),
.agent-customer-table td:nth-child(2) {
    width: 17%;
}

.agent-customer-table th:nth-child(3),
.agent-customer-table td:nth-child(3) {
    width: 13%;
}

.agent-customer-table th:nth-child(4),
.agent-customer-table td:nth-child(4) {
    width: 30%;
}

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

.report-grid > *,
.finance-dashboard-grid > *,
.finance-overview-grid > *,
.metric-grid > * {
    min-width: 0;
}

.finance-filter-bar {
    grid-template-columns: repeat(2, minmax(180px, 240px)) auto;
}

.finance-overview-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 1fr;
    gap: 12px;
    margin-bottom: 18px;
}

.finance-overview-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    min-height: 132px;
    margin: 0;
}

.finance-overview-card span {
    min-height: 34px;
    margin-bottom: 0;
}

.finance-overview-card strong {
    font-size: 24px;
    line-height: 1.2;
}

.finance-overview-card small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.finance-hero {
    display: grid;
    grid-template-columns: minmax(300px, .9fr) minmax(420px, 1.1fr);
    gap: 16px;
    margin-bottom: 18px;
}

.finance-profit-card {
    min-height: 178px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.finance-profit-card h2,
.finance-profit-card p {
    margin: 0;
}

.finance-profit-card h2 {
    font-size: 24px;
}

.finance-profit-card p {
    color: var(--muted);
    line-height: 1.45;
}

.hero-kicker {
    display: block;
    margin-bottom: 12px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.finance-profit-value {
    display: block;
    margin: 10px 0;
    color: var(--primary-dark);
    font-size: 24px;
    line-height: 1.2;
}

.finance-hero .metric strong,
.finance-dashboard-grid .metric strong {
    font-size: 24px;
}

.finance-side-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.finance-side-grid .metric {
    margin: 0;
}

.finance-settings-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(135px, 1fr));
    gap: 14px;
    align-items: end;
}

.finance-notes-field {
    grid-column: span 3;
}

.finance-settings-actions {
    display: flex;
    align-items: end;
}

.finance-settings-actions .button {
    width: 100%;
}

.finance-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.finance-profit-panel,
.finance-bank-panel {
    grid-column: 1 / -1;
}

.finance-profit-panel .table-wrap {
    max-width: none;
}

.finance-summary-table {
    min-width: 0;
}

.finance-summary-table th,
.finance-summary-table td {
    padding: 10px 8px;
}

.finance-bank-panel .table-wrap {
    overflow-x: auto;
}

.finance-bank-table {
    min-width: 1120px;
    table-layout: fixed;
}

.finance-bank-table th,
.finance-bank-table td {
    vertical-align: top;
}

.finance-bank-table th:nth-child(1),
.finance-bank-table td:nth-child(1) {
    width: 112px;
    white-space: nowrap;
}

.finance-bank-table th:nth-child(2),
.finance-bank-table td:nth-child(2) {
    width: 230px;
}

.finance-bank-table th:nth-child(3),
.finance-bank-table td:nth-child(3) {
    width: 170px;
}

.finance-bank-table th:nth-child(4),
.finance-bank-table td:nth-child(4) {
    width: auto;
    line-height: 1.35;
}

.finance-bank-table th:nth-child(5),
.finance-bank-table td:nth-child(5) {
    width: 140px;
    white-space: nowrap;
}

.finance-bank-table th:nth-child(6),
.finance-bank-table td:nth-child(6) {
    width: 160px;
}

.bank-statement-table {
    min-width: 1280px;
}

.bank-statement-table th:nth-child(1),
.bank-statement-table td:nth-child(1) {
    width: 112px;
}

.bank-statement-table th:nth-child(2),
.bank-statement-table td:nth-child(2) {
    width: 220px;
}

.bank-statement-table th:nth-child(3),
.bank-statement-table td:nth-child(3) {
    width: 165px;
}

.bank-statement-table th:nth-child(4),
.bank-statement-table td:nth-child(4) {
    width: auto;
}

.bank-statement-table th:nth-child(5),
.bank-statement-table td:nth-child(5),
.bank-statement-table th:nth-child(6),
.bank-statement-table td:nth-child(6) {
    width: 130px;
    white-space: nowrap;
}

.bank-statement-table th:nth-child(7),
.bank-statement-table td:nth-child(7) {
    width: 160px;
}

.bank-statement-total-row th,
.bank-statement-total-row td {
    background: var(--surface-soft);
    font-weight: 900;
}

.cash-sheet {
    overflow: hidden;
    background: var(--surface);
}

.cash-sheet-wrap {
    border-radius: 8px;
}

.cash-sheet-table {
    width: 100%;
}

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

.cash-sheet-table .table-actions {
    text-align: right;
    white-space: nowrap;
}

.cash-sheet-table .table-actions form {
    margin: 0;
}

.cash-sheet-table .table-actions > * + * {
    margin-left: 6px;
}

.cash-total-row td {
    background: var(--surface-soft);
    color: var(--text);
    font-weight: 800;
}

.cash-sheet-add-form {
    display: grid;
    grid-template-columns: 130px minmax(180px, 1fr) 150px 190px minmax(180px, 1fr) 180px 120px;
    gap: 12px;
    align-items: end;
    padding: 14px;
    border-top: 1px solid #222;
    background: var(--surface-soft);
}

.cash-expense-actions {
    display: flex;
}

.cash-expense-actions .button {
    width: 100%;
}

.finance-cash-table {
    min-width: 760px;
    table-layout: fixed;
}

.finance-cash-table th,
.finance-cash-table td {
    vertical-align: top;
}

.finance-cash-table th:nth-child(1),
.finance-cash-table td:nth-child(1) {
    width: 320px;
}

.finance-cash-table th:nth-child(2),
.finance-cash-table td:nth-child(2) {
    width: 170px;
    white-space: nowrap;
}

.finance-cash-table th:nth-child(3),
.finance-cash-table td:nth-child(3) {
    width: 170px;
}

.finance-cash-table th:nth-child(4),
.finance-cash-table td:nth-child(4) {
    width: 180px;
    text-align: right;
}

.finance-bar-cell {
    min-width: 138px;
}

.finance-bar-cell > span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.finance-bar {
    height: 8px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--surface-soft);
}

.finance-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.finance-bar-danger span {
    background: var(--danger);
}

.statement-upload-form {
    margin: 0;
}

.statement-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.statement-upload-button {
    position: relative;
    overflow: hidden;
}

.statement-upload-button input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.bank-edit-row td {
    background: var(--surface-soft);
}

.bank-edit-form {
    display: grid;
    grid-template-columns: 130px 170px 180px minmax(220px, 1fr) 150px auto;
    gap: 12px;
    align-items: end;
}

.bank-add-form {
    grid-template-columns: 150px 130px 170px 180px minmax(220px, 1fr) 150px auto;
}

.bank-balance-edit-form {
    grid-template-columns: minmax(220px, 360px) auto;
    justify-content: end;
}

.cash-edit-form {
    grid-template-columns: 130px minmax(180px, 1fr) 150px 170px minmax(180px, 1fr) 170px auto;
}

.cash-template-edit-form {
    grid-template-columns: minmax(220px, 1fr) 150px 180px auto;
}

.cash-add-form {
    grid-template-columns: 130px minmax(220px, 1fr) 150px 180px auto;
}

.bank-edit-description {
    min-width: 0;
}

.bank-edit-actions {
    display: flex;
    gap: 8px;
}

.report-filter-bar {
    grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
}

.report-downloads {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.payments-report-table {
    min-width: 840px;
}

.agent-report-table {
    min-width: 980px;
}

.agent-report-cards {
    display: none;
}

.agent-report-card {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.agent-report-card-title {
    margin-bottom: 12px;
    color: var(--text);
    font-size: 18px;
    font-weight: 900;
}

.agent-report-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.agent-report-card-grid div {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 10px;
    border-radius: 8px;
    background: var(--surface-soft);
}

.agent-report-card-grid span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.agent-report-card-grid strong {
    color: var(--text);
    font-size: 15px;
}

.agent-report-total-card {
    border-color: var(--primary);
}

.dashboard-table {
    min-width: 0;
    table-layout: fixed;
}

.dashboard-table th,
.dashboard-table td {
    overflow-wrap: anywhere;
}

.dashboard-table th {
    white-space: normal;
}

.dashboard-scroll {
    max-height: 360px;
    overflow-y: auto;
    overflow-x: hidden;
}

.dashboard-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface);
}

.payments-report-table th,
.payments-report-table td {
    padding: 10px 8px;
}

.table-total-row td {
    border-top: 2px solid var(--border);
    background: var(--surface-soft);
    font-weight: 900;
}

.table-total-row td:first-child {
    color: var(--text);
}

.table-input {
    width: 86px;
    min-height: 34px;
    padding: 6px 8px;
    border-radius: 8px;
    font-weight: 700;
}

.months-input {
    width: 64px;
}

.amount-input {
    width: 96px;
}

.payment-edit-row td {
    background: var(--surface-soft);
}

.payment-edit-form {
    display: grid;
    grid-template-columns: minmax(0, 720px) auto;
    align-items: flex-end;
    gap: 18px;
    width: 100%;
}

.payment-edit-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.payment-edit-field {
    display: grid;
    gap: 8px;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
}

.payment-edit-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    line-height: 1.2;
}

.payment-edit-field .table-input,
.payment-edit-output {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-weight: 800;
    line-height: 22px;
}

.payment-edit-output {
    padding-right: 58px;
    background: var(--surface-soft);
}

.payment-edit-currency input {
    padding-right: 58px;
}

.payment-edit-actions {
    display: flex;
    justify-self: end;
    gap: 8px;
}

.inline-form {
    display: inline;
}

.table-actions {
    white-space: nowrap;
}

.table-actions form {
    display: inline-flex;
    margin: 0;
    vertical-align: middle;
}

.table-actions > * + * {
    margin-left: 6px;
}

.simple-pagination {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.page-button,
.page-status {
    min-width: 34px;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.page-status {
    min-width: 58px;
    color: var(--muted);
    font-weight: 600;
}

.page-button.disabled {
    color: #a5afab;
    background: var(--surface-soft);
}

@media (max-width: 900px) {
    .topbar {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 8px 10px;
    }

    .brand {
        grid-column: 1;
        grid-row: 1;
        min-width: 0;
    }

    .nav {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        min-width: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        overflow-x: visible;
    }

    .nav a {
        width: 100%;
        min-width: 0;
        padding-left: 10px;
        padding-right: 10px;
    }

    .user-menu {
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
        min-width: 0;
    }

    .page {
        width: min(100% - 20px, 1180px);
        max-width: 100%;
        overflow-x: hidden;
    }

    .panel,
    .metric,
    .report-grid > *,
    .finance-dashboard-grid > *,
    .finance-overview-grid > *,
    .metric-grid > * {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .section-header {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 10px;
    }

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

    .report-grid,
    .finance-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .finance-overview-grid,
    .finance-filter-bar,
    .finance-settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .finance-settings-grid label,
    .finance-settings-actions {
        min-width: 0;
    }

    .finance-settings-actions {
        grid-column: 1 / -1;
    }

    .finance-settings-actions .button {
        max-width: 260px;
    }
}

@media (max-width: 760px) {
    .topbar {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        padding: 10px 12px;
        gap: 8px 10px;
    }

    .brand {
        grid-column: 1;
        grid-row: 1;
        min-height: 40px;
        padding: 0;
    }

    .brand-logo {
        width: 142px;
        height: 34px;
    }

    .page-heading,
    .filter-actions {
        width: 100%;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        min-width: 0;
        overflow-x: auto;
    }

    .nav a {
        flex: 0 0 auto;
    }

    .user-menu {
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
        width: auto;
        gap: 8px;
    }

    .user-menu > span {
        display: none;
    }

    .user-menu .button {
        min-height: 34px;
        padding: 7px 10px;
    }

    .page {
        width: min(100% - 20px, 1180px);
        max-width: 100%;
        margin-top: 18px;
        overflow-x: hidden;
    }

    .panel,
    .metric,
    .report-grid > *,
    .finance-dashboard-grid > *,
    .finance-overview-grid > *,
    .metric-grid > * {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

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

    .filter-bar,
    .filter-bar.single,
    .agent-filter-bar,
    .dashboard-filter-bar,
    .report-filter-bar,
    .finance-filter-bar,
    .finance-overview-grid,
    .payments-search-bar,
    .form-grid,
    .report-grid,
    .finance-hero,
    .finance-dashboard-grid,
    .finance-settings-grid,
    .cash-sheet-add-form,
    .billing-layout {
        grid-template-columns: 1fr;
    }

    .finance-notes-field {
        grid-column: auto;
    }

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

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

    .radius-alert-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .finance-side-grid {
        grid-template-columns: 1fr;
    }

    .metric {
        min-height: 88px;
        padding: 14px;
    }

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

    .agent-customer-table {
        display: block;
        min-width: 0;
    }

    .agent-customer-table thead {
        display: none;
    }

    .agent-customer-table tbody,
    .agent-customer-table tr,
    .agent-customer-table td {
        display: block;
        width: 100%;
    }

    .agent-customer-table tr {
        padding: 14px 0;
        border-bottom: 1px solid var(--border);
    }

    .agent-customer-table td {
        padding: 4px 0;
        border-bottom: 0;
    }

    .agent-customer-table td:nth-child(2),
    .agent-customer-table td:nth-child(3) {
        display: inline-flex;
        width: auto;
        margin-right: 10px;
        align-items: center;
    }

    .agent-customer-table td:nth-child(1) {
        width: 100%;
    }

    .agent-customer-table td.table-actions {
        width: 100%;
        text-align: left;
        padding-top: 10px;
        white-space: normal;
    }

    .dashboard-scroll {
        max-height: 420px;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .dashboard-table {
        display: block;
        min-width: 0;
        table-layout: auto;
    }

    .dashboard-table thead {
        display: none;
    }

    .dashboard-table tbody {
        display: grid;
        gap: 10px;
    }

    .dashboard-table tr {
        display: grid;
        gap: 8px;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 8px;
        background: var(--surface);
    }

    .dashboard-table td {
        display: grid;
        grid-template-columns: 112px minmax(0, 1fr);
        gap: 8px;
        align-items: start;
        padding: 0;
        border-bottom: 0;
        overflow-wrap: break-word;
        word-break: normal;
    }

    .dashboard-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        line-height: 1.25;
    }

    .dashboard-table td.empty {
        display: block;
        text-align: center;
    }

    .dashboard-table td.empty::before {
        content: none;
    }

    .quick-bill-actions {
        min-width: 0;
        justify-content: flex-start;
        gap: 12px;
    }

    .quick-bill-stack {
        width: 100%;
        max-width: 100%;
        justify-items: start;
        white-space: normal;
    }

    .billing-subnote {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .quick-bill-actions .button {
        min-width: 112px;
    }

    .details-list div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .filter-actions .button {
        flex: 1;
    }

    .report-downloads .button {
        flex: 1;
    }

    .status-buttons .button {
        flex: 1;
    }

    .bank-edit-form {
        grid-template-columns: 1fr;
    }

    .statement-actions {
        width: 100%;
        justify-content: stretch;
    }

    .statement-actions .button,
    .statement-actions .statement-upload-form {
        width: 100%;
    }

    .statement-upload-button {
        display: flex;
        justify-content: center;
    }

    .cash-edit-form,
    .cash-template-edit-form,
    .cash-add-form,
    .bank-add-form,
    .bank-balance-edit-form {
        grid-template-columns: 1fr;
    }

    .bank-edit-actions .button {
        flex: 1;
    }

    .billing-note {
        display: block;
        max-width: 100%;
    }

    .modal-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .payment-edit-form {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .payment-edit-fields,
    .payment-edit-actions {
        width: 100%;
    }

    .payment-edit-actions {
        justify-self: stretch;
    }

    .payment-edit-actions .button {
        flex: 1;
    }

    .agent-report-table-wrap {
        display: none;
    }

    .agent-report-cards {
        display: grid;
        gap: 12px;
    }
}

@media (max-width: 460px) {
    .auth-logo {
        width: 188px;
        height: 46px;
    }

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

    .payment-edit-fields {
        grid-template-columns: 1fr;
    }

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

    .button {
        padding-left: 12px;
        padding-right: 12px;
    }

    .payments-report-table {
        min-width: 840px;
    }
}

@media (max-width: 360px) {
    .inline-edit-form {
        grid-template-columns: minmax(0, 1fr) auto auto;
        width: 100%;
    }

    .inline-edit-form[data-phone-edit-form] {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .inline-edit-form input {
        width: 100%;
    }

    .metric-grid,
    .finance-overview-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-table td {
        grid-template-columns: 96px minmax(0, 1fr);
    }
}
