/* App theme color - default primary #20498B */
:root {
    --app-primary: #20498B;
    --app-primary-dark: #1a3d75;
    --app-primary-light: #2d5aa0;
}

/* Bootstrap overrides using app theme */
.btn-primary,
.navbar-dark.bg-dark,
.card-header .nav-tabs .nav-link.active,
.card-header .nav-tabs .nav-link:hover {
    --bs-primary: var(--app-primary);
    --bs-primary-rgb: 32, 73, 139;
}
.btn-primary {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}
.btn-primary:hover {
    background-color: var(--app-primary-dark);
    border-color: var(--app-primary-dark);
}
.navbar-dark.bg-dark,
.navbar.bg-primary {
    background-color: var(--app-primary) !important;
}
.text-primary {
    color: var(--app-primary) !important;
}
.bg-primary {
    background-color: var(--app-primary) !important;
}

/* Auth / card tabs use theme */
.card-header .nav-tabs .nav-link.active {
    color: var(--app-primary) !important;
}
.card-header .nav-tabs .nav-link:hover {
    color: var(--app-primary);
}

/* ========== Main layout: header + footer ========== */
:root {
    --sidebar-active-bg: var(--app-primary);
    --sidebar-active-text: #fff;
}

body.app-body {
    margin: 0 !important;
    padding: 0 !important;
    min-height: 100vh;
    display: flex !important;
    flex-direction: column;
    background: linear-gradient(135deg, #f0f4ff 0%, #f8fafc 50%, #f1f5f9 100%);
}

.app-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.btn-link-sm {
    background: linear-gradient(180deg, #20498B 0%, #20498B 100%);
    border: 1px solid var(--p-border);
    padding: 5px 12px;
    border-radius: 6px;
    color: var(--p-accent-light);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    display: inline-block;
    position: relative;
    overflow: hidden;
}

/* underline effect */
.btn-link-sm::after {
    content: "";
    position: absolute;
    left: 12px;
    bottom: 4px;
    width: 0%;
    height: 2px;
    background: currentColor;
    transition: width 0.25s ease;
}

.btn-link-sm:hover::after {
    width: calc(100% - 24px);
}

.btn-link-sm:hover {
    background: white;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    color: var(--p-accent);
}
.app-header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.875rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.app-header-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--app-primary);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 700;
    text-decoration: none;
    flex-shrink: 0;
}

.app-header-logo:hover {
    background: var(--app-primary-dark);
    color: #fff;
}

.app-header-brand {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.app-header-app-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.02em;
}

.app-breadcrumb {
    font-size: 0.8125rem;
    color: #64748b;
}

.app-breadcrumb a {
    color: #64748b;
    text-decoration: none;
}

.app-breadcrumb a:hover {
    color: var(--app-primary);
}

.app-breadcrumb-static {
    font-size: 0.8125rem;
    color: #64748b;
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-header-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    color: #64748b;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.app-header-icon-btn:hover {
    background: #f1f5f9;
    color: #334155;
}

.app-header-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    flex-shrink: 0;
}

.app-header-avatar:hover {
    background: #cbd5e1;
    color: #334155;
}

.app-header-avatar-btn {
    border: none;
    padding: 0;
    cursor: pointer;
}

.app-user-dropdown {
    min-width: 220px;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.app-user-dropdown .dropdown-header {
    padding: 0.75rem 1rem;
    white-space: normal;
}

.app-user-dropdown-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9375rem;
}

.app-user-dropdown-email {
    font-size: 0.8125rem;
    color: #64748b;
    margin-top: 2px;
}

.app-logout-form {
    margin: 0;
}

.app-logout-btn {
    width: 100%;
    text-align: left;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: #64748b;
    border: none;
    background: none;
    cursor: pointer;
}

.app-logout-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.app-header-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.app-header-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #212529;
}

.app-main {
    flex: 1;
    padding: 1.5rem 1.5rem 2rem;
    max-width: 1700px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.app-main .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

.app-footer {
    flex-shrink: 0;
    margin-top: auto;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 1rem 1.5rem;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.04);
    font-size: 0.875rem;
    color: #64748b;
}

.app-footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #6c757d;
}

@media (max-width: 991px) {
    .mp-grid-top,
    .mp-grid-bottom {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
    .app-main {
        padding: 1rem;
    }

    .app-header {
        padding: 0.75rem 1rem;
    }

    .app-header-app-name {
        font-size: 1rem;
    }
}

/* Breadcrumb list (Yii widget) */
.app-breadcrumb .breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    margin: 0;
    padding: 0;
    background: none;
    font-size: 0.8125rem;
    color: #64748b;
}

.app-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    content: '/';
    padding-right: 0.5rem;
    color: #94a3b8;
}

.app-breadcrumb .breadcrumb-item a {
    color: #64748b;
    text-decoration: none;
}

.app-breadcrumb .breadcrumb-item a:hover {
    color: var(--app-primary);
}

/* ========== Message Portal Dashboard ========== */
.message-portal-dashboard {
    padding: 0;
    max-width: 1200px;
    margin: 0 auto;
}

.mp-grid {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.mp-grid-top {
    grid-template-columns: 1fr 1fr;
}

.mp-grid-mid {
    grid-template-columns: 1fr;
}

.mp-grid-bottom {
    grid-template-columns: 1fr 1fr;
}

.mp-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.04);
    padding: 1.5rem 1.75rem;
    position: relative;
}

.mp-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.mp-card-head-row {
    flex-wrap: wrap;
}

.mp-card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    letter-spacing: -0.01em;
}

.mp-card-icon {
    color: #94a3b8;
    display: inline-flex;
}

.mp-card-desc {
    font-size: 0.9375rem;
    color: #64748b;
    margin: 0 0 1.25rem 0;
    line-height: 1.45;
}

.mp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: 10px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.mp-btn-primary {
    background: var(--app-primary);
    color: #fff;
}

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

.mp-btn-secondary {
    background: #f1f5f9;
    color: var(--app-primary);
    margin-top: 1rem;
    width: 100%;
}

.mp-btn-secondary:hover {
    background: #e2e8f0;
    color: var(--app-primary-dark);
}

.mp-btn-view {
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
    background: #f1f5f9;
    color: #334155;
    flex-shrink: 0;
}

.mp-btn-view:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* Send card illustration placeholder */
.mp-card-illus {
    margin-top: 1.25rem;
    height: 100px;
    position: relative;
}

.mp-illus-bubble,
.mp-illus-person {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    position: absolute;
    bottom: 0;
}

.mp-illus-person {
    left: 20px;
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
}

.mp-illus-bubble {
    right: 20px;
}

/* Metrics */
.mp-card-metrics .mp-card-head {
    margin-bottom: 0.25rem;
}

.mp-metrics-refill {
    font-size: 0.8125rem;
    color: #64748b;
    margin: 0 0 1rem 0;
}

.mp-metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.mp-metric-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.mp-metric-label {
    font-size: 0.8125rem;
    color: #64748b;
    font-weight: 500;
}

.mp-metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.02em;
}

.mp-metric-badge {
    font-size: 0.75rem;
    color: #64748b;
}

.mp-badge-up {
    color: #16a34a;
}

.mp-arrow-up {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 5px solid currentColor;
    margin-right: 2px;
    vertical-align: middle;
}

/* Chart placeholder */
.mp-card-chart .mp-card-title {
    margin-bottom: 1rem;
}

.mp-chart-placeholder {
    height: 140px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.mp-chart-line {
    width: 100%;
    height: 100%;
    color: #22c55e;
    opacity: 0.9;
}

/* Token history */
.mp-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mp-history-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9375rem;
}

.mp-history-item:last-of-type {
    border-bottom: none;
}

.mp-history-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mp-dot-green {
    background: #22c55e;
}

.mp-dot-red {
    background: #ef4444;
}

.mp-history-label {
    color: #334155;
}

.mp-history-date {
    font-size: 0.8125rem;
    color: #64748b;
}

.mp-history-value {
    font-weight: 600;
    color: #1e293b;
}

/* Scheduled messages */
.mp-tabs-inline {
    display: flex;
    gap: 0.25rem;
}

.mp-tab-inline {
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #64748b;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.mp-tab-inline:hover {
    color: #334155;
    background: #f8fafc;
}

.mp-tab-inline.active {
    background: #e8eef8;
    color: var(--app-primary);
    border-color: #b8c9e0;
}

.mp-scheduled-count {
    font-size: 0.8125rem;
    color: #64748b;
    margin: 0 0 1rem 0;
}

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

.mp-scheduled-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.mp-scheduled-item:last-child {
    border-bottom: none;
}

.mp-scheduled-empty {
    color: #64748b;
    font-size: 0.9375rem;
}

.mp-scheduled-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mp-scheduled-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    flex: 1;
}

.mp-scheduled-recipient {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #1e293b;
}

.mp-scheduled-meta {
    font-size: 0.75rem;
    color: #64748b;
}

.mp-scheduled-progress {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    min-width: 80px;
    overflow: hidden;
}

.mp-progress-bar {
    height: 100%;
    background: #f59e0b;
    border-radius: 3px;
    transition: width 0.3s;
}

.mp-scheduled-status {
    font-size: 0.75rem;
    color: #64748b;
}

/* Admin section */
.mp-admin-section {
    margin-top: 2rem;
}

.mp-section-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 1rem 0;
}

.mp-muted {
    color: #64748b;
}

.mp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.mp-table th,
.mp-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.mp-table th {
    font-weight: 600;
    color: #64748b;
}

.mp-form .form-label {
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: #334155;
}

/* Legacy dashboard (keep for other pages that might use .dashboard-*) */
.dashboard-page {
    padding: 0;
}

.dashboard-header {
    margin-bottom: 1.75rem;
}

.dashboard-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    color: #1e293b;
    letter-spacing: -0.02em;
}

.dashboard-subtitle {
    font-size: 0.9375rem;
    color: #64748b;
    margin: 0;
}

.dashboard-section-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 1rem 0;
}

.dashboard-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
    padding: 1.5rem 1.75rem;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.dashboard-stat {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.dashboard-stat-label {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

.dashboard-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.02em;
}

.dashboard-form .form-label {
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: #334155;
}

/* ========== Auth layout: header + main + footer (no sidebar) ========== */
.app-body-auth {
    flex-direction: column;
    background: #f1f3f5;
    background-image:
        linear-gradient(120deg, rgba(255,255,255,.6) 0%, transparent 50%),
        linear-gradient(240deg, rgba(0,0,0,.03) 0%, transparent 40%);
    min-height: 100vh;
}

.app-auth-header {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 0.875rem 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.app-auth-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-auth-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--app-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.app-auth-brand:hover {
    color: var(--app-primary-dark);
}

.app-auth-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.app-auth-nav-link {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #475569;
    text-decoration: none;
}

.app-auth-nav-link:hover {
    color: var(--app-primary);
}

.app-auth-main {
    flex: 1;
    min-height: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
}

.app-auth-footer {
    background: #fff;
    border-top: 1px solid #e9ecef;
    padding: 0.75rem 1rem;
}

.app-auth-footer-inner {
    max-width: 420px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: #6c757d;
}

main > .container {
    padding: 0;
}

.footer {
    background-color: #f5f5f5;
    font-size: .9em;
    height: 60px;
}

.footer > .container {
    padding-right: 15px;
    padding-left: 15px;
}

.not-set {
    color: #c55;
    font-style: italic;
}

/* add sorting icons to gridview sort links */
a.asc:after, a.desc:after {
    content: '';
    left: 3px;
    display: inline-block;
    width: 0;
    height: 0;
    border: solid 5px transparent;
    margin: 4px 4px 2px 4px;
    background: transparent;
}

a.asc:after {
    border-bottom: solid 7px #212529;
    border-top-width: 0;
}

a.desc:after {
    border-top: solid 7px #212529;
    border-bottom-width: 0;
}

.grid-view th {
    white-space: nowrap;
}

.hint-block {
    display: block;
    margin-top: 5px;
    color: #999;
}

.error-summary {
    color: #a94442;
    background: #fdf7f7;
    border-left: 3px solid #eed3d7;
    padding: 10px 20px;
    margin: 0 0 15px 0;
}

/* align the logout "link" (button in form) of the navbar */
.nav li > form > button.logout {
    padding-top: 7px;
    color: rgba(255, 255, 255, 0.5);
}

@media(max-width:767px) {
    .nav li > form > button.logout {
        display:block;
        text-align: left;
        width: 100%;
        padding: 10px 0;
    }
}

.nav > li > form > button.logout:focus,
.nav > li > form > button.logout:hover {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.75);
}

.nav > li > form > button.logout:focus {
    outline: none;
}

.form-group {
    margin-bottom: 1rem;
}

/* ============================================================
   SIDEBAR NAVIGATION — logo-header · nav sections · user footer
   ============================================================ */
:root {
    --sb-width: 262px;
    --sb-text: #b8d0f0;
    --sb-text-active: #ffffff;
    --sb-accent: #60a5fa;
    --topbar-h: 60px;
}

/* ══ Sidebar shell ══ */
.app-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sb-width);
    background: linear-gradient(180deg, #162f5e 0%, #0f2147 60%, #091630 100%);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.22);
}

/* ══ HEADER — logo + app name + current page ══ */
.sb-header {
    flex-shrink: 0;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    background: rgba(0,0,0,0.12);
}
.sb-logo-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    text-decoration: none;
    margin-bottom: 0.875rem;
}
.sb-logo-row:hover { text-decoration: none; }
.sb-logo-icon {
    width: 46px; height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2563eb 0%, #1a3d73 100%);
    box-shadow: 0 4px 14px rgba(37,99,235,0.45), inset 0 1px 0 rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sb-app-name {
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.sb-app-tagline {
    font-size: 0.6875rem;
    color: rgba(180,210,255,0.5);
    margin-top: 2px;
    letter-spacing: 0.02em;
}
.sb-current-page {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(96,165,250,0.1);
    border: 1px solid rgba(96,165,250,0.18);
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
}
.sb-current-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--sb-accent);
    flex-shrink: 0;
    box-shadow: 0 0 6px var(--sb-accent);
    animation: sbPulse 2.4s ease-in-out infinite;
}
@keyframes sbPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.7); }
}
.sb-current-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(180,210,255,0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.01em;
}

/* ══ NAV — scrollable middle ══ */
.sb-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0.875rem 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-nav::-webkit-scrollbar-track { background: transparent; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Section labels */
.sb-section-label {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(180,210,255,0.35);
    padding: 0.875rem 0.625rem 0.3rem;
    user-select: none;
}

/* Nav item */
.sb-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    color: var(--sb-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    border-radius: 10px;
    margin-bottom: 1px;
    transition: background 0.15s, color 0.15s;
    user-select: none;
    white-space: nowrap;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    outline: none;
    line-height: 1.4;
}
.sb-item:hover, .sb-item:focus-visible {
    background: rgba(255,255,255,0.08);
    color: var(--sb-text-active);
    text-decoration: none;
}
.sb-item.active {
    background: rgba(96,165,250,0.15);
    color: var(--sb-text-active);
}
.sb-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    background: var(--sb-accent);
    border-radius: 0 3px 3px 0;
}
/* Icon wrapper */
.sb-item-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.sb-item-icon svg {
    width: 16px; height: 16px;
    opacity: 0.65;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.sb-item:hover .sb-item-icon,
.sb-item.active .sb-item-icon {
    background: rgba(96,165,250,0.18);
}
.sb-item:hover .sb-item-icon svg,
.sb-item.active .sb-item-icon svg { opacity: 1; }
.sb-item-label { flex: 1; min-width: 0; }

/* Chevron */
.sb-chevron {
    width: 13px; height: 13px;
    flex-shrink: 0;
    opacity: 0.35;
    transition: transform 0.22s, opacity 0.15s;
}
.sb-group.open > .sb-item .sb-chevron { transform: rotate(90deg); opacity: 0.8; }
.sb-group.open > .sb-item { color: var(--sb-text-active); }
.sb-group.open > .sb-item .sb-item-icon { background: rgba(96,165,250,0.15); }
.sb-group.open > .sb-item .sb-item-icon svg { opacity: 1; }

/* Submenu */
.sb-submenu {
    overflow: hidden;
    max-height: 0;
    margin: 0 0 1px 0;
    transition: max-height 0.3s cubic-bezier(0.4,0,0.2,1);
}
.sb-group.open .sb-submenu { max-height: 600px; }

.sb-sub-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.875rem 0.5rem 1rem;
    margin-left: 1rem;
    border-left: 1px solid rgba(255,255,255,0.08);
    color: var(--sb-text);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 400;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.sb-sub-item:hover {
    color: var(--sb-text-active);
    border-color: rgba(96,165,250,0.5);
    text-decoration: none;
}
.sb-sub-item.active {
    color: var(--sb-text-active);
    font-weight: 600;
    border-color: var(--sb-accent);
}
/* Small icon per sub-item */
.sb-sub-icon {
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.sb-sub-icon svg { width: 13px; height: 13px; }
.sb-sub-item:hover .sb-sub-icon,
.sb-sub-item.active .sb-sub-icon { opacity: 1; }

/* ══ FOOTER — user card + signout ══ */
.sb-footer {
    flex-shrink: 0;
    border-top: 1px solid rgba(255,255,255,0.07);
    background: rgba(0,0,0,0.18);
    padding: 1rem 1rem 0.875rem;
}
.sb-user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sb-user-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #1a3d73 100%);
    box-shadow: 0 3px 10px rgba(37,99,235,0.35), 0 0 0 2px rgba(255,255,255,0.1);
    color: #fff;
    font-size: 1.0625rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: -0.02em;
    overflow: hidden;
}
.sb-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name {
    font-size: 0.875rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.sb-user-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 3px;
    flex-wrap: wrap;
}
.sb-user-role-pill {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--sb-accent);
    background: rgba(96,165,250,0.14);
    border: 1px solid rgba(96,165,250,0.22);
    border-radius: 20px;
    padding: 1px 7px;
    white-space: nowrap;
}
.sb-credits-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: rgba(180,210,255,0.65);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s;
}
.sb-credits-link:hover { color: #fff; text-decoration: none; }
.sb-signout-form { width: 100%; margin: 0; }
.sb-signout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 9px;
    color: rgba(180,210,255,0.6);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    letter-spacing: 0.01em;
}
.sb-signout-btn:hover {
    background: rgba(239,68,68,0.16);
    border-color: rgba(239,68,68,0.28);
    color: #fca5a5;
}

/* ── Content area ── */
.app-content {
    margin-left: var(--sb-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Topbar */
.app-topbar {
    background: #fff;
    border-bottom: 1px solid #e8edf4;
    padding: 0 1.5rem;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    flex-shrink: 0;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    min-width: 0;
    flex: 1;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
/* Hamburger — hidden on desktop */
.sb-toggle-btn {
    display: none;
    width: 36px; height: 36px;
    border: none;
    background: transparent;
    color: #475569;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}
.sb-toggle-btn:hover { background: #f1f5f9; }
.topbar-page-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-credits {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    padding: 0.275rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #1a3d73;
    text-decoration: none;
    transition: background 0.15s;
}
.topbar-credits:hover { background: #dbeafe; color: #1a3d73; }

/* Mobile overlay */
.sb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.42);
    z-index: 1039;
    backdrop-filter: blur(1px);
}
body.sb-open .sb-overlay { display: block; }

/* ── Responsive ── */
@media (max-width: 1023px) {
    .app-sidebar { transform: translateX(calc(-1 * var(--sb-width))); }
    body.sb-open .app-sidebar {
        transform: translateX(0);
        box-shadow: 6px 0 32px rgba(0,0,0,0.22);
    }
    .app-content { margin-left: 0; }
    .sb-toggle-btn { display: flex; }
    .app-topbar { padding: 0 1rem; }
}
@media (max-width: 767px) {
    .app-main { padding: 1rem; }
    .topbar-page-title { font-size: 0.9375rem; }
}
/* Guest layout wrapper (no sidebar) */
.app-guest-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
/* END SIDEBAR */