*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --icon-color: #05435c;
    --brand: #187c4a;
    --brand-dark: #125a38;
    --brand-light: #e8f4ed;
    --teal: var(--brand);
    --teal-dark: var(--brand-dark);
    --teal-light: var(--brand-light);
    --green: var(--brand);
    --gold: #c9a227;
    --gold-bg: #3d3520;
    --green-bg: #1a3d2e;
    --blue-bg: #1a2d4d;
    --red-bg: #3d1f28;
    --red: #e05a6a;
    --bg: #f4f7f7;
    --surface: #ffffff;
    --text: #05435c;
    --text-muted: #4a7285;
    --border: #c5d8e0;
    --radius: 14px;
    --header-gradient: url('../img/header-gradient.png');
    --shadow: 0 4px 24px rgba(5, 67, 92, 0.08);
    --layout-pad-x: clamp(1rem, 2.5vw, 2rem);
    --layout-pad-y: clamp(1rem, 1.75vw, 1.5rem);
    --layout-gap: clamp(0.85rem, 1.25vw, 1.25rem);
    --topnav-height: 4.25rem;
}

body {
    font-family: "Alexandria", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.7;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

a {
    color: var(--brand);
    text-decoration: none;
}

/* Nav */
.topnav {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: 0.85rem var(--layout-pad-x);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
    overflow: visible;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: inherit;
    flex-shrink: 0;
}

.brand-logo {
    height: 52px;
    width: auto;
    max-width: 240px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.brand-text strong {
    font-size: 0.95rem;
    font-weight: 700;
}

.brand-text small {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
}

.nav-links {
    display: flex;
    flex: 1;
    justify-content: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.topnav-side {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    margin-inline-start: auto;
}

.nav-user-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--icon-color);
    color: var(--text-muted);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: all 0.2s;
}

.nav-user-btn:hover,
.nav-user-btn.active {
    color: var(--teal);
    background: var(--teal-light);
    border-color: var(--teal-light);
}

.nav-user-icon {
    width: 20px;
    height: 20px;
    display: block;
}

.nav-user-menu {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.45rem;
}

.nav-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
}

.nav-user-btn--menu {
    cursor: pointer;
    flex-shrink: 0;
}

.nav-user-dropdown {
    position: absolute;
    top: calc(100% + 0.45rem);
    inset-inline-end: 0;
    inset-inline-start: auto;
    width: max-content;
    min-width: 11rem;
    max-width: min(14rem, calc(100vw - 1.5rem));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.35rem;
    z-index: 120;
}

.nav-user-dropdown-link {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-user-dropdown-link:hover {
    background: var(--teal-light);
    color: var(--teal-dark);
}

.nav-user-dropdown-logout {
    color: #b42318;
}

.nav-user-dropdown-logout:hover {
    background: #fef3f2;
    color: #912018;
}

.nav-user-dropdown-form {
    margin: 0;
}

.nav-user-dropdown--flip {
    inset-inline-end: auto;
    inset-inline-start: 0;
}

@media (max-width: 768px) {
    .nav-user-name {
        max-width: min(9rem, 38vw);
    }

    .nav-user-dropdown {
        min-width: 10rem;
        max-width: calc(100vw - 1.7rem);
    }
}

.nav-link {
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--teal);
    background: var(--teal-light);
}

.nav-link.active {
    background: var(--teal-light);
    color: var(--text);
    font-weight: 600;
}

.page-main {
    flex: 1 0 auto;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: var(--layout-pad-y) var(--layout-pad-x);
}

.page-main.page-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100dvh - var(--topnav-height) - 4rem);
}

.site-footer {
    width: 100%;
    text-align: center;
    padding: 1.25rem var(--layout-pad-x);
    font-size: 0.78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.site-footer a {
    color: var(--teal);
}

.site-footer-line {
    margin: 0;
    line-height: 1.6;
}

.site-footer-sep {
    margin: 0 0.35rem;
    color: var(--border);
    user-select: none;
}

.site-footer-version {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--teal);
    color: white;
}

.btn-primary:hover {
    background: var(--teal-dark);
}

.btn-outline {
    background: white;
    color: var(--teal);
    border-color: var(--teal);
}

.btn-outline:hover {
    background: var(--teal-light);
}

.btn-block {
    width: 100%;
}

/* Hero */
.hero {
    text-align: center;
    padding: 2.5rem 1rem 2rem;
    background: var(--surface);
    border-radius: calc(var(--radius) + 4px);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.page-hero.compact {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.page-hero h1,
.hero h1 {
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 800;
    color: var(--text);
    margin: 0.75rem 0 0.5rem;
}

.hero-desc,
.page-hero p {
    color: var(--text-muted);
    max-width: 560px;
    margin: 0 auto 1.25rem;
    font-size: 0.92rem;
}

.pill-badge {
    display: inline-block;
    padding: 0.3rem 0.85rem;
    background: var(--teal-light);
    color: var(--text);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.hero .stats-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 1rem;
    max-width: 100%;
}

.hero .stats-row .stat-card {
    flex: 0 1 160px;
    min-width: 140px;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    max-width: 520px;
    margin: 0 auto;
}

.stat-card {
    text-align: center;
}

.stat-card strong {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--teal);
    line-height: 1.2;
}

.stat-card span {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Sections */
.section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.section-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.section-head h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.section-icon {
    display: inline-flex;
    align-items: center;
    color: var(--icon-color);
}

.ui-icon {
    color: var(--icon-color);
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

.cat-icon,
.entity-icon,
.stage-icon,
.dash-stat-icon,
.empty-state-icon,
.alert-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-color);
}

.category-card .cat-icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
}

.entity-header .entity-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 10px;
    background: var(--brand-light);
    flex-shrink: 0;
}

.alert-info {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
}

.alert-info-icon {
    margin-top: 0.1rem;
}

.detail-msg-role {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.chat-history-toggle,
.sidebar-close-btn {
    color: var(--icon-color);
}

.user-message .avatar {
    background: var(--brand-light);
    border-color: var(--brand);
}

.user-message .avatar .ui-icon {
    color: var(--icon-color);
}

.empty-state-icon {
    margin-bottom: 0.5rem;
}

/* Categories */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 0.85rem;
}

.category-card {
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
    color: white;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.category-card p {
    font-size: 0.72rem;
    opacity: 0.85;
    line-height: 1.5;
}

.cat-gold { background: linear-gradient(145deg, #4a4020, var(--gold-bg)); }
.cat-green { background: linear-gradient(145deg, #1f5038, var(--green-bg)); }
.cat-blue { background: linear-gradient(145deg, #1e3a6e, var(--blue-bg)); }
.cat-red { background: linear-gradient(145deg, #5a2030, var(--red-bg)); }

.cat-icon {
    margin-bottom: 0.15rem;
}

.category-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

a.category-card {
    color: white;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

a.category-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(5, 67, 92, 0.22);
}

/* Home page */
.home-hero {
    background: linear-gradient(160deg, #ffffff 0%, #f3faf6 52%, #e8f4ed 100%);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 6px);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.home-hero-grid {
    display: block;
    padding: 2.25rem 2rem 1.75rem;
}

.home-hero-copy {
    text-align: center;
    max-width: 52rem;
    margin: 0 auto;
}

.home-hero-copy h1 {
    font-size: clamp(1.55rem, 3.5vw, 2.15rem);
    font-weight: 800;
    color: var(--text);
    line-height: 1.35;
    margin: 0.85rem 0 0.65rem;
}

.home-hero-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.75;
    max-width: 34rem;
    margin: 0 auto 0.65rem;
}

.home-hero-tagline {
    color: var(--brand);
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.65;
    max-width: 32rem;
    margin: 0 auto 1.25rem;
}

.home-hero-actions {
    justify-content: center;
    margin-bottom: 0.85rem;
}

.home-hero-note {
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 32rem;
    margin: 0 auto;
    opacity: 0.92;
}

.pill-badge-brand {
    background: rgba(24, 124, 74, 0.12);
    color: var(--brand-dark);
    border: 1px solid rgba(24, 124, 74, 0.18);
}

.home-hero-visual {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
}

.home-hero-visual-ring {
    position: absolute;
    width: min(240px, 72vw);
    height: min(240px, 72vw);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(24, 124, 74, 0.14) 0%, rgba(24, 124, 74, 0) 70%);
    border: 1px solid rgba(24, 124, 74, 0.12);
}

.home-hero-avatar {
    position: relative;
    width: min(168px, 42vw);
    height: auto;
    border-radius: 50%;
    box-shadow: 0 16px 40px rgba(5, 67, 92, 0.16);
    border: 4px solid #fff;
    object-fit: cover;
}

.home-stats-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.72);
}

.home-stat-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 1rem 0.85rem;
    text-align: center;
}

.home-stat-item + .home-stat-item {
    border-right: 1px solid var(--border);
}

.home-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--teal-light);
    color: var(--icon-color);
    flex-shrink: 0;
}

.home-stat-item strong {
    display: block;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--teal);
    line-height: 1.2;
}

.home-stat-item span {
    display: block;
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.home-section-head {
    align-items: flex-start;
    margin-bottom: 1.35rem;
}

.section-head-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-subtitle {
    margin: 0.35rem 0 0;
    font-size: 0.84rem;
    color: var(--text-muted);
    line-height: 1.65;
}

.home-categories-grid {
    gap: 1rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.home-category-card {
    position: relative;
    min-height: 148px;
    padding-bottom: 2rem;
}

.home-category-link {
    position: absolute;
    bottom: 0.85rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.72rem;
    font-weight: 700;
    opacity: 0.9;
    letter-spacing: 0.01em;
}

.home-steps {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
    margin: 0;
    padding: 0;
}

.home-step {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-soft, #f7faf9);
}

.home-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--teal-light);
    color: var(--brand-dark);
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.home-step h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.home-step p {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
}

.home-cta-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.35rem 1.5rem;
    margin-bottom: 0.5rem;
    border-radius: calc(var(--radius) + 2px);
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%);
    color: #fff;
    box-shadow: var(--shadow);
}

.home-cta-copy h2 {
    font-size: 1.05rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.home-cta-copy p {
    font-size: 0.82rem;
    opacity: 0.92;
    margin: 0;
}

.home-cta-btn {
    background: #fff;
    color: var(--brand-dark);
    border-color: #fff;
    white-space: nowrap;
}

.home-cta-btn:hover {
    background: var(--teal-light);
    border-color: var(--teal-light);
}

.btn-lg {
    padding: 0.75rem 1.45rem;
    font-size: 0.95rem;
}

/* Architecture */
.architecture-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.arch-layer {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.15rem;
    border-radius: var(--radius);
    background: linear-gradient(
        90deg,
        hsl(calc(175 - var(--i) * 8), 60%, calc(42% - var(--i) * 4%)),
        hsl(calc(175 - var(--i) * 8), 55%, calc(32% - var(--i) * 3%))
    );
    color: white;
    font-weight: 600;
    font-size: 0.88rem;
}

.arch-num {
    font-size: 0.82rem;
    opacity: 0.85;
    min-width: 2rem;
}

/* Compliance */
.compliance-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.compliance-card {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid;
}

.compliance-card.deny {
    background: rgba(224, 90, 106, 0.08);
    border-color: rgba(224, 90, 106, 0.35);
    color: #9b2030;
}

.compliance-card.allow {
    background: rgba(24, 124, 74, 0.08);
    border-color: rgba(24, 124, 74, 0.35);
    color: var(--brand);
}

.disclaimer-inline {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
}

/* Services page */
.service-category {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.category-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.85rem 1.25rem;
    background: var(--teal);
    color: white;
}

.category-header h2 {
    font-size: 1rem;
    font-weight: 700;
}

.cat-head-icon {
    font-size: 1.25rem;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
    padding: 1rem;
}

.tool-chip {
    display: block;
    padding: 0.55rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.78rem;
    color: var(--text);
    transition: all 0.2s;
}

.tool-chip::before {
    content: "• ";
    color: var(--teal);
    font-weight: 700;
}

.tool-chip:hover {
    border-color: var(--teal);
    background: var(--teal-light);
    color: var(--text);
}

/* Entities */
.alert-info {
    padding: 0.85rem 1.15rem;
    background: #fff8e6;
    border: 1px solid #f0d080;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: #7a5c00;
    margin-bottom: 1.25rem;
}

.entities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: var(--layout-gap);
}

.entity-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.entity-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.15rem;
    background: var(--teal);
    color: white;
}

.entity-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.entity-header small {
    font-size: 0.72rem;
    opacity: 0.85;
}

.entity-body {
    padding: 1.15rem;
}

.entity-body p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.85rem;
}

.entity-body h4 {
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.entity-body ul {
    list-style: none;
    margin-bottom: 1rem;
}

.entity-body li {
    font-size: 0.82rem;
    padding: 0.25rem 0;
    padding-right: 1.25rem;
    position: relative;
}

.entity-body li::before {
    content: "✓";
    position: absolute;
    right: 0;
    color: var(--teal);
    font-weight: 700;
}

.entity-link {
    font-size: 0.82rem;
    font-weight: 600;
}

/* Dashboard layout shell */
.dash-layout {
    display: flex;
    flex-direction: column;
    gap: var(--layout-gap);
    width: 100%;
}

.dash-layout-head {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(320px, 2fr);
    gap: var(--layout-gap);
    align-items: stretch;
}

.dash-layout-head .page-hero.compact,
.dash-layout-head .dash-quick-actions-card {
    margin-bottom: 0;
    height: 100%;
}

.dash-layout-head .dash-quick-actions-card h2 {
    margin-bottom: 0.75rem;
}

.dash-layout-split {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(0, 1.65fr);
    gap: var(--layout-gap);
    align-items: start;
}

.dash-layout-split > .dash-card {
    margin-bottom: 0;
}

.page-dashboard .page-hero.compact,
.page-dashboard .dash-card {
    margin-bottom: 0;
}

.page-dashboard .kpi-section,
.page-dashboard .dash-filter-card,
.page-dashboard .dash-quick-actions-card,
.page-dashboard .dashboard-stats {
    margin-bottom: 0;
}

.dashboard-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.dash-icon {
    width: 48px;
    height: 48px;
    background: var(--teal);
    color: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1rem;
    max-width: none;
    width: 100%;
    margin: 0 0 0;
}

.dash-stat {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: start;
}

.dash-stat strong {
    display: block;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--teal);
    line-height: 1.2;
}

.dash-stat span {
    display: block;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--text-muted);
}

.dash-stat-icon {
    width: 44px;
    height: 44px;
    background: var(--teal-light);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
}

.dashboard-grid-single {
    grid-template-columns: 1fr;
}

.dash-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.dash-card h2 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
}

.dash-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.dash-card-head h2 {
    margin-bottom: 0;
}

.view-all-link {
    font-size: 0.82rem;
    font-weight: 600;
}

.dash-meta {
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: -0.5rem 0 1.25rem;
}

.engine-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

.engine-on {
    background: var(--green-light);
    color: var(--green-dark);
}

.engine-off {
    background: #fff3cd;
    color: #856404;
}

.conv-table-wrap {
    overflow-x: auto;
}

.conv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.conv-table th,
.conv-table td {
    padding: 0.65rem 0.75rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.conv-table th {
    font-weight: 700;
    color: var(--text);
    background: var(--bg);
}

.conv-table tr:hover td {
    background: var(--teal-light);
}

.table-link {
    font-weight: 600;
    font-size: 0.78rem;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.table-inline-form {
    display: inline;
    margin: 0;
}

.activity-log-meta {
    display: inline-block;
    max-width: 16rem;
    font-size: 0.72rem;
    line-height: 1.4;
    word-break: break-word;
    white-space: normal;
    color: var(--text-muted, #64748b);
}

.table-link-danger {
    color: #c62828;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    cursor: pointer;
}

.table-link-danger:hover {
    color: #9b1c1c;
    text-decoration: underline;
}

.stage-pill {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: var(--teal-light);
    color: var(--text);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

.back-link {
    margin-top: 1rem;
    font-size: 0.85rem;
}

.compact-stats {
    margin-bottom: 1.25rem;
}

.kpi-section {
    margin-bottom: 1.25rem;
}

.kpi-stats {
    margin-bottom: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    max-width: none;
}

.kpi-card strong {
    font-size: 1.35rem;
}

.kpi-hint {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.kpi-meta {
    margin-top: 0.5rem;
    margin-bottom: 0;
}

.dash-filter-card {
    margin-bottom: 1.25rem;
}

.dash-quick-actions-card {
    margin-bottom: 1.25rem;
}

.dash-filter-form h2 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

.dash-filter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.dash-filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
    margin-bottom: 0.85rem;
}

.dash-filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.dash-filter-field input,
.dash-filter-field select {
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 8px);
    font-family: inherit;
    font-size: 0.85rem;
    background: var(--bg);
    color: var(--text);
}

.dash-filter-field input:focus,
.dash-filter-field select:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 2px rgba(24, 124, 74, 0.12);
}

.dash-filter-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.dash-filter-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
}

.users-search-form {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.users-search-grid {
    grid-template-columns: minmax(0, 1fr);
}

.dash-filter-badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--green-light);
    color: var(--green-dark);
}

.dash-filter-badge.sm {
    font-size: 0.72rem;
}

.top-questions-card {
    margin-bottom: 1.25rem;
}

.top-questions-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.top-question-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 8px);
    background: var(--bg);
}

.top-question-rank {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--green);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
}

.top-question-body p {
    margin: 0 0 0.25rem;
    font-size: 0.85rem;
    line-height: 1.5;
}

.top-question-body small {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.top-questions-meta {
    margin: 0 0 0.75rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.top-questions-pagination {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pagination-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.pagination-page,
.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 8px);
    font-size: 0.82rem;
    color: var(--text);
    text-decoration: none;
    background: var(--surface, #fff);
}

.pagination-page.active {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
    font-weight: 600;
}

.pagination-btn:hover,
.pagination-page:hover:not(.active) {
    border-color: var(--green);
    color: var(--green);
}

.empty-state.compact {
    padding: 1rem 0;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
}

.rating-stars-display {
    display: inline-flex;
    gap: 0.1rem;
    color: #ccc;
}

.rating-stars-display .rating-star.filled {
    color: #c9a227;
}

.rating-stars-md .rating-star {
    font-size: 1.1rem;
}

.rating-stars-sm .rating-star {
    font-size: 0.95rem;
}

.rating-stars-empty {
    color: var(--text-muted);
}

.detail-rating {
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.detail-rating-comment {
    font-size: 0.88rem;
    color: var(--text-muted);
    font-style: italic;
}

.detail-rating-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.conversation-rating {
    margin: 0 1.15rem 0.65rem;
    padding: 0.85rem 1rem;
    background: var(--brand-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.conversation-rating.hidden {
    display: none;
}

.rating-prompt {
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.rating-stars-input {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.rating-star-btn {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: #ccc;
    cursor: pointer;
    padding: 0.1rem;
    font-family: inherit;
    transition: color 0.15s, transform 0.15s;
}

.rating-star-btn:hover,
.rating-star-btn.active {
    color: #c9a227;
    transform: scale(1.08);
}

.rating-comment {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.82rem;
    resize: vertical;
    margin-bottom: 0.5rem;
}

.rating-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.rating-thanks {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--brand);
    margin: 0;
}

.rating-thanks.hidden {
    display: none;
}

.conversation-pdf-offer {
    margin: 0 1.15rem 0.65rem;
    padding: 0.85rem 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.conversation-pdf-offer.hidden {
    display: none;
}

.pdf-offer-prompt {
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.pdf-offer-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pdf-offer-status {
    font-size: 0.82rem;
    margin: 0.5rem 0 0;
    color: var(--text-muted);
}

.pdf-offer-status.hidden {
    display: none;
}

.pdf-offer-status.error {
    color: #b42318;
}

.export-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--layout-gap);
    margin: 1rem 0 0;
}

@media (min-width: 1200px) {
    .charts-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .chart-card-wide {
        grid-column: 1 / -1;
    }

    .chart-wrap {
        height: 240px;
    }
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.chart-card-wide {
    grid-column: 1 / -1;
}

.chart-card h3 {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.75rem;
}

.chart-wrap {
    position: relative;
    height: 220px;
}

.chart-wrap-pie {
    height: 260px;
}

.kpi-mini {
    margin-bottom: 0.5rem;
}

.satisfaction-gauge {
    padding: 0.5rem 0;
}

.satisfaction-gauge-track {
    height: 22px;
    background: #e8f5ee;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.satisfaction-gauge-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #187c4a, #05435c);
    border-radius: 999px;
    transition: width 0.8s ease;
}

.satisfaction-gauge-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.satisfaction-gauge-meta strong {
    font-size: 1.5rem;
    color: var(--brand);
}

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .chart-card-wide {
        grid-column: auto;
    }
}

.ratings-count-badge {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-right: 0.25rem;
}

.ratings-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ratings-list-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
}

.ratings-list-item:last-child {
    border-bottom: none;
}

.ratings-list-item time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-right: auto;
}

.archived-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.detail-messages {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.detail-msg {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.detail-msg-user {
    background: var(--teal-light);
    border-color: rgba(24, 124, 74, 0.2);
}

.detail-msg-bot {
    background: var(--bg);
}

.detail-msg-role {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.detail-msg-body {
    font-size: 0.88rem;
    line-height: 1.7;
}

.detail-msg time {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.chat-history .hist-title {
    display: block;
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history .hist-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.chat-history li.empty-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: default;
}

.chat-history li:not(.empty-hint):hover {
    background: var(--teal-light);
}


.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.empty-state span {
    font-size: 2.5rem;
    opacity: 0.35;
    display: block;
    margin-bottom: 0.5rem;
}

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dash-quick-actions-card h2 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 0.85rem;
    color: var(--text);
}

.quick-actions-row {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.logout-form {
    margin: 0;
    width: 100%;
}

/* Chat layout */
.chat-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1rem;
    min-height: calc(100vh - 180px);
}

.chat-sidebar {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    height: fit-content;
}

.chat-sidebar-head {
    display: none;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

.sidebar-close-btn {
    border: none;
    background: var(--bg);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.chat-history-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    cursor: pointer;
    flex-shrink: 0;
}

.chat-sidebar-overlay {
    display: none;
}

body.sidebar-open {
    overflow: hidden;
}

.sidebar-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    margin: 1rem 0 0.5rem;
}

.chat-history {
    list-style: none;
}

.chat-history li {
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
}

.chat-history li.active {
    background: var(--teal-light);
    color: var(--text);
    font-weight: 600;
}

.chat-panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-panel-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    background: #05435c var(--header-gradient) center / cover no-repeat;
    color: white;
}

.chat-head-logo {
    height: 72px;
    width: auto;
    max-width: min(320px, 60vw);
    object-fit: contain;
    flex-shrink: 0;
}

.chat-head-text strong {
    display: block;
    font-size: 0.92rem;
}

.chat-head-text small {
    font-size: 0.72rem;
    opacity: 0.7;
}

.ai-disclaimer-banner {
    padding: 0.5rem 1rem;
    background: #fff8e6;
    border-bottom: 1px solid #f0d080;
    font-size: 0.76rem;
    color: #7a5c00;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 260px;
    max-height: 380px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-message {
    flex-direction: row-reverse;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #0d0d0d;
    border: 2px solid var(--brand);
    overflow: hidden;
    font-size: 0.9rem;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 3px;
}

.user-message .avatar {
    background: var(--brand-light);
    border-color: var(--brand);
}

.bubble {
    max-width: 78%;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
}

.bot-message .bubble {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
}

.user-message .bubble {
    background: var(--brand);
    color: #ffffff;
}

.topic-badge {
    display: inline-block;
    background: var(--brand-light);
    color: var(--brand-dark);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    margin-bottom: 0.4rem;
}

.topic-badge.out-of-scope {
    background: #fde8e8;
    color: #9b1c1c;
}

.bot-message .bubble a,
.bot-message .bubble strong {
    color: var(--brand);
}

.bot-message .bubble a {
    font-weight: 600;
    text-decoration: underline;
}

.stage-section {
    padding: 0.75rem 1.15rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.stage-section h4 {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stage-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.stage-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.65rem 0.35rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: white;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
}

.stage-btn:hover {
    border-color: var(--teal);
}

.stage-btn.active {
    border-color: var(--teal);
    background: var(--teal-light);
    color: var(--text);
}

.stage-btn.stage-red.active {
    border-color: var(--red);
    background: rgba(224, 90, 106, 0.12);
    color: #9b2030;
}

.stage-btn.stage-gold.active {
    border-color: var(--gold);
    background: rgba(201, 162, 39, 0.12);
    color: #7a5c00;
}

.stage-icon {
    font-size: 1.25rem;
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.65rem 1.15rem;
}

.suggestion-btn {
    background: white;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-family: inherit;
    font-size: 0.76rem;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-btn:hover {
    background: var(--teal-light);
    border-color: var(--teal);
}

.input-area {
    display: flex;
    gap: 0.5rem;
    padding: 0.85rem 1.15rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.input-area input[type="text"] {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
}

.input-area input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-light);
}

.input-area button {
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 50%;
    background: var(--teal);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    order: -1;
}

.input-area button:hover {
    background: var(--teal-dark);
}

.input-area button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.typing .bubble {
    display: flex;
    gap: 4px;
    padding: 1rem;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--teal);
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* Responsive */
@media (max-width: 1100px) {
    .dash-layout-head,
    .dash-layout-split {
        grid-template-columns: 1fr;
    }

    .home-categories-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .entities-grid,
    .dash-filter-grid {
        grid-template-columns: 1fr;
    }

    .chat-layout {
        grid-template-columns: 1fr;
        min-height: calc(100dvh - 110px);
    }

    .page-main.page-chat {
        padding: 0;
        max-width: none;
    }

    .page-main.page-chat + .site-footer {
        display: none;
    }

    .chat-panel {
        border-radius: 0;
        min-height: calc(100dvh - 110px);
    }

    .chat-panel-head {
        padding: 0.65rem 0.85rem;
        gap: 0.65rem;
    }

    .chat-head-logo {
        height: 44px;
        max-width: min(200px, 45vw);
    }

    .chat-head-text strong {
        font-size: 0.82rem;
    }

    .chat-history-toggle {
        display: inline-flex;
    }

    .chat-sidebar-head {
        display: flex;
    }

    .chat-sidebar {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        width: min(300px, 88vw);
        height: 100dvh;
        z-index: 300;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        border-radius: 0;
        overflow-y: auto;
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .chat-sidebar.open {
        transform: translateX(0);
    }

    .chat-sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 299;
    }

    .chat-sidebar-overlay.open {
        display: block;
    }

    .messages {
        flex: 1;
        min-height: 0;
        max-height: none;
    }

    .stage-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bubble {
        max-width: 88%;
    }
}

@media (max-width: 768px) {
    .topnav {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "brand side"
            "links links";
        align-items: center;
        gap: 0.45rem 0.65rem;
        padding: 0.65rem 0.85rem;
    }

    .brand {
        grid-area: brand;
        min-width: 0;
    }

    .topnav-side {
        grid-area: side;
        margin-inline-start: 0;
    }

    .nav-links {
        grid-area: links;
        flex: none;
        width: 100%;
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.25rem;
        padding-bottom: 0.1rem;
    }

    .nav-links::-webkit-scrollbar {
        display: none;
    }

    .nav-link {
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 0.8rem;
        padding: 0.4rem 0.7rem;
    }

    .brand-logo {
        height: 38px;
        max-width: 130px;
    }

    .brand-text strong {
        font-size: 0.82rem;
    }

    .brand-text small {
        font-size: 0.65rem;
    }

    .page-main {
        padding: 1rem 0.85rem 1.5rem;
    }

    .hero {
        padding: 1.75rem 0.85rem 1.5rem;
        border-radius: var(--radius);
    }

    .page-hero.compact {
        padding: 1.5rem 0.85rem;
    }

    .section {
        padding: 1.15rem;
    }

    .hero-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-actions .btn {
        width: 100%;
    }

    .home-hero-grid {
        grid-template-columns: 1fr;
        padding: 1.5rem 1rem 1.15rem;
        text-align: center;
    }

    .home-hero-copy {
        text-align: center;
    }

    .home-hero-desc,
    .home-hero-tagline,
    .home-hero-note {
        margin-left: auto;
        margin-right: auto;
    }

    .home-hero-actions {
        justify-content: center;
    }

    .home-hero-visual {
        min-height: 180px;
        order: -1;
    }

    .home-stats-strip {
        grid-template-columns: 1fr;
    }

    .home-categories-grid {
        grid-template-columns: 1fr;
    }

    .home-stat-item + .home-stat-item {
        border-right: none;
        border-top: 1px solid var(--border);
    }

    .home-steps {
        grid-template-columns: 1fr;
    }

    .home-cta-band {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .home-cta-btn {
        width: 100%;
    }

    .hero .stats-row {
        gap: 0.75rem;
    }

    .hero .stats-row .stat-card {
        flex: 1 1 calc(50% - 0.75rem);
        min-width: 120px;
        max-width: 180px;
    }

    .stats-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.65rem;
    }

    .stat-card strong {
        font-size: 1.35rem;
    }

    .categories-grid,
    .compliance-grid,
    .entities-grid {
        grid-template-columns: 1fr;
    }

    .tools-grid {
        grid-template-columns: 1fr;
    }

    .category-card {
        min-height: auto;
        padding: 1rem;
    }

    .arch-layer {
        font-size: 0.8rem;
        padding: 0.75rem 0.85rem;
        gap: 0.65rem;
    }

    .dash-card {
        padding: 1rem;
    }

    .dash-card-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .conv-table {
        font-size: 0.75rem;
        min-width: 520px;
    }

    .suggestions {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-inline: 0.85rem;
    }

    .suggestions::-webkit-scrollbar {
        display: none;
    }

    .suggestion-btn {
        flex-shrink: 0;
        max-width: 85vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .input-area {
        padding: 0.65rem 0.85rem;
        padding-bottom: max(0.65rem, env(safe-area-inset-bottom));
    }

    .input-area input[type="text"] {
        font-size: 16px;
    }

    .ai-disclaimer-banner {
        font-size: 0.72rem;
        padding: 0.45rem 0.85rem;
    }

    .stage-section {
        padding: 0.65rem 0.85rem;
    }

    .stage-btn {
        font-size: 0.7rem;
        padding: 0.55rem 0.25rem;
    }

    .site-footer {
        padding: 1rem 0.85rem;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        font-size: 0.72rem;
    }
}

@media (max-width: 640px) {
    .brand-text small {
        display: none;
    }

    .stats-row:not(.dashboard-stats) {
        grid-template-columns: 1fr 1fr;
    }

    .dashboard-stats {
        grid-template-columns: repeat(5, minmax(9.5rem, 1fr));
        overflow-x: auto;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
    }

    .dash-stat {
        min-width: 9.5rem;
    }

    .stage-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 400px) {
    .brand-text {
        display: none;
    }

    .stats-row:not(.dashboard-stats) {
        grid-template-columns: 1fr;
    }

    .stage-grid {
        grid-template-columns: 1fr 1fr;
    }

    .chat-head-text small {
        display: none;
    }
}

/* Admin login */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50vh;
    padding: 1rem 0;
}

.login-card {
    width: min(420px, 100%);
    background: var(--surface);
    border-radius: calc(var(--radius) + 2px);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.login-card-head {
    padding: 1.5rem 1.5rem 1rem;
    background: #05435c var(--header-gradient) center / cover no-repeat;
    color: white;
}

.login-card-head h1 {
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
}

.login-card-head p {
    font-size: 0.85rem;
    opacity: 0.85;
}

.login-error {
    margin: 1rem 1.5rem 0;
    padding: 0.65rem 0.85rem;
    background: #fde8ea;
    color: #9b1c2e;
    border-radius: 10px;
    font-size: 0.85rem;
}

.login-form {
    padding: 1.25rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.login-field span {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
}

.login-field input,
.login-input {
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    width: 100%;
}

.login-field input:focus,
.login-input:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(24, 124, 74, 0.12);
}

.field-error {
    font-size: 0.78rem;
    color: #9b1c2e;
}

.field-hint,
.login-field ul {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
    padding-right: 1rem;
    list-style: disc;
}

.login-success {
    margin: 1rem 1.5rem 0;
    padding: 0.65rem 0.85rem;
    background: #e6f7ef;
    color: var(--brand);
    border-radius: 10px;
    font-size: 0.85rem;
}

.login-submit {
    margin-top: 0.25rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--radius);
    background: var(--teal);
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
}

.login-submit:hover {
    background: var(--teal-dark);
}

.login-back {
    padding: 0 1.5rem 1.25rem;
    font-size: 0.82rem;
}

.login-back a {
    color: var(--teal);
    font-weight: 600;
}

.page-alert {
    max-width: 960px;
    margin: 0 auto 1rem;
}

.user-form-page .login-card {
    max-width: 480px;
}

.user-delete-form {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
}

.checkbox-field {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-field input[type="checkbox"] {
    width: auto;
}

.inactive-badge {
    background: #fde8ea;
    color: #9b1c2e;
}

.content-section {
    margin-bottom: 1.25rem;
}

.content-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0 0 1.25rem;
}

.dash-staff-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0 0 1.25rem;
    padding: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.dash-staff-nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.dash-staff-nav-link:hover {
    background: rgba(0, 107, 63, 0.08);
    color: var(--green);
}

.dash-staff-nav-link.active {
    background: var(--green);
    color: #fff;
}

.content-tab {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.content-tab:hover {
    border-color: var(--green);
    color: var(--green);
}

.content-tab.active {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.content-field-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.content-json {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8rem;
    direction: ltr;
    text-align: left;
}

.content-hint {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.content-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
}

.content-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 8px);
    background: var(--bg);
    padding: 0.65rem 0.85rem;
}

.content-item summary {
    cursor: pointer;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
}

.content-item summary::-webkit-details-marker {
    display: none;
}

.content-item-title {
    flex: 1;
    font-size: 0.88rem;
    font-weight: 600;
}

.content-form {
    margin-top: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.content-textarea {
    min-height: 4rem;
    resize: vertical;
}

.content-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.compact-field {
    max-width: 8rem;
}

.content-form-actions {
    display: flex;
    gap: 0.5rem;
}

.content-delete-form {
    margin-top: 0.5rem;
}

.content-add-box {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
}

.content-add-box h3 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: var(--green);
}

.danger-btn {
    color: #9b1c2e;
    border-color: #f0c4c8;
}

.btn-danger {
    background: #c62828;
    color: #fff;
    border-color: #c62828;
}

.btn-danger:hover {
    background: #9b1c1c;
    border-color: #9b1c1c;
}

.btn-danger:disabled {
    background: #e0a0a0;
    border-color: #e0a0a0;
    cursor: not-allowed;
}

body.dash-modal-open {
    overflow: hidden;
}

.dash-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.dash-modal[hidden] {
    display: none !important;
}

.dash-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 40, 40, 0.55);
}

.dash-modal-dialog {
    position: relative;
    width: min(100%, 460px);
    background: var(--surface);
    border-radius: calc(var(--radius) + 2px);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.35rem;
    border: 1px solid var(--border);
}

.dash-modal-dialog h3 {
    margin: 0 0 0.75rem;
    color: var(--teal-dark);
    font-size: 1.05rem;
}

.dash-modal-warning {
    margin: 0 0 0.75rem;
    color: #9b1c1c;
    background: #fdecec;
    border: 1px solid #f5c2c7;
    border-radius: var(--radius);
    padding: 0.75rem;
    font-size: 0.88rem;
    line-height: 1.6;
}

.dash-modal-list,
.dash-modal-results {
    margin: 0 0 1rem;
    padding-right: 1.2rem;
    color: var(--text);
    font-size: 0.88rem;
    line-height: 1.7;
}

.dash-modal-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.88rem;
    color: var(--text);
    cursor: pointer;
}

.dash-modal-check input {
    margin-top: 0.2rem;
}

.dash-modal-error {
    margin: 0 0 0.75rem;
    color: #9b1c1c;
    font-size: 0.85rem;
}

.dash-modal-success {
    margin: 0 0 0.75rem;
    color: var(--green-dark);
    background: var(--green-light);
    border: 1px solid #b8e6cf;
    border-radius: var(--radius);
    padding: 0.75rem;
    font-size: 0.88rem;
}

.dash-modal-note {
    margin: 0 0 1rem;
    padding: 0.65rem 0.75rem;
    background: #eef5ff;
    border: 1px solid #c8daf5;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
    line-height: 1.6;
}

.dash-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* —— مساعد المحتوى —— */
.ca-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 420px;
}

.ca-messages {
    flex: 1;
    min-height: 280px;
    max-height: 52vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f6f9fb;
    border: 1px solid var(--border, #dce6ee);
    border-radius: var(--radius);
}

.ca-message {
    max-width: 92%;
}

.ca-message--user {
    align-self: flex-start;
}

.ca-message--assistant {
    align-self: flex-end;
}

.ca-message-body {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    line-height: 1.65;
    font-size: 0.92rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.ca-message--user .ca-message-body {
    background: var(--brand, #187c4a);
    color: #fff;
}

.ca-message--assistant .ca-message-body {
    background: var(--surface, #fff);
    border: 1px solid var(--border, #dce6ee);
    color: var(--text, #05435c);
}

.ca-form {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.ca-field {
    margin: 0;
}

.ca-input {
    min-height: 3.5rem;
    resize: vertical;
}

.ca-form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.ca-status {
    font-size: 0.82rem;
    color: #5a7285;
}

.ca-suggestions {
    border: 1px solid #c8daf5;
    background: #eef5ff;
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
}

.ca-suggestions.hidden {
    display: none;
}

.ca-suggestions-head {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text, #05435c);
}

.ca-suggestions-list {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.ca-suggestion-item {
    background: #fff;
    border: 1px solid var(--border, #dce6ee);
    border-radius: calc(var(--radius) - 2px);
    padding: 0.65rem 0.75rem;
}

.ca-suggestion-key {
    display: block;
    font-size: 0.78rem;
    color: #5a7285;
    margin: 0.15rem 0;
    direction: ltr;
    text-align: left;
}

.ca-suggestion-value {
    margin: 0;
    padding: 0.5rem;
    background: #f6f9fb;
    border-radius: 6px;
    font-size: 0.82rem;
    white-space: pre-wrap;
    word-break: break-word;
    direction: ltr;
    text-align: left;
}

.ca-suggestion-reason {
    margin: 0 0 0.35rem;
    font-size: 0.82rem;
    color: #5a7285;
}

.ca-apply-btn {
    margin-top: 0.25rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
