/* ── Auth Splash ────────────────────────────────────────────── */
.auth-splash {
    min-height: 100vh;
    background: #080f1e;
    display: flex;
    align-items: center;
    justify-content: center;
}

.splash-logo {
    width: 96px;
    height: 96px;
    animation: splash-pulse 1.6s ease-in-out infinite;
}

@keyframes splash-pulse {
    0%, 100% { opacity: .6; transform: scale(1); }
    50%       { opacity: 1;  transform: scale(1.06); }
}

/* ── Login Page ─────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: #080f1e;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(0,102,204,.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,102,204,.06) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
}

.login-card {
    position: relative;
    z-index: 1;
    background: #0d1a2e;
    border: 1px solid #1e3a5f;
    border-radius: 16px;
    padding: 48px 44px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 0 60px rgba(0,102,204,.12), 0 24px 48px rgba(0,0,0,.5);
    text-align: center;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 18px;
    justify-content: center;
    margin-bottom: 28px;
}

.login-logo {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
}

.login-brand-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.login-company {
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 3px;
    line-height: 1.2;
}

.login-product {
    font-size: 12px;
    color: #64748b;
    letter-spacing: 1px;
    margin-top: 3px;
}

.login-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #1e3a5f 30%, #1e3a5f 70%, transparent);
    margin-bottom: 28px;
}

.login-tagline {
    color: #94a3b8;
    font-size: 14px;
    margin-bottom: 28px;
    line-height: 1.5;
}

.login-btn-ms {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 13px 20px;
    background: #ffffff;
    color: #1e293b;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    justify-content: center;
    transition: background .15s, box-shadow .15s;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.login-btn-ms:hover {
    background: #f1f5f9;
    box-shadow: 0 4px 16px rgba(0,0,0,.35);
}

.ms-logo {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.login-footer {
    margin-top: 24px;
    font-size: 11px;
    color: #334155;
    letter-spacing: .5px;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #0066cc;
    --primary-dark: #0052a3;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --urgent: #b91c1c;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #ffffff;
    --sidebar-active-bg: #0066cc;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Layout ────────────────────────────────────────────────── */
.page { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-row {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
}

.app-title { font-weight: 600; color: var(--text-muted); font-size: 13px; }

.content { padding: 24px; max-width: 1400px; }

/* ── Nav ────────────────────────────────────────────────────── */
.nav-menu {
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
}

.nav-user-panel {
    padding: 10px 20px 8px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-username {
    font-size: 11px;
    color: rgba(255,255,255,.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-logout-link {
    font-size: 12px;
    color: rgba(255,255,255,.45);
    text-decoration: none;
    transition: color .15s;
}
.nav-logout-link:hover { color: #ef4444; }

.nav-logo {
    margin-top: auto;
    padding: 20px 20px 28px;
    opacity: 0.65;
    transition: opacity .2s;
}

.nav-logo:hover { opacity: 1; }

.nav-logo img {
    width: 100%;
    max-width: 120px;
    display: block;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px 20px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.1);
    margin-bottom: 8px;
}

.nav-brand-icon { font-size: 22px; }

.nav-links { list-style: none; }

.nav-links li { margin: 2px 8px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 14px;
    transition: background .15s, color .15s;
}

.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 600; }

/* ── DB Status Panel ─────────────────────────────────────────── */
.db-status-panel {
    margin: 16px 12px 0;
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,.1);
}

.db-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.db-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-green  { background: #22c55e; box-shadow: 0 0 6px #22c55e88; }
.dot-red    { background: #ef4444; }
.dot-yellow { background: #f59e0b; animation: pulse-yellow 1.2s infinite; }

@keyframes pulse-yellow {
    0%, 100% { opacity: 1; }
    50%       { opacity: .4; }
}

.db-state-label { font-size: 12px; color: var(--sidebar-text); }

.db-start-btn {
    width: 100%;
    padding: 7px 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}

.db-start-btn:hover:not(:disabled) { background: var(--primary-dark); }
.db-start-btn:disabled { opacity: .5; cursor: not-allowed; }

.db-stop-btn {
    width: 100%;
    padding: 7px 12px;
    background: transparent;
    color: #94a3b8;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.db-stop-btn:hover:not(:disabled) { background: rgba(239,68,68,.15); color: #fca5a5; border-color: rgba(239,68,68,.4); }
.db-stop-btn:disabled { opacity: .5; cursor: not-allowed; }

.db-spinner {
    display: block;
    font-size: 11px;
    color: var(--sidebar-text);
    text-align: center;
    letter-spacing: 3px;
    animation: pulse-yellow 1s infinite;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

/* ── Page header ────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 24px; font-weight: 700; color: var(--text); }
.subtitle { color: var(--text-muted); margin-top: 4px; }

/* ── Upload zone ────────────────────────────────────────────── */
.upload-card { max-width: 600px; }

.upload-zone {
    display: block;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    transition: border-color .2s, background .2s;
    cursor: pointer;
}

.upload-zone.dragging {
    border-color: var(--primary);
    background: #eff6ff;
}

.upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-text { font-size: 16px; font-weight: 500; color: var(--text); }
.upload-subtext { color: var(--text-muted); margin: 8px 0; }

.selected-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    padding: 6px 14px;
    margin-top: 16px;
    font-size: 13px;
    color: var(--primary);
}

.btn-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}

.upload-actions { margin-top: 20px; text-align: right; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    text-decoration: none;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }

.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #e2e8f0; }

.btn-link { background: none; color: var(--primary); padding: 6px 10px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ── Upload result ──────────────────────────────────────────── */
.result-card { max-width: 600px; }
.result-success { border-left: 4px solid var(--success); }
.result-warning { border-left: 4px solid var(--warning); }

.result-stats {
    display: flex;
    gap: 32px;
    margin: 16px 0;
}

.stat { text-align: center; }
.stat-value { display: block; font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

.error-details { margin-top: 16px; }
.error-details summary { cursor: pointer; color: var(--warning); font-weight: 500; }
.error-list { margin-top: 8px; padding-left: 20px; color: var(--text-muted); font-size: 12px; }
.error-list li { margin-bottom: 4px; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }

/* ── Report meta ────────────────────────────────────────────── */
.report-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.report-time { color: var(--text-muted); font-size: 13px; }
.filter-note { color: var(--text-muted); font-size: 13px; font-style: italic; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: var(--success); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-urgent  { background: #fee2e2; color: var(--urgent); }
.badge-ok      { background: #f0fdf4; color: var(--success); }

.days-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.expiry-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 10px;
    background: #fef3c7;
    color: var(--warning);
    font-size: 11px;
    font-weight: 600;
}

/* ── Table ──────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 13px;
}

.data-table th {
    background: #f8fafc;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f8fafc; }

.data-table a { color: var(--primary); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

.row-warning td { background: #fffbeb !important; }
.row-urgent td  { background: #fff1f2 !important; }

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    padding: 16px 20px;
}

.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

/* ── Multi-select dropdown ──────────────────────────────────── */
.multiselect-wrapper { position: relative; }

.multiselect-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-width: 220px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
}

.multiselect-trigger:hover { border-color: var(--primary); }
.placeholder { color: var(--text-muted); }
.caret { color: var(--text-muted); font-size: 12px; }

.multiselect-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 260px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.dropdown-search { padding: 8px; border-bottom: 1px solid var(--border); }
.search-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
.search-input:focus { border-color: var(--primary); }

.dropdown-options { max-height: 220px; overflow-y: auto; padding: 4px 0; }

.dropdown-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
}
.dropdown-option:hover { background: #f1f5f9; }
.dropdown-option input[type="checkbox"] { cursor: pointer; }

.no-options { display: block; padding: 10px 12px; color: var(--text-muted); font-size: 13px; }

.dropdown-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
}

/* ── Active filter chips ────────────────────────────────────── */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-self: flex-end;
    padding-bottom: 2px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: var(--primary);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
}

.filter-chip button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary);
    font-size: 11px;
    line-height: 1;
    padding: 0;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}
.empty-icon { font-size: 48px; display: block; margin-bottom: 12px; }

/* ── Loading ────────────────────────────────────────────────── */
.loading {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 16px;
}

/* ── Spinner ────────────────────────────────────────────────── */
.spinner { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Table row states ───────────────────────────────────────── */
.row-expired td { background: #f8f8f8 !important; color: #94a3b8 !important; }
.row-expired td a { color: #94a3b8 !important; }

/* ── Button group (filter toggles) ─────────────────────────── */
.btn-group {
    display: inline-flex;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
.btn-group .btn { border-radius: 0; border: none; border-right: 1px solid var(--border); }
.btn-group .btn:last-child { border-right: none; }

/* ── Danger button ──────────────────────────────────────────── */
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

/* ── Alert success ──────────────────────────────────────────── */
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--success); }
.mt-2 { margin-top: 12px; }

/* ── Filter actions ─────────────────────────────────────────── */
.filter-actions { display: flex; gap: 8px; align-items: flex-end; margin-top: auto; }

/* ── Danger zone card ───────────────────────────────────────── */
.danger-card { border-left: 4px solid var(--danger); max-width: 600px; }
.danger-card h3 { font-size: 15px; font-weight: 700; color: var(--danger); margin-bottom: 8px; }
.danger-desc { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }

.purge-confirm {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text);
}

/* ── Role completion wizard ─────────────────────────────────── */
.role-wizard { max-width: 700px; }

.wizard-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
}

.wizard-header h2 { font-size: 18px; font-weight: 700; }
.wizard-progress { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.wizard-context {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
}

.context-row { display: flex; gap: 8px; align-items: baseline; }
.context-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    min-width: 70px;
}
.context-value { font-size: 13px; color: var(--text); }

/* ── Form grid ──────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 24px;
    margin-bottom: 20px;
}

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field-full { grid-column: 1 / -1; }

.form-field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.required { color: var(--danger); }

.form-control {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color .15s;
    width: 100%;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,102,204,.1); }
textarea.form-control { resize: vertical; }

/* ── Cost center inline add ─────────────────────────────────── */
.cc-select-row { display: flex; gap: 8px; align-items: center; }
.cc-select-row .form-control { flex: 1; }

.cc-new-fields { display: flex; flex-direction: column; gap: 6px; }

/* ── Wizard actions ─────────────────────────────────────────── */
.wizard-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ── Apply template bar ─────────────────────────────────────── */
.template-apply-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 20px;
}
.template-apply-bar .filter-label { white-space: nowrap; }
.form-control-sm { padding: 6px 10px; font-size: 13px; }

/* ── Save-as-template panel ─────────────────────────────────── */
.save-template-panel {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    margin-bottom: 12px;
}
.save-template-panel .form-control { flex: 1; min-width: 200px; }

.save-template-link {
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-muted);
}
.save-template-link:hover { color: var(--primary); }

.text-success { color: var(--success); font-size: 13px; }
.text-danger  { color: var(--danger);  font-size: 13px; }

/* ── Completion mode selector ───────────────────────────────── */
.mode-card { max-width: 700px; }
.mode-card h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.mode-desc { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

.mode-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    padding: 20px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.mode-btn:hover:not(:disabled) {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,102,204,.08);
}
.mode-btn:disabled { opacity: .5; cursor: not-allowed; }

.mode-icon { font-size: 32px; }
.mode-title { font-weight: 600; font-size: 14px; color: var(--text); }
.mode-sub { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.mode-spinner { font-size: 16px; }

/* ── Manage page ────────────────────────────────────────────── */
.manage-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.manage-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}
.manage-tab:hover { color: var(--text); }
.manage-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.manage-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 720px) {
    .manage-layout { grid-template-columns: 1fr; }
}

.manage-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.manage-list-header h3 { font-size: 15px; font-weight: 700; }

.item-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }

.item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .12s;
    border: 1px solid transparent;
}
.item-row:hover { background: #f1f5f9; }
.item-row-active { background: #eff6ff !important; border-color: #bfdbfe; }

.item-name { flex: 1; font-size: 14px; color: var(--text); }
.item-code { font-size: 13px; font-weight: 600; color: var(--primary); min-width: 80px; }
.item-meta { font-size: 12px; color: var(--text-muted); }
.item-tpl-main { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.item-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 4px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity .15s, color .15s;
}
.item-row:hover .item-delete { opacity: 1; }
.item-delete:hover { color: var(--danger); }

.manage-form h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ── Confirmation overlay ───────────────────────────────────── */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.confirm-dialog {
    background: var(--surface);
    border-radius: 12px;
    padding: 28px 32px;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.confirm-dialog p { margin-bottom: 8px; font-size: 15px; }
.confirm-warn { font-size: 12px; color: var(--warning); }

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ══════════════════════════════════════════════════════════════
   Manage → Onboarding Plans Tab
══════════════════════════════════════════════════════════════ */

.onboarding-manage-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 24px;
    margin-top: 16px;
}

.onboarding-left  { display: flex; flex-direction: column; gap: 24px; }
.onboarding-right { min-height: 300px; }

.ob-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.ob-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.ob-section-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.item-selected {
    background: var(--primary-light, #e8f4fd) !important;
    border-color: var(--primary) !important;
}

.item-badge {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    margin-right: 8px;
}

.proc-link {
    font-size: 11px;
    color: var(--primary);
    text-decoration: none;
    display: block;
    margin-top: 2px;
}
.proc-link:hover { text-decoration: underline; }

.task-lib-list .item-row .item-info small {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.excel-action-bar {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.form-success { color: #2a9d55; font-size: 13px; margin-top: 8px; }
.form-error   { color: var(--danger, #d9534f); font-size: 13px; margin-top: 6px; }

.inline-form {
    background: var(--bg, #f5f7fa);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-top: 14px;
}
.inline-form h4 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.inline-form .form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}
.inline-form .form-row label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.inline-form .form-row input,
.inline-form .form-row select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: white;
}
.inline-form .form-actions { display: flex; gap: 8px; margin-top: 12px; }

.chain-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 14px;
    border: 2px dashed var(--border);
    border-radius: 12px;
}

.chain-list { display: flex; flex-direction: column; gap: 8px; }

.chain-step-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.chain-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chain-step-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.chain-step-body strong { font-size: 13px; }
.chain-task-tag {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--border);
    padding: 1px 6px;
    border-radius: 10px;
    width: fit-content;
}
.chain-task-desc { font-size: 11px; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   Onboarding Plans list page  (/onboarding)
══════════════════════════════════════════════════════════════ */

.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.ob-plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.ob-plan-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: box-shadow .15s, border-color .15s;
}
.ob-plan-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
    border-color: var(--primary);
}

.ob-plan-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
}
.ob-plan-title { font-size: 15px; font-weight: 600; }

.ob-plan-delete {
    opacity: .5;
    transition: opacity .1s;
}
.ob-plan-delete:hover { opacity: 1; }

.ob-plan-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.ob-plan-progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.ob-progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.ob-progress-bar-lg { height: 12px; border-radius: 6px; max-width: 400px; }

.ob-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width .3s ease;
}

.ob-progress-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.ob-plan-date { font-size: 11px; color: var(--text-muted); }

.ob-create-dialog { max-width: 480px !important; }

/* ══════════════════════════════════════════════════════════════
   Onboarding Detail page  (/onboarding/{id})
══════════════════════════════════════════════════════════════ */

.back-link {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    display: inline-block;
    margin-bottom: 6px;
}
.back-link:hover { text-decoration: underline; }

.ob-detail-progress {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.ob-step-list { display: flex; flex-direction: column; gap: 16px; }

.ob-step-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    transition: border-color .2s;
}
.ob-step-done {
    border-color: #2a9d55;
    background: #f0faf4;
}

.ob-step-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.ob-step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ob-step-done .ob-step-num { background: #2a9d55; }

.ob-step-title-block { flex: 1; }
.ob-step-name { font-size: 15px; font-weight: 600; }
.ob-step-task {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.ob-step-complete-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    white-space: nowrap;
}
.ob-step-complete-toggle input { width: 16px; height: 16px; cursor: pointer; }

.ob-step-desc {
    font-size: 13px;
    color: var(--text-secondary, #555);
    margin-bottom: 8px;
}

.ob-proc-link {
    display: inline-block;
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
    margin-bottom: 14px;
}
.ob-proc-link:hover { text-decoration: underline; }

.ob-step-fields {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px 16px;
    align-items: start;
}

.ob-step-field { display: flex; flex-direction: column; gap: 4px; }
.ob-step-field-wide { }
.ob-step-field label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.form-control-sm {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: white;
    width: 100%;
}
.ob-notes { resize: vertical; min-height: 54px; }

.ob-step-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* ── Variable chips (task chain) ─────────────────────────────── */
.chain-step-vars {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}

.var-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 2px 9px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.var-chip-removable {
    padding-right: 4px;
}

.var-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    font-size: 10px;
    padding: 0 2px;
    line-height: 1;
}
.var-remove:hover { color: #ef4444; }

/* Variable editor in chain step form */
.form-row-vars { align-items: flex-start; }

.var-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.var-chips-edit {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 6px 0;
    min-height: 28px;
}

.var-add-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.var-input {
    flex: 1;
    padding: 5px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}
.var-input:focus { outline: none; border-color: var(--primary); }

/* ── Variable chips on onboarding step cards ─────────────────── */
.ob-step-vars {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin: 8px 0 4px;
}

.ob-step-vars-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 2px;
}

/* ══════════════════════════════════════════════════════════════
   Mobile responsive
══════════════════════════════════════════════════════════════ */

/* Hamburger — hidden on desktop */
.hamburger-btn { display: none; }
.nav-overlay   { display: none; }

@media (max-width: 768px) {

    /* ── Hamburger button ── */
    .hamburger-btn {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 22px;
        height: 16px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
        margin-right: 14px;
        flex-shrink: 0;
    }
    .hamburger-btn span {
        display: block;
        height: 2px;
        background: var(--text-muted);
        border-radius: 2px;
        transition: background .15s;
    }
    .hamburger-btn:hover span { background: var(--text); }

    /* ── Sidebar — off-canvas drawer ── */
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        height: 100vh;
        width: 240px;
        z-index: 300;
        transition: left .25s ease;
        overflow-y: auto;
    }
    .sidebar.nav-open {
        left: 0;
        box-shadow: 6px 0 32px rgba(0,0,0,.5);
    }

    /* ── Overlay behind open nav ── */
    .nav-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 299;
    }

    /* ── Main takes full width ── */
    main { width: 100%; min-width: 0; }

    /* ── Top row ── */
    .top-row { padding: 10px 14px; }

    /* ── Content ── */
    .content { padding: 14px; }

    /* ── Page header ── */
    .page-header h1 { font-size: 20px; }

    /* ── Login card ── */
    .login-card { padding: 32px 20px; margin: 16px; }

    /* ── Form grids → single column ── */
    .form-grid        { grid-template-columns: 1fr; }
    .wizard-context   { grid-template-columns: 1fr; }

    /* ── Filter bar → stacked ── */
    .filter-bar { flex-direction: column; gap: 10px; }

    /* ── Multiselect → full width ── */
    .multiselect-trigger { min-width: 0; width: 100%; }
    .multiselect-dropdown { min-width: 0; width: 100%; }

    /* ── Onboarding manage → stacked ── */
    .onboarding-manage-layout { grid-template-columns: 1fr; }

    /* ── Onboarding step fields → stacked ── */
    .ob-step-fields { grid-template-columns: 1fr; }

    /* ── Onboarding plan grid → single column ── */
    .ob-plan-grid { grid-template-columns: 1fr; }

    /* ── Onboarding step header → wrap on small ── */
    .ob-step-header { flex-wrap: wrap; }
    .ob-step-complete-toggle { margin-left: auto; }

    /* ── Detail progress bar → stacked ── */
    .ob-detail-progress { flex-direction: column; align-items: flex-start; gap: 10px; }

    /* ── Stats → wrap ── */
    .result-stats { flex-wrap: wrap; gap: 16px; justify-content: center; }

    /* ── Manage tabs → scroll ── */
    .manage-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-shrink: 0; }
    .manage-tab  { white-space: nowrap; }

    /* ── Toolbar → wrap ── */
    .toolbar { flex-wrap: wrap; }

    /* ── Wizard & form actions → full-width stacked ── */
    .wizard-actions,
    .form-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }
    .wizard-actions .btn,
    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* ── Purge confirm → stacked ── */
    .purge-confirm { flex-direction: column; align-items: flex-start; }

    /* ── Confirm dialog ── */
    .confirm-dialog { padding: 24px 20px; }

    /* ── Report meta → wrap ── */
    .report-meta { flex-wrap: wrap; gap: 8px; }

    /* ── Mode options → single column ── */
    .mode-options { grid-template-columns: 1fr; }

    /* ── Template apply bar → stacked ── */
    .template-apply-bar { flex-direction: column; align-items: flex-start; }
}
