:root {
    --brand: #1e3a5f;
    --brand-2: #2c5282;
    --brand-accent: #3182ce;
    --sidebar-w: 280px;
    --bg: #f4f6fa;
    --card-shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: #1a202c;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
}

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

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, var(--brand) 0%, #16293f 100%);
    color: #cbd5e0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-brand .bi { font-size: 1.75rem; color: #63b3ed; }
.brand-logo { width: 30px; height: auto; flex: 0 0 auto; }
.brand-name { font-size: 1.35rem; font-weight: 700; color: #fff; letter-spacing: .04em; display: block; }
.brand-company { color: #90cdf4; font-size: .72rem; }

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-profile .fw-semibold { color: #fff; }
.sidebar-profile .text-muted { color: rgba(255, 255, 255, .75) !important; }
.avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--brand-accent); color: #fff;
    display: grid; place-items: center;
    font-weight: 700; font-size: 1.1rem; text-transform: uppercase;
}

.sidebar-nav { padding: .5rem 0 2rem; }
.nav-section {
    padding: 1rem 1.25rem .35rem;
    font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
    color: #718096; font-weight: 700;
}
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: .6rem;
    padding: .6rem 1.25rem; color: #cbd5e0; text-decoration: none;
    border-left: 3px solid transparent;
}
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-nav .nav-link.active { background: rgba(49, 130, 206, .22); color: #fff; border-left-color: #63b3ed; }
.sidebar-nav .bi { width: 1.1rem; text-align: center; }

.sidebar .accordion,
.sidebar .accordion-item { background: transparent; border: 0; }
.sidebar .accordion-button {
    background: transparent; color: #cbd5e0; padding: .6rem 1.25rem;
    font-size: .875rem; box-shadow: none; gap: .6rem;
}
.sidebar .accordion-button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar .accordion-button:not(.collapsed) { background: rgba(255, 255, 255, .04); color: #fff; }
.sidebar .accordion-button::after { filter: invert(1) grayscale(1) brightness(1.6); }
.sidebar .accordion-body { padding: .15rem 0 .5rem; }
.nav-sublink {
    display: block; padding: .4rem 1.25rem .4rem 2.85rem;
    color: #a0aec0; text-decoration: none; font-size: .83rem;
    border-left: 3px solid transparent;
}
.nav-sublink:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-sublink.active { background: rgba(49, 130, 206, .28); color: #fff; border-left-color: #63b3ed; font-weight: 600; }
/* Accordion whose child is the current page: keep the header highlighted too. */
.sidebar .accordion-button:not(.collapsed) { color: #fff; }

/* ---------- Main ---------- */
.app-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex; align-items: center;
    background: #fff; padding: .5rem 1.25rem;
    box-shadow: var(--card-shadow); position: sticky; top: 0; z-index: 20;
}
.toggle-sidebar { color: #4a5568; font-size: 1.4rem; padding: 0 .5rem; text-decoration: none; }
.user-menu { color: #2d3748; text-decoration: none; font-weight: 600; }
.user-menu .bi-person-circle { font-size: 1.2rem; margin-right: .25rem; }

.content { padding: 1.5rem; flex: 1 1 auto; }
.footer { padding: 1rem 1.5rem; color: #718096; font-size: .8rem; border-top: 1px solid #e2e8f0; }

/* ---------- Cards / tables ---------- */
.card { border: 0; box-shadow: var(--card-shadow); border-radius: .6rem; }
.card-header {
    background: #fff; border-bottom: 1px solid #edf2f7;
    font-weight: 600; display: flex; align-items: center; gap: .5rem;
    border-radius: .6rem .6rem 0 0 !important;
}
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--brand); margin-bottom: 1.25rem; }
.page-title .bi { color: var(--brand-accent); }

.table > :not(caption) > * > * { padding: .6rem .75rem; vertical-align: middle; }
.table thead th { background: #f7fafc; color: #4a5568; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }

.btn-brand { background: var(--brand-accent); border-color: var(--brand-accent); color: #fff; }
.btn-brand:hover { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }

.stat-tile {
    display: flex; align-items: center; justify-content: space-between;
    padding: .55rem .25rem; border-bottom: 1px solid #edf2f7;
}
.stat-tile:last-child { border-bottom: 0; }
.stat-tile a { text-decoration: none; color: #2d3748; }
.stat-swatch { width: .8rem; height: .8rem; border-radius: 3px; display: inline-block; margin-right: .5rem; }
.stat-count { font-weight: 700; color: var(--brand); }

.badge-global { background: #e2e8f0; color: #2d3748; font-weight: 500; }

/* ---------- Tags input (people lists) ---------- */
.tags-input {
    display: flex; flex-wrap: wrap; align-items: center; gap: .3rem;
    padding: .3rem .4rem; min-height: 38px; cursor: text;
    border: 1px solid #ced4da; border-radius: .375rem; background: #fff;
}
.tags-input.is-invalid { border-color: #dc3545; }
.tags-input:focus-within { border-color: #86b7fe; box-shadow: 0 0 0 .25rem rgba(13,110,253,.25); }
.ti-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    background: #e7f0fb; color: var(--brand); border: 1px solid #cfe0f5;
    border-radius: 1rem; padding: .1rem .1rem .1rem .55rem; font-size: .8rem; line-height: 1.4;
}
.ti-x {
    border: 0; background: transparent; color: var(--brand); cursor: pointer;
    line-height: 1; padding: 0 .35rem; font-size: 1rem; border-radius: 50%;
}
.ti-x:hover { color: #fff; background: #c0392b; }
.ti-entry {
    border: 0; outline: 0; background: transparent; flex: 1 1 140px;
    min-width: 140px; font-size: .85rem; padding: .15rem .25rem;
}

/* ---------- Auth ---------- */
.auth-wrap { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, var(--brand) 0%, #16293f 100%); padding: 1rem; }
.auth-card { width: 100%; max-width: 430px; background: #fff; border-radius: .8rem; box-shadow: 0 20px 45px rgba(0,0,0,.25); overflow: hidden; }
.auth-head { text-align: center; padding: 2rem 2rem 1rem; }
.auth-head .bi { font-size: 2.75rem; color: var(--brand-accent); }
.auth-logo { width: 58px; height: auto; }
.auth-head h1 { font-size: 1.6rem; font-weight: 700; color: var(--brand); letter-spacing: .05em; margin: .5rem 0 .25rem; }
.auth-body { padding: 1rem 2rem 2rem; }
.captcha-img { border: 1px solid #cbd5e0; border-radius: .4rem; }

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
    .sidebar { position: fixed; z-index: 1050; transform: translateX(-100%); transition: transform .2s ease; }
    .app-shell.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1040; }
}
