:root {
    --bg: #0b1016;
    --surface: #151b24;
    --surface-2: #1c2430;
    --surface-3: #243041;
    --border: rgba(255, 255, 255, 0.08);
    --text: #f3f6fb;
    --muted: #94a3b8;
    --accent: #6c8cff;
    --accent-2: #8b5cf6;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    --radius: 16px;
    --sidebar-width: 280px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
    background: linear-gradient(180deg, var(--bg) 0%, #101722 100%);
    color: var(--text);
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

button, .btn, input[type="submit"], input[type="button"] {
    font: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: rgba(11, 16, 22, 0.98);
    border-right: 1px solid var(--border);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 120;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 110;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    font-weight: 700;
    flex-shrink: 0;
}

.brand small,
.nav-section-title,
.page-eyebrow,
.stat-label,
.user-chip small,
.panel-header p,
.text-muted {
    color: var(--muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 18px;
    flex: 1;
    overflow-y: auto;
}

.nav-section { display: flex; flex-direction: column; gap: 6px; }

.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 10px;
}

.nav-link {
    padding: 11px 12px;
    border-radius: 12px;
    color: var(--muted);
    transition: 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(108, 140, 255, 0.12);
    color: var(--text);
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.logout-link { color: #ffb4b4; }

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

.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: rgba(21, 27, 36, 0.95);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-topbar-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.14);
    color: #ffb4b4;
    font-size: 0.875rem;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
}

.mobile-logout-btn:hover {
    background: rgba(239, 68, 68, 0.24);
    color: #ffd0d0;
}

.page-header { margin-bottom: 20px; }
.page-header h1 { margin: 4px 0 0; font-size: clamp(1.5rem, 4vw, 2rem); }
.page-body { display: flex; flex-direction: column; gap: 20px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
}

.stat-card,
.panel,
.quick-link-card {
    background: rgba(21, 27, 36, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stat-card { padding: 18px; }
.stat-value { display: block; font-size: 1.8rem; margin: 8px 0; }

.panel-header,
.panel-body { padding: 20px; }
.panel-header { border-bottom: 1px solid var(--border); }
.panel-header h2, .panel-header p { margin: 0; }
.panel-header p { margin-top: 6px; }

.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.quick-link-card {
    padding: 18px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.quick-link-card:hover {
    transform: translateY(-2px);
    border-color: rgba(108, 140, 255, 0.35);
}

.quick-link-card span {
    color: var(--muted);
    display: block;
    margin-top: 8px;
}

.alert {
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.35);
}

.alert-error,
.alert-danger {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.35);
}

.form-grid,
.filter-bar,
.form-row {
    display: grid;
    gap: 14px;
}

.form-grid.two-col,
.form-row {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.filter-bar {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-size: 0.92rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
}

input[readonly] { opacity: 0.85; }

button,
.btn,
input[type="submit"],
input[type="button"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
    font-weight: 600;
}

.btn-secondary,
button.secondary {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-danger,
button.danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.inline-actions,
.button-group,
.actions-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

fieldset {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    margin: 0 0 16px;
    background: rgba(28, 36, 48, 0.5);
}

legend {
    padding: 0 8px;
    color: var(--muted);
}

.table-wrap,
.table-scroll {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(28, 36, 48, 0.35);
}

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

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

th {
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(15, 20, 25, 0.5);
}

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

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    background: rgba(108, 140, 255, 0.15);
    color: #c7d7ff;
}

.badge-super { background: rgba(139, 92, 246, 0.18); color: #ddd6fe; }
.badge-admin { background: rgba(34, 197, 94, 0.15); color: #bbf7d0; }

.copy-box,
.preview-box,
.info-box {
    background: rgba(28, 36, 48, 0.8);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
}

.copy-box.success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.35);
}

.copy-box pre,
.preview-box pre,
.code-block {
    white-space: pre-wrap;
    margin: 0 0 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92rem;
}

.warning-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 14px;
    padding: 16px;
}

.preview-box.highlight {
    background: rgba(108, 140, 255, 0.08);
    border-color: rgba(108, 140, 255, 0.25);
}

.empty-state {
    padding: 24px;
    text-align: center;
    color: var(--muted);
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
}

#hoursModal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 760px);
    max-height: 85vh;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    z-index: 210;
    box-shadow: var(--shadow);
}

#hoursModal.open,
.modal-overlay.open { display: block; }

.staff-list,
.preview-list {
    margin: 0;
    padding-left: 20px;
}

.staff-list li,
.preview-list li { margin: 6px 0; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 420px);
    background: rgba(21, 27, 36, 0.96);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.login-card h1 { margin-top: 0; }

.compact-table td form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.compact-table td input,
.compact-table td select {
    min-width: 120px;
}

a.btn, a.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    border-radius: 10px;
    font-weight: 600;
}

a.btn-secondary {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}

#hoursModal h3 { margin-top: 0; }

details summary {
    list-style: none;
}

details summary::-webkit-details-marker {
    display: none;
}

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

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: min(85vw, var(--sidebar-width));
    }

    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }

    .mobile-topbar { display: flex; }
    .main-content { padding: 16px; }

    .sidebar-footer {
        position: sticky;
        bottom: 0;
        background: rgba(11, 16, 22, 0.98);
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .logout-link {
        text-align: center;
        padding: 12px;
        border-radius: 12px;
        border: 1px solid rgba(239, 68, 68, 0.35);
        background: rgba(239, 68, 68, 0.12);
        font-weight: 600;
    }

    .page-header h1 { font-size: 1.5rem; }

    table { min-width: 560px; }

    .compact-table td form {
        flex-direction: column;
        align-items: stretch;
    }
}
