:root {
    --bg: #07111f;
    --bg-soft: #0a1627;
    --surface: #0e1b2e;
    --surface-2: #13233a;
    --surface-3: #172a44;
    --border: #1b3150;
    --border-strong: #294564;
    --text: #e8f2ff;
    --muted: #8ba2bf;
    --subtle: #58708f;
    --accent: #20c7f4;
    --accent-strong: #08a4d4;
    --accent-soft: rgba(32, 199, 244, .11);
    --teal: #25d0a3;
    --red: #ff6262;
    --yellow: #f7c94a;
    --purple: #a78bfa;
    --sidebar-width: 236px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
}
button, input, select { font: inherit; }
a { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0 13px 14px;
    overflow: visible;
    color: var(--muted);
    background: linear-gradient(180deg, #0a1627 0%, #081321 100%);
    border-right: 1px solid var(--border);
    transition: width .2s ease, transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 0 10px; border-bottom: 1px solid rgba(41, 69, 100, .55); }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 39px;
    height: 39px;
    flex: 0 0 auto;
    border: 1px solid rgba(32, 199, 244, .35);
    border-radius: 10px;
    color: var(--accent);
    background: linear-gradient(145deg, rgba(32, 199, 244, .17), rgba(37, 208, 163, .06));
    box-shadow: 0 0 24px rgba(32, 199, 244, .08);
}
.brand-mark i { font-size: 1rem; }
.brand-copy, .auth-brand > span:last-child { display: flex; flex-direction: column; }
.brand-copy strong, .auth-brand strong { color: var(--accent); font-family: Rajdhani, sans-serif; font-size: 1.18rem; font-weight: 700; letter-spacing: .14em; }
.brand-copy small, .auth-brand small { color: var(--subtle); font-size: .65rem; letter-spacing: .06em; text-transform: uppercase; }

.nav-menu { display: flex; flex: 1; flex-direction: column; gap: 4px; padding: 17px 0; overflow: visible; }
.nav-menu a {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--muted);
    text-decoration: none;
    transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.nav-menu a:hover { color: var(--text); background: rgba(32, 199, 244, .045); }
.nav-menu a.active { color: var(--accent); background: var(--accent-soft); border-color: rgba(32, 199, 244, .13); }
.nav-menu a i { width: 19px; color: var(--subtle); font-size: .91rem; text-align: center; transition: color .15s ease; }
.nav-menu a:hover i, .nav-menu a.active i { color: var(--accent); }
.nav-menu a strong { font-size: .78rem; font-weight: 600; }
.nav-label { padding: 0 12px 5px; color: #4d6686; font-size: .58rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.nav-label-spaced { margin-top: 14px; }

.user-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border: 1px solid rgba(37, 208, 163, .25);
    border-radius: 50%;
    color: var(--teal);
    background: rgba(37, 208, 163, .09);
    font-size: .68rem;
    font-weight: 700;
}
.user-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.user-copy strong { overflow: hidden; color: var(--text); font-size: .73rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.user-copy small { overflow: hidden; color: var(--subtle); font-size: .64rem; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-toggle {
    position: absolute;
    top: 88px;
    right: -14px;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    color: var(--accent);
    background: var(--surface);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}
.sidebar-toggle i { font-size: .65rem; transition: transform .2s ease; }

.main-column { min-width: 0; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 68px;
    padding: 0 30px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 22, 39, .94);
    backdrop-filter: blur(14px);
}
.topbar-context { display: flex; align-items: center; gap: 10px; }
.topbar-context > span:last-child { display: flex; flex-direction: column; }
.topbar-context strong { color: var(--text); font-family: Rajdhani, sans-serif; font-size: .9rem; letter-spacing: .06em; text-transform: uppercase; }
.topbar-context small { color: var(--subtle); font-size: .65rem; }
.context-icon { color: var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.environment-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px;
    border: 1px solid rgba(37, 208, 163, .19);
    border-radius: 999px;
    color: var(--teal);
    background: rgba(37, 208, 163, .07);
    font-size: .63rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.topbar-dropdown { position: relative; z-index: 36; }
.user-trigger {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    color: var(--accent);
    background: linear-gradient(145deg, var(--surface-2), var(--surface));
    box-shadow: 0 5px 18px rgba(0, 0, 0, .2);
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.user-trigger:hover, .user-trigger[aria-expanded="true"] { border-color: rgba(32, 199, 244, .55); color: #7fe6ff; background: var(--accent-soft); }
.user-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 270px;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: linear-gradient(150deg, #12223a, #0b1829);
    box-shadow: 0 20px 55px rgba(0, 0, 0, .45);
}
.user-menu-header { display: flex; align-items: center; gap: 11px; padding: 15px; border-bottom: 1px solid var(--border); }
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 58px;
    padding: 10px 15px;
    border: 0;
    border-bottom: 1px solid rgba(27, 49, 80, .58);
    color: var(--muted);
    background: transparent;
    text-align: left;
    text-decoration: none;
    transition: color .15s ease, background .15s ease;
}
.user-menu form:last-child .user-menu-item { border-bottom: 0; }
.user-menu-item > i { width: 20px; color: var(--accent); text-align: center; }
.user-menu-item > span { display: flex; flex-direction: column; }
.user-menu-item strong { color: var(--text); font-size: .72rem; font-weight: 600; }
.user-menu-item small { color: var(--subtle); font-size: .62rem; }
.user-menu-item:hover { color: var(--text); background: var(--accent-soft); }
.user-menu-item.danger > i { color: var(--red); }
.user-menu-item.danger:hover { background: rgba(255, 98, 98, .07); }
.dropdown-backdrop { position: fixed; inset: 0; z-index: 25; border: 0; background: transparent; }
.icon-button { border: 0; color: var(--accent); background: transparent; font-size: 1.1rem; }
.content { width: min(100%, 1520px); margin: 0 auto; padding: 30px 32px 42px; }

.page-header { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-header h1 { margin: 4px 0 3px; color: var(--text); font-family: Rajdhani, sans-serif; font-size: clamp(1.75rem, 3vw, 2.15rem); font-weight: 700; letter-spacing: .025em; }
.page-header p, .panel p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--accent); font-size: .62rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow i { margin-right: 5px; }
.competence-chip { display: grid; grid-template-columns: auto auto; align-items: center; gap: 1px 8px; min-width: 165px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.competence-chip i { grid-row: 1 / 3; color: var(--accent); }
.competence-chip span { color: var(--subtle); font-size: .58rem; letter-spacing: .08em; text-transform: uppercase; }
.competence-chip strong { color: var(--text); font-size: .77rem; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 17px; }
.metric-card, .panel { border: 1px solid var(--border); border-radius: 10px; background: linear-gradient(150deg, var(--surface) 0%, #0c192a 100%); box-shadow: 0 8px 26px rgba(0, 0, 0, .12); }
.metric-card { position: relative; display: flex; align-items: center; gap: 14px; min-height: 118px; padding: 17px; overflow: hidden; }
.metric-card::after { position: absolute; right: -28px; bottom: -38px; width: 100px; height: 100px; border: 1px solid currentColor; border-radius: 50%; content: ""; opacity: .05; }
.metric-card > div { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.metric-card > div > span { color: var(--muted); font-size: .68rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.metric-card strong { margin: 2px 0; color: var(--text); font-family: Rajdhani, sans-serif; font-size: 1.85rem; line-height: 1; }
.metric-card small { color: var(--subtle); font-size: .64rem; }
.metric-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border: 1px solid currentColor; border-radius: 9px; background: rgba(255,255,255,.025); }
.metric-card.danger { color: var(--red); } .metric-card.warning { color: var(--yellow); }
.metric-card.info { color: var(--accent); } .metric-card.success { color: var(--teal); }

.panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.panel { padding: 21px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-heading h2 { margin: 3px 0 0; color: var(--text); font-family: Rajdhani, sans-serif; font-size: 1.05rem; font-weight: 700; letter-spacing: .025em; }
.panel-icon { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 8px; color: var(--accent); background: var(--accent-soft); }
.empty-compact { display: flex; align-items: center; gap: 13px; min-height: 92px; padding: 15px; border: 1px dashed var(--border-strong); border-radius: 8px; background: rgba(7, 17, 31, .35); }
.empty-compact > span { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--subtle); background: var(--surface-2); }
.empty-compact > div, .foundation-status span { display: flex; flex-direction: column; }
.empty-compact strong, .foundation-status strong { color: var(--text); font-size: .75rem; }
.empty-compact small, .foundation-status small { color: var(--subtle); font-size: .66rem; }
.foundation-status { display: flex; align-items: center; gap: 10px; margin-top: 18px; padding: 11px 12px; border: 1px solid rgba(37, 208, 163, .14); border-radius: 8px; color: var(--teal); background: rgba(37, 208, 163, .05); }

.form-panel { margin-bottom: 17px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 13px; margin-bottom: 17px; }
.form-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: .69rem; font-weight: 600; }
.field-label { color: var(--muted); font-size: .67rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.field-optional { display: inline; margin-left: 5px; color: var(--subtle); font-size: .58rem; font-weight: 400; }
.form-control, .form-select {
    min-height: 41px;
    border-color: var(--border-strong);
    border-radius: 7px;
    color: var(--text);
    background-color: #0a1728;
    font-size: .76rem;
}
.form-control::placeholder { color: var(--subtle); }
.form-control:focus, .form-select:focus { border-color: var(--accent); color: var(--text); background-color: #0a1728; box-shadow: 0 0 0 .18rem rgba(32, 199, 244, .1); }
.form-select option { color: var(--text); background: var(--surface); }
.readonly-field { color: var(--subtle); background: rgba(7, 17, 31, .62); cursor: not-allowed; }
.readonly-field:focus { border-color: var(--border-strong); color: var(--subtle); background: rgba(7, 17, 31, .62); box-shadow: none; }
.field-help { color: var(--subtle); font-size: .62rem; font-weight: 400; line-height: 1.45; }
.field-help i { margin-right: 4px; color: var(--teal); }
.validation-message, .validation-errors { color: var(--red); font-size: .68rem; }
.btn { border-radius: 7px; font-size: .7rem; font-weight: 700; letter-spacing: .035em; }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-color: #03111b; --bs-btn-hover-bg: #52d8fb; --bs-btn-hover-border-color: #52d8fb; --bs-btn-hover-color: #03111b; }
.btn-outline-secondary { --bs-btn-color: var(--muted); --bs-btn-border-color: var(--border-strong); --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-border-color: var(--accent); --bs-btn-hover-color: var(--accent); }
.alert { display: flex; align-items: center; gap: 9px; border-radius: 8px; font-size: .72rem; }
.alert-danger { border-color: rgba(255, 98, 98, .28); color: #ff9797; background: rgba(255, 98, 98, .08); }
.alert-success { border-color: rgba(37, 208, 163, .25); color: var(--teal); background: rgba(37, 208, 163, .07); }

.table-responsive { border: 1px solid var(--border); border-radius: 8px; }
.app-table { margin: 0; color: var(--text); --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-hover-bg: rgba(32, 199, 244, .035); }
.app-table th { padding: 10px 12px; border-bottom-color: var(--border); color: var(--subtle); background: var(--surface-2); font-size: .6rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; white-space: nowrap; }
.app-table td { padding: 11px 12px; border-bottom-color: rgba(27, 49, 80, .65); color: var(--muted); font-size: .72rem; }
.app-table td:first-child > strong,
.app-table td:first-child > small { display: block; }
.app-table td:first-child > strong + small { margin-top: 2px; }
.app-table td strong { color: var(--text); font-weight: 600; }
.app-table td small { color: var(--subtle); font-size: .63rem; }
.username-chip { display: inline-flex; padding: 4px 8px; border: 1px solid rgba(32, 199, 244, .16); border-radius: 5px; color: var(--accent); background: var(--accent-soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .66rem; }
.status-pill { display: inline-flex; padding: 4px 8px; border: 1px solid currentColor; border-radius: 999px; font-size: .62rem; font-weight: 700; }
.status-pill.active { color: var(--teal); background: rgba(37, 208, 163, .07); } .status-pill.inactive { color: var(--subtle); background: rgba(88, 112, 143, .07); }

.permission-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; margin: 20px 0; }
.permission-group { padding: 15px; border: 1px solid var(--border); border-radius: 8px; background: rgba(7, 17, 31, .28); }
.permission-group h3 { margin: 0 0 9px; color: var(--accent); font-family: Rajdhani, sans-serif; font-size: .82rem; letter-spacing: .06em; text-transform: uppercase; }
.permission-row { display: flex; align-items: center; justify-content: space-between; gap: 13px; padding: 9px 0; border-top: 1px solid rgba(27, 49, 80, .62); }
.permission-check { flex: 1; flex-direction: row; align-items: center; }
.permission-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.permission-check span { display: flex; flex-direction: column; }
.permission-check strong { color: var(--text); font-size: .7rem; }
.permission-check small { color: var(--subtle); font-size: .58rem; font-weight: 400; }
.scope-select { width: 205px; min-height: 35px; font-size: .67rem; }
.cards-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.classification-card small { color: var(--subtle); }
.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; align-items: start; }
.account-form { display: grid; gap: 15px; }
.account-submit { justify-self: start; margin-top: 3px; }
.empty-state { display: grid; place-items: center; min-height: 280px; text-align: center; }
.empty-state h1, .empty-state h2 { margin-bottom: 4px; color: var(--text); font-family: Rajdhani, sans-serif; }
.empty-icon { color: var(--accent); font-size: 2rem; }

.auth-page { position: relative; display: grid; min-height: 100vh; place-items: center; padding: 24px; overflow: hidden; background: #07111f; }
.auth-page::before, .auth-page::after { position: absolute; width: 480px; height: 480px; border-radius: 50%; content: ""; filter: blur(2px); pointer-events: none; }
.auth-page::before { top: -260px; left: -180px; background: radial-gradient(circle, rgba(32, 199, 244, .14), transparent 66%); }
.auth-page::after { right: -230px; bottom: -290px; background: radial-gradient(circle, rgba(37, 208, 163, .09), transparent 68%); }
.auth-card { position: relative; z-index: 1; width: min(100%, 420px); padding: 36px; border: 1px solid var(--border-strong); border-radius: 14px; background: linear-gradient(145deg, rgba(17, 34, 56, .97), rgba(10, 23, 40, .98)); box-shadow: 0 26px 80px rgba(0, 0, 0, .45); }
.auth-card::before { position: absolute; top: 0; left: 32px; width: 72px; height: 2px; background: linear-gradient(90deg, var(--accent), var(--teal)); content: ""; }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 31px; }
.auth-heading { margin-bottom: 21px; }
.auth-heading h1 { margin: 5px 0 3px; color: var(--text); font-family: Rajdhani, sans-serif; font-size: 1.75rem; font-weight: 700; }
.auth-heading p { margin: 0; color: var(--muted); font-size: .74rem; }
.auth-card form { display: grid; gap: 15px; }
.input-with-icon { position: relative; display: block; }
.input-with-icon > i { position: absolute; top: 50%; left: 13px; z-index: 1; color: var(--subtle); transform: translateY(-50%); }
.input-with-icon .form-control { padding-left: 38px; }
.auth-submit { display: flex; align-items: center; justify-content: space-between; min-height: 43px; margin-top: 4px; padding-inline: 16px; text-transform: uppercase; }
.auth-footer { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 21px; color: var(--subtle); font-size: .62rem; }
.auth-footer i { color: var(--teal); }

.sidebar-collapsed { grid-template-columns: 78px minmax(0, 1fr); }
.sidebar-collapsed .brand-copy, .sidebar-collapsed .nav-menu strong, .sidebar-collapsed .nav-label { display: none; }
.sidebar-collapsed .brand, .sidebar-collapsed .nav-menu a { justify-content: center; }
.sidebar-collapsed .sidebar-toggle i { transform: rotate(180deg); }

@media (min-width: 992px) {
    .app-shell {
        min-height: 111.112vh;
        zoom: .9;
    }

    .sidebar { height: 111.112vh; }
}

@media (max-width: 1100px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cards-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 991.98px) {
    .app-shell, .sidebar-collapsed { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; width: var(--sidebar-width); transform: translateX(-105%); box-shadow: 22px 0 60px rgba(0, 0, 0, .35); }
    .sidebar.mobile-open { transform: translateX(0); }
    .menu-backdrop { position: fixed; inset: 0; z-index: 25; border: 0; background: rgba(2, 8, 15, .72); backdrop-filter: blur(2px); }
    .topbar { padding: 0 20px; }
    .content { padding: 25px 20px 36px; }
}

@media (max-width: 720px) {
    .metric-grid, .panel-grid, .form-grid.two-columns, .permission-list, .cards-list, .account-grid { grid-template-columns: 1fr; }
    .page-header { align-items: start; flex-direction: column; }
    .competence-chip { width: 100%; }
    .environment-badge span { display: none; }
    .content { padding: 22px 14px 32px; }
    .panel { padding: 17px; }
    .permission-row { align-items: start; flex-direction: column; }
    .scope-select { width: 100%; }
    .auth-card { padding: 30px 24px; }
}
