:root {
    --bg: #0b1420;
    --sidebar: #0d1725;
    --panel: #172638;
    --panel-hover: #1b2d42;
    --panel-dark: #111f2f;
    --border: #29415a;
    --border-light: #34516e;
    --text: #f2f6fb;
    --muted: #9db4ca;
    --muted-2: #7891aa;
    --blue: #3d78bf;
    --blue-hover: #4a87d3;
    --green: #36c98f;
    --yellow: #ffd54f;
    --red: #ef476f;
    --sidebar-width: 226px;
    --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
}

a { color: #9ecbff; }
a:hover { color: #c4deff; }

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
}

.main {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
}

.content {
    max-width: 1450px;
    margin: 0 auto;
    padding: 16px 24px 40px;
}

.brand {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    background: #fff;
    border-radius: 9px;
    padding: 4px;
}

.brand-text { min-width: 0; }

.brand-title {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
}

.brand-subtitle {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.25;
}

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

.nav-section {
    color: var(--muted-2);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin: 14px 8px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--panel);
    color: #e2edf8;
    text-decoration: none;
    font-weight: 600;
    transition: background .12s ease, border-color .12s ease;
}

.nav-item:hover {
    background: var(--panel-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--blue);
    border-color: #5890d2;
    color: #fff;
}

.nav-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 22px;
    background: rgba(255,255,255,.08);
    color: inherit;
}

.nav-icon svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-spacer { flex: 1; }

.page-header {
    margin-bottom: 18px;
}

.page-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
}

.page-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 16px;
}

.panel-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
}

.stat-label {
    color: var(--muted);
    margin-top: 4px;
}

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

.tool-card {
    display: flex;
    min-height: 180px;
    flex-direction: column;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    transition: background .12s ease, border-color .12s ease, transform .12s ease;
}

.tool-card:hover {
    color: #fff;
    background: var(--panel-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.tool-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #20354c;
    border: 1px solid var(--border);
    font-size: 22px;
    margin-bottom: 14px;
}

.tool-name {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 7px;
}

.tool-description {
    color: var(--muted);
    line-height: 1.45;
}

.tool-launch {
    margin-top: auto;
    padding-top: 18px;
    color: #8ec3ff;
    font-weight: 700;
}

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

.admin-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    color: var(--text);
    text-decoration: none;
    min-height: 140px;
}

.admin-card:hover {
    background: var(--panel-hover);
    border-color: var(--border-light);
    color: #fff;
}

.admin-card h2 {
    margin: 0 0 8px;
    font-size: 17px;
}

.admin-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-full { grid-column: 1 / -1; }

label {
    display: block;
    margin-bottom: 6px;
    color: #cbd9e7;
    font-weight: 600;
    font-size: 12px;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--panel-dark);
    color: var(--text);
    padding: 10px 11px;
    font: inherit;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: #4d83bd;
    box-shadow: 0 0 0 2px rgba(61,120,191,.18);
}

textarea {
    min-height: 90px;
    resize: vertical;
}

input::placeholder, textarea::placeholder { color: #6f879e; }

.help {
    color: var(--muted-2);
    margin-top: 5px;
    font-size: 11px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check-row input { width: auto; }
.check-row label { margin: 0; }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #20354c;
    color: #fff;
    padding: 9px 14px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover {
    background: #29435f;
    color: #fff;
}

.btn-primary {
    background: var(--blue);
    border-color: #538bd0;
}

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

.btn-danger {
    background: #a92743;
    border-color: #c23857;
}

.btn-danger:hover { background: #c22c4d; }

.alert {
    border-radius: 7px;
    padding: 11px 13px;
    margin-bottom: 14px;
    border: 1px solid;
}

.alert-success {
    background: rgba(34,197,94,.10);
    border-color: rgba(34,197,94,.35);
    color: #80e5a5;
}

.alert-error {
    background: rgba(239,71,111,.10);
    border-color: rgba(239,71,111,.40);
    color: #ff9bb2;
}

.manage-item {
    border-top: 1px solid var(--border);
    padding-top: 18px;
    margin-top: 18px;
}

.manage-item:first-child {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
}

.empty-state {
    padding: 24px;
    text-align: center;
    color: var(--muted);
    background: var(--panel);
    border: 1px dashed var(--border-light);
    border-radius: var(--radius);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(circle at 50% -20%, #1c3551 0, var(--bg) 45%);
}

.login-box {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 28px;
    box-shadow: 0 25px 60px rgba(0,0,0,.30);
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    background: #fff;
    padding: 6px;
    border-radius: 12px;
    margin-bottom: 12px;
}

.login-title {
    font-size: 21px;
    font-weight: 700;
}

.login-subtitle {
    color: var(--muted);
    margin-top: 5px;
}

.user-card {
    border-top: 1px solid var(--border);
    padding-top: 22px;
    margin-top: 22px;
}

.user-card:first-child {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
}

.user-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.user-name {
    font-size: 17px;
    font-weight: 700;
}

.user-meta {
    color: var(--muted);
    margin-top: 3px;
    font-size: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 20px;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 700;
}

.badge-admin {
    background: rgba(61,120,191,.16);
    color: #9ecbff;
    border: 1px solid rgba(61,120,191,.45);
}

.badge-user {
    background: rgba(255,255,255,.05);
    color: var(--muted);
    border: 1px solid var(--border);
}

.tool-access { margin-top: 18px; }

.tool-access-title {
    font-weight: 700;
    margin-bottom: 10px;
}

.tool-check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}

.tool-check {
    display: flex;
    gap: 9px;
    align-items: center;
    background: var(--panel-dark);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 9px 10px;
}

.tool-check input {
    width: auto;
    margin: 0;
}

.tool-check label {
    margin: 0;
    color: var(--text);
    cursor: pointer;
}

.admin-note {
    color: var(--muted);
    background: var(--panel-dark);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 11px;
}

.password-box {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

@media (max-width: 760px) {
    .app-shell { display: block; }

    .sidebar {
        position: static;
        width: 100%;
        min-width: 0;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .main {
        margin-left: 0;
        width: 100%;
    }

    .form-grid { grid-template-columns: 1fr; }
    .form-full { grid-column: auto; }
    .content { padding: 18px 14px 30px; }

    .user-header {
        align-items: flex-start;
        flex-direction: column;
    }
}


/* ============================================================
   Shared polished navigation
   Applied globally so Dashboard + ALL admin pages match.
   ============================================================ */

/* More breathing room around the entire sidebar. */
.sidebar {
    padding: 14px 12px 16px;
}

/* Give the logo/header a little extra room. */
.brand {
    margin-bottom: 20px;
}

/* Space between nav buttons without changing the working structure. */
.nav {
    gap: 5px;
}

/* Section heading spacing. */
.nav-section {
    margin: 16px 8px 7px;
}

/* The buttons themselves keep the same size/padding on every page. */
.nav-item {
    min-height: 44px;
    padding: 8px 10px;
    gap: 10px;
}

/* Pretty colored icon chips like the Intellifi sidebar. */
.nav-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 9px;
    border: 1px solid rgba(255,255,255,.08);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.06),
        0 1px 3px rgba(0,0,0,.18);
    transition:
        transform .12s ease,
        filter .12s ease,
        background .12s ease;
}

.nav-icon svg {
    width: 14px;
    height: 14px;
}

.nav-icon-dashboard {
    color: #b9d9ff;
    background: #294f7a;
}

.nav-icon-admin {
    color: #d5b9ff;
    background: #4c3973;
}

.nav-icon-tools {
    color: #9ceaf0;
    background: #23606a;
}

.nav-icon-users {
    color: #9fe4b7;
    background: #286046;
}

.nav-icon-password {
    color: #ffe08a;
    background: #65501f;
}

.nav-icon-logout {
    color: #ffaea5;
    background: #6a3932;
}

.nav-item:hover .nav-icon {
    transform: translateY(-1px);
    filter: brightness(1.12);
}

/* Active page stays blue, but the icon gets a darker inset chip. */
.nav-item.active .nav-icon {
    color: #fff;
    background: rgba(10, 28, 48, .48);
    border-color: rgba(255,255,255,.18);
}

/* Keep the footer controls away from the bottom edge. */
.nav-spacer {
    min-height: 24px;
}

.sidebar > .nav:last-child {
    padding-bottom: 6px;
}

/* Preserve attractive dashboard tool icons. */
.tool-icon {
    width: 44px;
    height: 44px;
    border-radius: 9px;
    background: #223750;
    border: 1px solid #304b66;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.05),
        0 2px 5px rgba(0,0,0,.16);
}

.tool-icon i {
    font-size: 21px;
}
