/* ─── Base ─────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #14151c;
    color: #e8e9ed;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul { list-style: none; }
input, textarea, select {
    font-family: inherit;
    width: 100%;
    padding: 10px 12px;
    background: #2a2d39;
    border: 1px solid #353846;
    border-radius: 8px;
    color: #e8e9ed;
    font-size: 14px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: #7c5cff; }
textarea { resize: vertical; min-height: 80px; }
code {
    font-family: 'Courier New', monospace;
    background: #22242e;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}
small { font-size: 11px; color: #6b7080; display: block; margin-top: 4px; }

:root {
    --bg-0: #14151c;
    --bg-1: #1a1c24;
    --bg-2: #22242e;
    --bg-3: #2a2d39;
    --bg-4: #353846;
    --border: #2f3240;
    --text: #e8e9ed;
    --text-dim: #9aa0b1;
    --text-faint: #6b7080;
    --brand: #7c5cff;
    --brand-2: #a47dff;
    --brand-gradient: linear-gradient(135deg, #7c5cff 0%, #c45dff 100%);
    --success: #43b581;
    --danger: #f04747;
    --warning: #faa61a;
}

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
    background: var(--brand-gradient);
    color: #fff;
    box-shadow: 0 6px 22px -8px rgba(124, 92, 255, .8);
}
.btn-secondary { background: var(--bg-3); color: var(--text); border: 1px solid var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; justify-content: center; }

/* ─── Login ────────────────────────────────────────────────── */
.login-screen {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at 30% 20%, rgba(124, 92, 255, .15), transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(196, 93, 255, .12), transparent 50%),
                var(--bg-0);
}
.login-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 36px 32px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px -20px rgba(0, 0, 0, .6);
}
.login-logo {
    position: relative;
    width: 56px; height: 56px;
    border-radius: 16px;
    background:
        radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.35), transparent 55%),
        linear-gradient(135deg, #7c5cff 0%, #a35cff 35%, #c45dff 70%, #ff5cd0 100%);
    background-size: 200% 200%;
    animation: brand-shimmer 8s ease-in-out infinite;
    display: grid; place-items: center;
    font-size: 26px; font-weight: 900;
    color: #fff;
    margin: 0 auto 16px;
    text-shadow: 0 1px 2px rgba(60, 0, 80, 0.4);
    box-shadow:
        0 12px 32px -6px rgba(124, 92, 255, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        inset 0 -10px 20px -10px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}
.login-logo::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, transparent 35%, rgba(255, 255, 255, 0.22) 50%, transparent 65%);
    opacity: 0.7;
    pointer-events: none;
}
.login-logo::after {
    content: "";
    position: absolute;
    top: 14%; right: 14%;
    width: 10px; height: 10px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.95);
    animation: brand-spark 3s ease-in-out infinite;
}
.login-logo > * { position: relative; z-index: 1; }
@keyframes brand-shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}
@keyframes brand-spark {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}
.login-card h1 { font-size: 24px; margin-bottom: 8px; letter-spacing: -0.5px; }
.login-card > p { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-card label { font-size: 13px; font-weight: 600; }
.login-hint {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-2);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-dim);
}
.login-link {
    display: block;
    margin-top: 16px;
    color: var(--brand-2);
    font-size: 13px;
    font-weight: 500;
}
.login-link:hover { color: #fff; }

/* ─── App layout ───────────────────────────────────────────── */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}
.sidebar {
    width: 260px;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    flex-shrink: 0;
}
.sidebar-brand {
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
}
.brand-logo {
    width: 40px; height: 40px;
    background: var(--brand-gradient);
    border-radius: 12px;
    display: grid; place-items: center;
    color: #fff; font-weight: 800; font-size: 18px;
}
.sidebar-brand div { display: flex; flex-direction: column; }
.sidebar-brand strong { font-size: 14px; }
.sidebar-brand small { font-size: 11px; color: var(--text-faint); margin-top: 0; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 2px;
    position: relative;
    transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active { background: rgba(124, 92, 255, .15); color: #fff; }
.nav-item.active::before {
    content: ""; position: absolute;
    left: -8px; top: 6px; bottom: 6px;
    width: 3px; background: var(--brand);
    border-radius: 0 3px 3px 0;
}
.nav-item .ico { font-size: 16px; }
.pill {
    margin-left: auto;
    padding: 2px 8px;
    background: var(--danger);
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}
.pill:empty { display: none; }
.sidebar-foot {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 8px;
}
.external-link {
    font-size: 12px;
    color: var(--text-dim);
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--bg-2);
    text-align: center;
}
.external-link:hover { background: var(--bg-3); color: var(--text); }
.logout-btn {
    padding: 8px 10px;
    border-radius: 8px;
    background: transparent;
    color: var(--text-faint);
    font-size: 12px;
    border: 1px solid var(--border);
}
.logout-btn:hover { background: var(--bg-2); color: var(--danger); border-color: var(--danger); }

.main {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}
.view { display: none; }
.view.active { display: block; }
.view h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 18px; }
.view-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.view-head h1 { margin-bottom: 0; }

/* ─── Stats ────────────────────────────────────────────────── */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    display: flex; flex-direction: column; gap: 4px;
}
.stat-card span { color: var(--text-dim); font-size: 13px; }
.stat-card strong { font-size: 26px; font-weight: 800; }
.stat-card em { font-style: normal; font-size: 12px; color: var(--text-faint); }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
}
.card h3 { font-size: 15px; margin-bottom: 14px; }
.mini-list { display: flex; flex-direction: column; gap: 8px; }
.mini-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px;
    background: var(--bg-3);
    border-radius: 8px;
}
.mini-row strong { display: block; font-size: 13px; }
.mini-row small { color: var(--text-faint); }
.mini-empty { color: var(--text-faint); font-size: 13px; padding: 12px; text-align: center; }

/* ─── Tables ───────────────────────────────────────────────── */
.table-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    background: var(--bg-3);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-faint);
    letter-spacing: 1px;
    text-transform: uppercase;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-3); }
.data-table .empty { text-align: center; color: var(--text-faint); padding: 32px; }
.row-expired { opacity: 0.5; }
.hint {
    padding: 12px 16px;
    background: var(--bg-3);
    color: var(--text-dim);
    font-size: 12px;
    border-top: 1px solid var(--border);
}

.group-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(124, 92, 255, .15);
    color: var(--c);
    border: 1px solid var(--c);
    font-size: 12px;
    font-weight: 600;
}
.color-chip {
    display: inline-block;
    width: 14px; height: 14px;
    border-radius: 4px;
    vertical-align: middle;
    margin-right: 4px;
}
.status {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-active { background: rgba(67, 181, 129, .15); color: var(--success); }
.status-inactive { background: rgba(154, 160, 177, .15); color: var(--text-dim); }
.status-suspended { background: rgba(240, 71, 71, .15); color: var(--danger); }

.muted { color: var(--text-faint); }
.row-btn {
    width: 28px; height: 28px;
    border-radius: 6px;
    color: var(--text-faint);
    background: transparent;
    margin: 0 2px;
}
.row-btn:hover { background: var(--bg-4); color: var(--text); }
.row-btn.danger:hover { background: rgba(240, 71, 71, .15); color: var(--danger); }

/* ─── Tabs ─────────────────────────────────────────────────── */
.tab-row { display: flex; gap: 4px; background: var(--bg-2); padding: 4px; border-radius: 10px; }
.tab-btn {
    padding: 8px 16px;
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--bg-4); color: var(--text); }

/* ─── Application cards ────────────────────────────────────── */
.apps-list { display: flex; flex-direction: column; gap: 12px; }
.app-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.app-head {
    padding: 16px 20px;
    display: flex; justify-content: space-between; align-items: flex-start;
    border-bottom: 1px solid var(--border);
}
.app-head h3 { font-size: 16px; margin-bottom: 2px; }
.app-head small { color: var(--text-faint); font-size: 12px; }
.app-body { padding: 16px 20px; }
.app-body p { margin-bottom: 12px; font-size: 14px; color: var(--text-dim); }
.app-body p:last-child { margin-bottom: 0; }
.app-body strong { color: var(--text); }
.app-actions {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-1);
    display: flex; gap: 8px; justify-content: flex-end;
}
.app-actions.decided { color: var(--text-faint); font-size: 13px; justify-content: flex-start; }
.empty-card {
    background: var(--bg-2);
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    color: var(--text-faint);
}

/* Badges */
.badge {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-pending { background: rgba(250, 166, 26, .15); color: var(--warning); }
.badge-accepted { background: rgba(67, 181, 129, .15); color: var(--success); }
.badge-rejected { background: rgba(240, 71, 71, .15); color: var(--danger); }
.badge-running { background: rgba(67, 181, 129, .15); color: var(--success); }
.badge-upcoming { background: rgba(88, 101, 242, .15); color: #7c87ff; }
.badge-completed { background: rgba(154, 160, 177, .15); color: var(--text-dim); }
.badge-cancelled { background: rgba(240, 71, 71, .15); color: var(--danger); }

.toggle-pill {
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(240, 71, 71, .15);
    color: var(--danger);
    font-size: 12px;
    font-weight: 600;
}
.toggle-pill.on { background: rgba(67, 181, 129, .15); color: var(--success); }

/* ─── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .65);
    backdrop-filter: blur(6px);
    display: none; align-items: center; justify-content: center;
    z-index: 100; padding: 24px;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    max-width: 480px;
    width: 100%;
    position: relative;
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8);
}
.modal-close {
    position: absolute; top: 14px; right: 14px;
    width: 32px; height: 32px;
    border-radius: 8px;
    color: var(--text-faint);
    font-size: 22px;
}
.modal-close:hover { background: var(--bg-3); color: var(--text); }
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal-actions {
    display: flex; gap: 8px; justify-content: flex-end;
    margin-top: 20px;
}

.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-size: 13px; font-weight: 600;
    margin-bottom: 6px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ─── Public apply page ────────────────────────────────────── */
.apply-body {
    min-height: 100vh;
    display: flex;
    background: radial-gradient(circle at 50% 0%, rgba(124, 92, 255, .12), transparent 60%),
                var(--bg-0);
}
.apply-shell {
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
    padding: 32px 24px;
    display: flex; flex-direction: column;
}
.apply-head {
    display: flex; align-items: center; gap: 12px;
    padding-bottom: 20px;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border);
}
.apply-head div { display: flex; flex-direction: column; }
.apply-head strong { font-size: 14px; }
.apply-head small { font-size: 12px; color: var(--text-faint); margin-top: 0; }

.apply-main { flex: 1; }
.apply-step { display: none; }
.apply-step.active { display: block; }
.apply-step h1 {
    font-size: 32px; font-weight: 800; letter-spacing: -1px;
    margin-bottom: 8px;
}
.apply-step > p { color: var(--text-dim); margin-bottom: 24px; }

.dept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.dept-card {
    padding: 20px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: left;
    transition: border-color .15s, transform .15s;
    display: flex; flex-direction: column; gap: 6px;
    position: relative;
}
.dept-card:hover {
    border-color: var(--brand);
    transform: translateY(-2px);
}
.dept-name { font-size: 16px; font-weight: 700; color: var(--text); }
.dept-meta { font-size: 12px; color: var(--text-faint); }
.dept-arrow {
    position: absolute; top: 16px; right: 16px;
    color: var(--brand-2);
    font-size: 18px;
}
.dept-loading, .dept-empty {
    grid-column: 1 / -1;
    padding: 40px;
    text-align: center;
    color: var(--text-faint);
    background: var(--bg-2);
    border-radius: 12px;
    border: 1px dashed var(--border);
}

.apply-form { display: flex; flex-direction: column; gap: 16px; }
.back-btn {
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 16px;
}
.back-btn:hover { color: var(--text); }

.success-mark, .error-mark {
    width: 72px; height: 72px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 36px;
    font-weight: 800;
    margin: 32px auto 24px;
}
.success-mark { background: rgba(67, 181, 129, .15); color: var(--success); }
.error-mark { background: rgba(240, 71, 71, .15); color: var(--danger); }
#step-done, #step-error { text-align: center; }
#step-done .btn, #step-error .btn { margin-top: 16px; }

.apply-foot {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    color: var(--text-faint);
    font-size: 12px;
    text-align: center;
}

@media (max-width: 768px) {
    .sidebar { width: 200px; }
    .grid-2 { grid-template-columns: 1fr; }
    .field-row { grid-template-columns: 1fr; }
    .main { padding: 20px; }
}
