:root {
    color-scheme: light dark;

    --color-bg: #f4f6fb;
    --color-surface: #ffffff;
    --color-surface-2: #eef1f8;
    --color-border: #e2e6f0;
    --color-text: #1c2333;
    --color-text-muted: #6b7280;
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-contrast: #ffffff;
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-success-bg: #ecfdf5;
    --color-success-text: #047857;
    --color-success-border: #a7f3d0;
    --color-error-bg: #fef2f2;
    --color-error-text: #b91c1c;
    --color-error-border: #fecaca;

    --status-pending: #2563eb;
    --status-pending-bg: #eff6ff;
    --status-onhold: #d97706;
    --status-onhold-bg: #fffbeb;
    --status-denied: #dc2626;
    --status-denied-bg: #fef2f2;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
    --radius: 12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #12141c;
        --color-surface: #1a1d29;
        --color-surface-2: #21243272;
        --color-surface-2: #232637;
        --color-border: #2e3244;
        --color-text: #e7e9f2;
        --color-text-muted: #9599ab;
        --color-primary: #818cf8;
        --color-primary-hover: #6366f1;
        --color-primary-contrast: #12141c;
        --color-danger: #f87171;
        --color-danger-hover: #ef4444;
        --color-success-bg: #0b2e22;
        --color-success-text: #6ee7b7;
        --color-success-border: #14532d;
        --color-error-bg: #2e1414;
        --color-error-text: #fca5a5;
        --color-error-border: #7f1d1d;

        --status-pending: #60a5fa;
        --status-pending-bg: #101d33;
        --status-onhold: #fbbf24;
        --status-onhold-bg: #2e230a;
        --status-denied: #f87171;
        --status-denied-bg: #2e1414;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    }
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.site-header {
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.5rem;
    flex-wrap: wrap;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--color-text);
}

.nav-brand:hover {
    text-decoration: none;
}

.nav-brand .logo-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-primary);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.nav-link {
    padding: 0.45rem 0.8rem;
    border-radius: 8px;
    color: var(--color-text-muted);
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-link:hover {
    background: var(--color-surface-2);
    text-decoration: none;
    color: var(--color-text);
}

.nav-link.active {
    background: var(--color-surface-2);
    color: var(--color-primary);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 3rem;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0 0 0.25rem;
    font-size: 1.6rem;
}

.page-subtitle {
    color: var(--color-text-muted);
    margin: 0;
    font-size: 0.95rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--color-surface-2);
    color: var(--color-text);
    transition: background-color 0.15s ease, transform 0.05s ease;
}

.btn:hover {
    background: var(--color-border);
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-primary-contrast);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
}

.btn-danger {
    background: transparent;
    color: var(--color-danger);
    border-color: currentColor;
}

.btn-danger:hover {
    background: var(--color-danger);
    color: #fff;
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

/* Tabs */
.tab-list {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1.5rem;
}

.tab-button {
    padding: 0.65rem 1.1rem;
    border: none;
    background: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-button:hover {
    color: var(--color-text);
}

.tab-button.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.85rem;
}

/* Flash messages */
.flash {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid transparent;
    font-size: 0.95rem;
}

.flash-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
    border-color: var(--color-success-border);
}

.flash-error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
    border-color: var(--color-error-border);
}

/* Kanban board */
.board {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.board-column {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.board-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--color-border);
    font-weight: 700;
}

.board-column-header .count {
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--color-surface-2);
    color: var(--color-text-muted);
}

.board-column[data-status="pending"] .board-column-header { border-top: 3px solid var(--status-pending); color: var(--status-pending); }
.board-column[data-status="on_hold"] .board-column-header { border-top: 3px solid var(--status-onhold); color: var(--status-onhold); }
.board-column[data-status="denied"] .board-column-header { border-top: 3px solid var(--status-denied); color: var(--status-denied); }

.board-column-body {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 80px;
}

.board-empty {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 1.5rem 0.5rem;
}

/* Job card */
.job-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow-sm);
}

.job-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.job-card h3 {
    margin: 0;
    font-size: 1rem;
}

.job-card .job-role {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin: 0.15rem 0 0.5rem;
}

.job-card .job-meta {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.8rem;
    margin-bottom: 0.6rem;
}

.job-card .job-denial-reason {
    font-size: 0.85rem;
    background: var(--status-denied-bg);
    color: var(--status-denied);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    margin-bottom: 0.6rem;
}

.job-card-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.status-pending { color: var(--status-pending); background: var(--status-pending-bg); }
.status-onhold { color: var(--status-onhold); background: var(--status-onhold-bg); }
.status-denied { color: var(--status-denied); background: var(--status-denied-bg); }

/* Forms */
.form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    max-width: 640px;
}

.form-row {
    margin-bottom: 1.1rem;
}

.form-row label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

.form-row .form-help {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 0.3rem;
}

.form-row .form-error {
    font-size: 0.82rem;
    color: var(--color-danger);
    margin-top: 0.3rem;
}

input[type=text], input[type=url], input[type=date], input[type=password], textarea, select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 0.95rem;
    font-family: inherit;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 25%, transparent);
}

.char-counter {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    text-align: right;
    margin-top: 0.25rem;
}

.char-counter.is-over {
    color: var(--color-danger);
    font-weight: 600;
}

.form-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 1.4rem;
}

/* Tables (archive) */
.table-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

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

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

tbody tr:hover {
    background: var(--color-surface-2);
}

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--color-text-muted);
}

/* Statistics */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.1rem 1.25rem;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}

.stat-card .stat-label {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.month-row {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.25rem;
    margin-bottom: 0.85rem;
}

.month-row-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.month-row-top h3 {
    margin: 0;
    text-transform: capitalize;
    font-size: 1rem;
}

.month-row-top .month-total {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.month-bar {
    display: flex;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--color-surface-2);
    margin-bottom: 0.6rem;
}

.month-bar span {
    height: 100%;
}

.month-bar .bar-pending { background: var(--status-pending); }
.month-bar .bar-onhold { background: var(--status-onhold); }
.month-bar .bar-denied { background: var(--status-denied); }

.month-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

.month-legend .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.35rem;
}

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
}

.login-card h1 {
    font-size: 1.3rem;
    margin: 0 0 0.3rem;
    text-align: center;
}

.login-card .login-subtitle {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 900px) {
    .board {
        grid-template-columns: 1fr;
    }

    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 560px) {
    .nav {
        padding: 0.75rem 1rem;
    }

    .container {
        padding: 1.25rem 1rem 2.5rem;
    }

    .stat-cards {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
    }

    th, td {
        padding: 0.6rem 0.7rem;
    }
}
