:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --blue: #2563eb;
    --blue-soft: #eff6ff;
    --green: #dcfce7;
    --green-text: #166534;
    --red: #fee2e2;
    --red-text: #991b1b;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

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

.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 250px;
    overflow-y: auto;
    padding: 24px 18px;
    border-right: 1px solid var(--border);
    background: #ffffff;
}

.brand {
    margin-bottom: 26px;
    padding: 0 10px;
    color: var(--blue);
    font-size: 24px;
    font-weight: 800;
}

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

.sidebar a {
    display: block;
    padding: 11px 12px;
    border-radius: 12px;
    color: #334155;
    font-weight: 700;
    text-decoration: none;
}

.sidebar a:hover {
    background: var(--blue-soft);
    color: var(--blue);
}

.content {
    width: calc(100% - 250px);
    min-width: 0;
    margin-left: 250px;
    padding: 26px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.topbar strong {
    display: block;
    font-size: 18px;
}

.topbar span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.top-actions,
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

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

.page-header h1 {
    margin: 0;
    font-size: 32px;
    letter-spacing: -0.8px;
    overflow-wrap: anywhere;
}

.page-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.card,
.kpi {
    min-width: 0;
    margin-bottom: 20px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.grid {
    display: grid;
    gap: 20px;
}

.grid > * {
    min-width: 0;
}

.grid.two {
    grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
}

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

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

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

.kpi strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 12px;
    background: var(--blue);
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
}

.btn.secondary {
    border: 1px solid var(--border);
    background: #f8fafc;
    color: #334155;
}

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

.form label {
    display: block;
    margin: 14px 0 6px;
    font-weight: 700;
}

.form input,
.form textarea,
.form select,
.searchbar input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #ffffff;
    font: inherit;
}

.form textarea {
    min-height: 110px;
    resize: vertical;
}

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

.searchbar {
    display: flex;
    gap: 10px;
}

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

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

.table th {
    background: #f8fafc;
    color: #475569;
}

.table td {
    overflow-wrap: anywhere;
}

.right {
    text-align: right;
}

.muted {
    color: var(--muted);
}

.badge {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
}

.badge.paid,
.badge.success,
.badge.sent {
    background: var(--green);
    color: var(--green-text);
}

.badge.failed,
.badge.overdue,
.badge.critical {
    background: var(--red);
    color: var(--red-text);
}

.badge.open {
    background: #dbeafe;
    color: #1d4ed8;
}

.alert {
    margin-bottom: 18px;
    padding: 13px 15px;
    border-radius: 14px;
}

.alert.success {
    background: var(--green);
    color: var(--green-text);
}

.alert.error {
    background: var(--red);
    color: var(--red-text);
}

.login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 220px;
}

.bar-item {
    flex: 1;
    text-align: center;
}

.bar {
    min-height: 5px;
    border-radius: 8px 8px 0 0;
    background: var(--blue);
}

code {
    padding: 4px 6px;
    border-radius: 6px;
    background: #0f172a;
    color: #e0f2fe;
    font-size: 12px;
}

@media (max-width: 980px) {
    .layout {
        display: block;
    }

    .sidebar {
        position: relative;
        bottom: auto;
        width: 100%;
    }

    .content {
        width: 100%;
        margin-left: 0;
    }

    .grid.two,
    .grid.three,
    .kpi-grid,
    .form-row {
        grid-template-columns: 1fr;
    }

    .topbar,
    .page-header,
    .searchbar {
        flex-direction: column;
        align-items: stretch;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 640px) {
    .content,
    .login,
    .sidebar {
        padding: 16px;
    }

    .card,
    .kpi,
    .login-card {
        padding: 16px;
    }

    .btn,
    .top-actions > * {
        width: 100%;
    }
}
