:root {
    color-scheme: light;
    --bg: #f3f4f6;
    --panel: #ffffff;
    --text: #18212f;
    --muted: #667085;
    --line: #d7dce3;
    --accent: #d72638;
    --accent-dark: #a91423;
    --dark: #14171f;
    --soft: #eef2f7;
    --success: #0f7a4f;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

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

a {
    color: inherit;
}

button,
.button {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 12px;
    font: inherit;
    text-decoration: none;
    white-space: nowrap;
}

button.primary,
.button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

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

.button.small {
    min-height: 32px;
    padding: 6px 10px;
}

.button.danger {
    border-color: #f0b6b1;
    color: var(--danger);
}

.login-screen {
    display: grid;
    place-items: center;
    padding: 24px;
    background: #191d25;
}

.login-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.brand {
    font-weight: 600;
    letter-spacing: 0;
    color: var(--accent);
    text-transform: uppercase;
}

.login-card h1,
.panel h1 {
    margin: 8px 0 18px;
    font-size: 28px;
    letter-spacing: 0;
}

.login-card form,
.record-form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
    color: #344054;
    font-weight: 600;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 11px;
    color: var(--text);
    background: #fff;
    font: inherit;
    font-weight: 400;
}

textarea {
    resize: vertical;
}

.alert,
.success {
    border-radius: 6px;
    padding: 11px 12px;
    margin: 0 0 14px;
}

.alert {
    background: #fff0f0;
    color: var(--danger);
    border: 1px solid #f2c2bd;
}

.success {
    background: #eefbf3;
    color: var(--success);
    border: 1px solid #b9e7cc;
}

.shell {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: var(--dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
}

.sidebar .brand {
    color: #fff;
    margin-bottom: 24px;
}

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

.sidebar a {
    border-radius: 6px;
    color: #d5d9e0;
    padding: 11px 12px;
    text-decoration: none;
}

.sidebar a.active,
.sidebar a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.logout {
    margin-top: auto;
    display: grid;
    gap: 10px;
    color: #d5d9e0;
}

.logout span {
    font-size: 13px;
}

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

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

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

.panel-head p {
    margin: -8px 0 0;
    color: var(--muted);
}

.filter-bar {
    align-items: end;
    display: grid;
    grid-template-columns: minmax(220px, 320px) auto;
    gap: 12px;
    margin-bottom: 16px;
}

.filter-bar button {
    width: fit-content;
}

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

.stat-card {
    background: #fbfcfe;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 7px;
    min-height: 118px;
    padding: 14px;
}

.stat-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.stat-card strong {
    color: var(--text);
    font-size: 22px;
    line-height: 1.15;
    word-break: break-word;
}

.stat-card small {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

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

th {
    background: var(--soft);
    color: #344054;
    font-size: 13px;
    font-weight: 600;
}

td {
    background: #fff;
}

tr:hover td {
    background: #fbfcfe;
}

tr.record-done td {
    background: #f0fbf4;
}

tr.record-done:hover td {
    background: #e6f7ed;
}

tr.record-open td {
    background: #fff5f5;
}

tr.record-open:hover td {
    background: #ffecec;
}

.status-badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    justify-content: center;
    min-width: 74px;
    padding: 5px 9px;
    white-space: nowrap;
}

.record-done .status-badge {
    background: #dff5e8;
    color: var(--success);
}

.record-open .status-badge {
    background: #ffe1df;
    color: var(--danger);
}

.description {
    min-width: 220px;
    max-width: 340px;
}

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

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

.actions form {
    margin: 0;
}

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

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

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

.checkbox-field {
    align-content: start;
    border: 1px solid var(--line);
    border-radius: 6px;
    grid-template-columns: 1fr auto;
    min-height: 43px;
    padding: 10px 11px;
}

.checkbox-field input {
    height: 18px;
    margin: 0;
    width: 18px;
}

.supplier-custom {
    display: none;
}

.supplier-custom.open {
    display: grid;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.audit-table {
    min-width: 1320px;
}

.audit-value {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 860px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    .content {
        padding: 16px;
    }

    .panel {
        padding: 16px;
    }

    .panel-head {
        display: grid;
    }

    .filter-bar {
        grid-template-columns: 1fr;
    }

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

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

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