:root {
    --ink: #1f2933;
    --muted: #667085;
    --line: #d7dee8;
    --paper: #ffffff;
    --back: #f7f8fb;
    --blue: #1f5fbf;
    --green: #146c43;
    --red: #b42318;
    --amber: #a15c07;
    --teal: #0f766e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--back);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: 0 16px;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-weight: 800;
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 12px;
    font-size: 14px;
}

.nav a {
    color: var(--muted);
    text-decoration: none;
}

.shell {
    width: min(1080px, 100%);
    margin: 0 auto;
    padding: 18px 14px 44px;
}

.auth {
    width: min(430px, 100%);
    margin: 40px auto;
    padding: 22px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 27px; }
h2 { font-size: 20px; }
p { margin: 8px 0 0; color: var(--muted); }
small { color: var(--muted); }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1.05fr .95fr; }
.metrics { grid-template-columns: repeat(4, 1fr); }
.top-gap { margin-top: 14px; }

.panel, .metric, .list-item, .user-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.panel { padding: 16px; }
.metric { padding: 14px; }
.metric span, label {
    display: block;
    color: var(--muted);
    font-size: 13px;
}
.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 23px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
}

.toolbar-actions {
    display: flex;
    align-items: end;
    gap: 10px;
}

form, .stack {
    display: grid;
    gap: 12px;
}

.stack { margin-top: 14px; }

input, select, textarea, button, .button {
    width: 100%;
    font: inherit;
    border-radius: 8px;
}

input, select, textarea {
    margin-top: 5px;
    padding: 11px 12px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
}

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

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 14px;
    color: #fff;
    background: var(--ink);
    border: 1px solid transparent;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

button.secondary, .button.ghost {
    color: var(--ink);
    background: #fff;
    border-color: var(--line);
}

.alert {
    margin-bottom: 14px;
    padding: 10px 12px;
    color: #713b00;
    background: #fff4e5;
    border: 1px solid #ffd8a8;
    border-radius: 8px;
}

.alert.success {
    color: var(--green);
    background: #ecfdf3;
    border-color: #abefc6;
}

.split-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.month-form { width: 180px; }

.list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.list-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 13px;
}

.right { text-align: right; }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.pending { color: var(--amber); background: #fff7e6; }
.approved { color: var(--blue); background: #eef4ff; }
.paid { color: var(--green); background: #ecfdf3; }
.rejected { color: var(--red); background: #fff1f0; }
.cancelled { color: #475467; background: #eef1f5; }

.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}
th, td {
    padding: 11px 8px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}
th {
    color: var(--muted);
    font-size: 13px;
}

.actions {
    display: flex;
    gap: 8px;
    min-width: 210px;
    align-items: end;
}
.actions form { display: block; }
.actions button { min-height: 34px; padding: 6px 9px; font-size: 13px; }
.actions select { min-width: 150px; padding: 6px 8px; font-size: 13px; }
.pay-form { display: flex; gap: 6px; align-items: end; }

.inline-action {
    margin-top: 8px;
}

.inline-action button {
    min-height: 32px;
    padding: 5px 10px;
    font-size: 13px;
}

.note {
    font-size: 13px;
}

.chart-box { height: 290px; }

.user-list {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.user-card { padding: 13px; }

.user-form {
    grid-template-columns: 1.1fr 1.4fr 120px 82px 105px 84px;
    align-items: end;
}

.password-form {
    grid-template-columns: 1fr 120px;
    align-items: end;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 43px;
}
.checkline input {
    width: auto;
    margin: 0;
}

@media (max-width: 840px) {
    h1 { font-size: 24px; }
    .toolbar {
        flex-direction: column;
    }
    .toolbar-actions {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }
    .month-form {
        width: 100%;
    }
    .grid.two,
    .metrics,
    .split-row,
    .user-form,
    .password-form {
        grid-template-columns: 1fr;
    }
    .list-item {
        grid-template-columns: 1fr;
    }
    .right {
        text-align: left;
    }
    .actions {
        min-width: 0;
        flex-wrap: wrap;
    }
    .pay-form {
        flex-direction: column;
        align-items: stretch;
    }
}
