html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
        sans-serif;
    background: radial-gradient(circle at top left, #111827 0, #020617 45%),
        radial-gradient(circle at bottom right, #020617 0, #000 55%);
    color: #e5e7eb;
}

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

:root {
    --sidebar-width: 260px;
}

.sidebar {
    width: var(--sidebar-width);
    background: radial-gradient(circle at top, #0b1120 0, #020617 60%);
    border-right: 1px solid rgba(15, 23, 42, 0.9);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.5rem;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
}

.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.9);
}

.sidebar-user {
    display: flex;
    flex-direction: column;
}

.sidebar-user-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.sidebar-user-sub {
    font-size: 0.75rem;
    color: #9ca3af;
}

.sidebar-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #6b7280;
    margin: 1.1rem 0 0.35rem;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.6rem;
    border-radius: 0.55rem;
    color: #9ca3af;
    text-decoration: none;
    font-size: 0.88rem;
    transition: all 0.15s ease-out;
}

.nav-item a .bi {
    font-size: 1rem;
    width: 18px;
    text-align: center;
}

.nav-item a span.badge {
    margin-left: auto;
}

.nav-item a:hover {
    background: #020617;
    color: #e5e7eb;
}

.nav-item a.active {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.16), transparent);
    border: 1px solid rgba(79, 70, 229, 0.55);
    color: #f9fafb;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.8);
}

.nav-item a.active .bi {
    color: #a5b4fc;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.25rem;
    border-top: 1px dashed rgba(55, 65, 81, 0.8);
    font-size: 0.78rem;
    color: #6b7280;
}

.sidebar-footer span {
    color: #9ca3af;
}

/* Main area */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(24px);
    background: radial-gradient(circle at top, rgba(15, 23, 42, 0.9), #020617);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.85);
    background: radial-gradient(circle at top left,
            rgba(15, 23, 42, 0.9),
            rgba(15, 23, 42, 0.6));
}

.topbar-title {
    font-size: 0.9rem;
    font-weight: 500;
}

.topbar-sub {
    font-size: 0.76rem;
    color: #9ca3af;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-profile-btn {
    border: none;
    background: transparent;
    padding: 0;
}

.topbar-profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #f9fafb;
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.9);
}

/* Profile dropdown – theme-matched dark glass */
.topbar-profile-menu.dropdown-menu {
    background: radial-gradient(circle at top left, #0f172a, #020617);
    border: 1px solid rgba(55, 65, 81, 0.9);
    border-radius: 0.75rem;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    padding: 0.5rem;
    min-width: 200px;
    margin-top: 0.5rem;
}

.topbar-profile-menu .dropdown-header {
    padding: 0.5rem 0.75rem;
    color: #9ca3af !important;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(55, 65, 81, 0.6);
    margin-bottom: 0.25rem;
}

.topbar-profile-menu .dropdown-item {
    color: #e5e7eb;
    font-size: 0.88rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
}

.topbar-profile-menu .dropdown-item:hover,
.topbar-profile-menu .dropdown-item:focus {
    background: rgba(79, 70, 229, 0.15);
    color: #f9fafb;
}

.topbar-profile-menu .dropdown-divider {
    border-color: rgba(55, 65, 81, 0.8);
    margin: 0.35rem 0;
}

.topbar-profile-menu .dropdown-item[href="login.html"] {
    color: #f87171;
}

.topbar-profile-menu .dropdown-item[href="login.html"]:hover {
    background: rgba(248, 113, 113, 0.12);
    color: #fca5a5;
}

.pill-toggle {
    background: rgba(15, 23, 42, 0.9);
    border-radius: 999px;
    padding: 0.2rem;
    display: inline-flex;
    gap: 0.15rem;
}

.pill-toggle button {
    border: none;
    background: transparent;
    color: #9ca3af;
    font-size: 0.75rem;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
}

.pill-toggle button.active {
    background: radial-gradient(circle at top left, #4f46e5, #06b6d4);
    color: white;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.75);
}

.badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
}

.content-scroll {
    padding: 1.5rem;
    overflow: auto;
}

/* Cards */
.glass-card {
    background: radial-gradient(circle at top left, #020617, #020617);
    border-radius: 1rem;
    border: 1px solid rgba(15, 23, 42, 0.95);
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.9);
    padding: 1.1rem 1.1rem 1.15rem;
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.card-title {
    font-size: 0.86rem;
    font-weight: 500;
}

.card-sub {
    font-size: 0.7rem;
    color: #6b7280;
}

.tiny-pill {
    font-size: 0.7rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(55, 65, 81, 0.8);
    padding: 0.12rem 0.55rem;
    color: #9ca3af;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.stat-label {
    font-size: 0.78rem;
    color: #9ca3af;
}

.stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
}

.stat-chip.positive {
    background: rgba(22, 163, 74, 0.12);
    color: #4ade80;
}

.stat-chip.neutral {
    background: rgba(148, 163, 184, 0.12);
    color: #e5e7eb;
}

.mini-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1.2rem;
}

.mini-card {
    border-radius: 0.9rem;
    padding: 0.7rem 0.85rem;
    background: radial-gradient(circle at top, #020617, #020617);
    border: 1px solid rgba(31, 41, 55, 0.9);
}

.mini-label {
    font-size: 0.72rem;
    color: #9ca3af;
}

.mini-value {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0.2rem;
}

.mini-sub {
    font-size: 0.7rem;
    color: #6b7280;
}

.chart-placeholder {
    margin-top: 0.6rem;
    height: 140px;
    border-radius: 0.9rem;
    border: 1px dashed rgba(55, 65, 81, 0.8);
    background-image: linear-gradient(90deg,
            rgba(148, 163, 184, 0.12) 1px,
            transparent 0),
        linear-gradient(180deg, rgba(148, 163, 184, 0.12) 1px, transparent 0);
    background-size: 22px 100%, 100% 22px;
    position: relative;
    overflow: hidden;
}

.chart-placeholder::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 20%,
            rgba(79, 70, 229, 0.22),
            transparent 60%);
    opacity: 0.6;
}

/* Calls grid */
.calls-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.85rem;
}

.call-card-label {
    font-size: 0.76rem;
    color: #9ca3af;
}

.call-card-value {
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 0.15rem;
}

/* Table + theme-table */
.table-card {
    margin-top: 1.1rem;
}

.theme-table thead th,
.table thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    border-bottom: 1px solid rgba(31, 41, 55, 0.9);
    font-weight: 500;
}

.theme-table tbody td,
.table tbody td {
    border-top: 1px solid rgba(31, 41, 55, 0.9);
    font-size: 0.8rem;
    color: #e5e7eb;
}

.badge-soft {
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    font-size: 0.7rem;
}

.badge-soft-neutral {
    background: rgba(148, 163, 184, 0.12);
    color: #e5e7eb;
}

.badge-soft-warning {
    background: rgba(234, 179, 8, 0.1);
    color: #facc15;
}

.badge-soft-success {
    background: rgba(22, 163, 74, 0.12);
    color: #4ade80;
}

.hero-badge {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #f97316;
    margin-bottom: 0.4rem;
}

.hero-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.hero-sub {
    font-size: 0.84rem;
    color: #9ca3af;
    max-width: 420px;
}

.stats-strip {
    background-color: radial-gradient(circle at top, #020617, #020617);
    border-radius: 0.9rem;
    border: 1px solid rgba(31, 41, 55, 0.9);
    padding: 0.8rem 1.2rem;
    display: flex;
    gap: 1.5rem;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.stats-strip-label {
    color: #9ca3af;
}

.stats-strip-value {
    font-weight: 600;
    margin-left: 0.25rem;
}

.empty-row {
    text-align: center;
    padding: 2rem 1rem;
    color: #9ca3af;
    font-size: 0.85rem;
}

.theme-tabs .nav-link {
    font-size: 0.85rem;
    font-weight: 500;
    color: #9ca3af;
    border: 1px solid rgba(55, 65, 81, 0.8);
    background: transparent;
    border-radius: 0.5rem 0.5rem 0 0;
    padding: 0.5rem 1rem;
}

.theme-tabs .nav-link:first-child {
    border-right: 0;
}

.theme-tabs .nav-link.active {
    background: rgba(15, 23, 42, 0.95);
    color: #e5e7eb;
    border-bottom-color: transparent;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.empty-state-icon {
    font-size: 3rem;
    color: #4b5563;
    margin-bottom: 1rem;
}

.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.empty-state-sub {
    font-size: 0.85rem;
    color: #9ca3af;
    margin-bottom: 1.25rem;
}

.theme-modal .modal-content {
    background: radial-gradient(circle at top left, #0f172a, #020617);
    border: 1px solid rgba(55, 65, 81, 0.9);
    border-radius: 0.85rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    color: #e5e7eb;
}

.theme-modal .modal-header {
    border-bottom: 1px solid rgba(55, 65, 81, 0.8);
    padding: 1rem 1.25rem;
}

.theme-modal .modal-title {
    font-size: 1rem;
    font-weight: 600;
}

.theme-modal .modal-header .modal-subtitle {
    font-size: 0.8rem;
    color: #9ca3af;
    font-weight: 400;
    margin-top: 0.15rem;
}

.theme-modal .btn-close {
    filter: invert(1);
    opacity: 0.7;
}

.theme-modal .modal-body {
    padding: 1rem 1.25rem;
}

.theme-modal .modal-footer {
    border-top: 1px solid rgba(55, 65, 81, 0.8);
    padding: 0.85rem 1.25rem;
}

.theme-modal .form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #e5e7eb;
}

.theme-modal .form-control {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(55, 65, 81, 0.9);
    color: #e5e7eb;
    border-radius: 0.5rem;
}

.theme-modal .form-control::placeholder {
    color: #6b7280;
}

.theme-modal .form-text {
    font-size: 0.76rem;
    color: #9ca3af;
}

.theme-modal .btn-primary {
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    border: none;
}

/* Upload zone for Add Documents */
.upload-zone {
    border: 2px dashed rgba(55, 65, 81, 0.9);
    border-radius: 0.75rem;
    background: rgba(15, 23, 42, 0.5);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: #4f46e5;
    background: rgba(79, 70, 229, 0.08);
}

.upload-zone .bi-cloud-arrow-up {
    font-size: 2.5rem;
    color: #6b7280;
}

.upload-zone p {
    margin: 0.5rem 0 0;
    font-size: 0.9rem;
    color: #9ca3af;
}

.upload-zone .upload-limit {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Knowledge base: single-selection note + table polish */
.kb-single-note {
    background: rgba(79, 70, 229, 0.08);
    border: 1px solid rgba(79, 70, 229, 0.25);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 1rem;
}
.table-responsive .table {
    margin-bottom: 0;
}
.table .form-check-input:checked {
    background-color: #4f46e5;
    border-color: #4f46e5;
}
.glass-card .theme-tabs .nav-link {
    border-radius: 0.5rem;
}
.glass-card .theme-tabs .nav-link.active {
    background: rgba(79, 70, 229, 0.15);
    color: #a5b4fc;
}

/* Auth pages (login / register) */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1.5rem;
}

.auth-shell .auth-card {
    width: 100%;
    max-width: 460px;
}

.auth-card {
    background: radial-gradient(circle at top left, #020617, #020617);
    border-radius: 1rem;
    border: 1px solid rgba(15, 23, 42, 0.95);
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.9);
    padding: 1.6rem 1.7rem 1.7rem;
}

.auth-logo {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.auth-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.auth-sub {
    font-size: 0.85rem;
    color: #9ca3af;
    margin-bottom: 1.4rem;
}

.auth-card .form-label {
    font-size: 0.82rem;
    font-weight: 500;
}

.auth-card .form-control {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(55, 65, 81, 0.9);
    color: #e5e7eb;
    border-radius: 0.55rem;
}

.auth-card .form-control::placeholder {
    color: #6b7280;
}

.auth-card .btn-primary {
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    border: none;
    border-radius: 0.55rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.auth-footer {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #9ca3af;
    text-align: center;
}

.text-muted {
    color: rgb(40 147 255 / 75%) !important;
}

/* Responsive */
@media (max-width: 991.98px) {
    body {
        overflow: auto;
    }

    .app-shell {
        flex-direction: column;
        height: auto;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        padding: 0.6rem 1rem;
        overflow-x: auto;
    }

    .sidebar-header {
        margin-bottom: 0;
        margin-right: 1.2rem;
    }

    .sidebar-main {
        display: flex;
        gap: 1.5rem;
        align-items: center;
    }

    .sidebar-section-label {
        display: none;
    }

    .nav-list-horizontal {
        display: flex;
        gap: 0.25rem;
    }

    .nav-item a {
        white-space: nowrap;
    }

    .main-area {
        height: auto;
    }
}