/* Hand-written and deliberately small: no CSS framework, so there is no build
   step and nothing to keep in sync with a dependency. */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --border: #dfe3e8;
    --text: #1c2128;
    --muted: #5a6472;
    --accent: #1f4e79;
    --accent-text: #ffffff;

    --status-draft: #6b7280;
    --status-pending: #b45309;
    --status-approved: #15803d;
    --status-rejected: #b91c1c;
    --status-completed: #1d4ed8;
    --status-cancelled: #6b7280;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171c;
        --surface: #1c2028;
        --border: #2f3540;
        --text: #e6e9ee;
        --muted: #9aa4b2;
        --accent: #7aa7d4;
        --accent-text: #14171c;

        --status-draft: #9aa4b2;
        --status-pending: #d99a3a;
        --status-approved: #4ec27e;
        --status-rejected: #e5766e;
        --status-completed: #6fa4f0;
        --status-cancelled: #9aa4b2;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

/* --- Layout --- */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.site-header .inner,
main.container {
    max-width: 60rem;
    margin: 0 auto;
    padding: 0 1rem;
}

.site-header .inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.brand {
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
}

.site-header nav {
    display: flex;
    gap: 1rem;
    margin-right: auto;
}

.site-header nav a {
    text-decoration: none;
    color: var(--muted);
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
}

.site-header nav a.active,
.site-header nav a:hover {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.session {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--muted);
}

main.container { padding-top: 2rem; padding-bottom: 3rem; }

h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }

.subtitle { color: var(--muted); margin: 0 0 1.5rem; }

/* --- Buttons --- */

button, .button {
    font: inherit;
    font-size: 0.875rem;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
}

button:hover, .button:hover { border-color: var(--accent); }

button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

/* --- Cards and tables --- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
}

.table-scroll { overflow-x: auto; }

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

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

th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 600;
}

tbody tr:last-child td { border-bottom: none; }

td a { font-weight: 500; }

.muted { color: var(--muted); font-size: 0.875rem; }

/* --- Status badges --- */

.badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    border: 1px solid currentColor;
    white-space: nowrap;
}

.badge.status-draft { color: var(--status-draft); }
.badge.status-pending { color: var(--status-pending); }
.badge.status-approved { color: var(--status-approved); }
.badge.status-rejected { color: var(--status-rejected); }
.badge.status-completed { color: var(--status-completed); }
.badge.status-cancelled { color: var(--status-cancelled); }

/* --- Detail view --- */

.detail-grid {
    display: grid;
    grid-template-columns: 11rem 1fr;
    gap: 0.75rem 1.5rem;
    padding: 1.25rem;
}

.detail-grid dt { color: var(--muted); font-size: 0.875rem; }
.detail-grid dd { margin: 0; }

@media (max-width: 34rem) {
    .detail-grid { grid-template-columns: 1fr; gap: 0.25rem 0; }
    .detail-grid dd { margin-bottom: 0.75rem; }
}

.system-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }

.system-list li {
    font-size: 0.8125rem;
    padding: 0.15rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
}

.system-list li.inactive { color: var(--muted); font-style: italic; }

.notes { white-space: pre-wrap; margin: 0; }

/* --- Pagination --- */

.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
    font-size: 0.875rem;
    color: var(--muted);
}

.pagination .spacer { margin-left: auto; }

/* --- Empty state --- */

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

/* --- Login page --- */

.auth {
    max-width: 22rem;
    margin: 4rem auto;
    padding: 1.75rem;
}

.auth p { margin: 0 0 1rem; }
.auth label { display: block; font-size: 0.875rem; color: var(--muted); margin-bottom: 0.25rem; }

.auth input[type="text"],
.auth input[type="password"] {
    width: 100%;
    font: inherit;
    padding: 0.45rem 0.6rem;
    margin-bottom: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg);
    color: var(--text);
}

.errorlist { color: var(--status-rejected); font-size: 0.875rem; padding-left: 1rem; margin: 0.35rem 0 0; }

/* --- Page heading with an action --- */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem;
}

.page-head > div { margin-right: auto; }

/* --- Messages --- */

.messages { list-style: none; margin: 0 0 1.5rem; padding: 0; }

.message {
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: 0.375rem;
    background: var(--surface);
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

.message.success { border-left-color: var(--status-approved); }
.message.error { border-left-color: var(--status-rejected); }
.message.warning { border-left-color: var(--status-pending); }
.message.info { border-left-color: var(--status-completed); }

/* --- Forms --- */

.form-card { padding: 1.25rem; }

.field { margin-bottom: 1.15rem; }

.field > label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.3rem;
}

.field .required { color: var(--status-rejected); }

.field .help { margin: 0.3rem 0 0; font-size: 0.8125rem; }

.field input[type="text"],
.field input[type="date"],
.field input[type="number"],
.field select,
.field textarea {
    width: 100%;
    font: inherit;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg);
    color: var(--text);
}

.field textarea { resize: vertical; }

/* Checkbox list for the systems multi-select. */
.field ul {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg);
    max-height: 15rem;
    overflow-y: auto;
    columns: 2;
    column-gap: 1.5rem;
}

.field ul li { break-inside: avoid; }

.field ul label {
    font-weight: normal;
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0;
}

@media (max-width: 34rem) {
    .field ul { columns: 1; }
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

.actions-bar { margin-bottom: 1.25rem; }

button.destructive, .button.destructive {
    color: var(--status-rejected);
    border-color: var(--status-rejected);
}

button.destructive:hover, .button.destructive:hover {
    background: var(--status-rejected);
    color: var(--surface);
}

.confirm-summary { padding: 1rem 0; }

/* --- Wizard --- */

.wizard-progress {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 0;
    counter-reset: wizard-step;
    font-size: 0.875rem;
    color: var(--muted);
}

.wizard-progress li {
    counter-increment: wizard-step;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.wizard-progress li::before {
    content: counter(wizard-step);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
}

.wizard-progress li.current { color: var(--text); font-weight: 600; }

.wizard-progress li.current::before {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

.wizard-progress li.done::before {
    border-color: var(--status-approved);
    color: var(--status-approved);
}

hr.rule {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* Radio lists (request type, employee mode) read better in one column. */
.field ul.radio-single { columns: 1; }

/* --- Dashboard: KPI row of stat tiles --- */

.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat { padding: 1.1rem 1.25rem; }

.stat-label {
    margin: 0 0 0.35rem;
    font-size: 0.8125rem;
    color: var(--muted);
}

.stat-value {
    margin: 0;
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.1;
    /* Proportional figures deliberately: tabular-nums gives every digit the
       width of a zero, which reads loose at display sizes. Tabular is for
       columns of numbers that must align, not for a standalone value. */
}

/* The one number the view leads with. Exactly one per page. */
.stat.hero { grid-column: span 2; }
.stat.hero .stat-value { font-size: 3rem; }

@media (max-width: 34rem) {
    .stat.hero { grid-column: span 1; }
    .stat.hero .stat-value { font-size: 2.5rem; }
}

.stat .muted { font-size: 0.8125rem; margin: 0.35rem 0 0; }

.section-heading {
    font-size: 1.05rem;
    margin: 0 0 0.75rem;
}

.card + .section-heading { margin-top: 2rem; }

/* Screen-reader-only: for a column header that exists structurally but has no
   visible text (an actions column). */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
