:root {
    --primary-color: #0284c7;
    --primary-hover: #0369a1;
    --primary-soft: rgba(2, 132, 199, 0.1);
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-sidebar: #94a3b8;
    --border-color: #e2e8f0;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-main: #0b0f19;
    --bg-card: #1e293b;
    --bg-sidebar: #020617;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --glass-bg: rgba(30, 41, 59, 0.85);
    --primary-soft: rgba(56, 189, 248, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Tajawal', sans-serif;
}

/* Global Custom Scrollbar */
html {
    scrollbar-width: thin;
    scrollbar-color: rgba(2, 132, 199, 0.45) var(--bg-main);
    scroll-behavior: smooth;
}

[data-theme="dark"] html {
    scrollbar-color: rgba(56, 189, 248, 0.45) #0b0f19;
}

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: rgba(2, 132, 199, 0.4);
    border-radius: 10px;
    border: 2px solid var(--bg-main);
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #0b0f19;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.35);
    border: 2px solid #0b0f19;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #38bdf8;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header Styles */
.top-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 65px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text-main);
}

.logo-accent {
    color: var(--primary-color);
    background: linear-gradient(135deg, #0284c7, #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--primary-soft);
    color: var(--primary-color);
}

/* Intelligent Search Bar */
.header-center {
    flex: 1;
    max-width: 600px;
    margin: 0 20px;
    position: relative;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    right: 14px;
    color: var(--text-muted);
}

#global-search-input {
    width: 100%;
    padding: 10px 42px 10px 42px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.9rem;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

#global-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.clear-btn {
    position: absolute;
    left: 14px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.95rem;
    padding: 4px 6px;
    border-radius: 50%;
    transition: var(--transition);
}

.clear-btn:hover {
    color: #ef4444;
}

/* Search Dropdown */
.search-dropdown {
    position: absolute;
    top: 110%;
    right: 0;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 420px;
    overflow-y: auto;
    z-index: 200;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.search-result-item:hover {
    background: var(--primary-soft);
}

.search-result-item .res-thumb {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: #f1f5f9;
}

.search-result-item .res-text {
    flex: 1;
    min-width: 0;
}

.search-result-item .res-title {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.95rem;
}

.search-result-item .res-category {
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    margin-right: 6px;
}

.search-result-item .res-snippet {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

.search-highlight {
    background: #fef08a;
    color: #854d0e;
    padding: 0 2px;
    border-radius: 2px;
}

/* Layout App */
.app-container {
    display: flex;
    min-height: calc(100vh - 65px);
    position: relative;
}

/* Sidebar Fixed & Styled */
.sidebar {
    position: sticky;
    top: 65px;
    height: calc(100vh - 65px);
    width: 290px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    padding: 16px 12px 24px 12px;
    transition: var(--transition);
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 80;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar.collapsed {
    margin-right: -290px;
}

.nav-group-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: #94a3b8;
    margin: 14px 10px 8px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    color: var(--text-sidebar);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    margin-bottom: 4px;
    transition: var(--transition);
    border: 1px solid transparent;
}

.nav-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: #94a3b8;
    transition: var(--transition);
}

.nav-link-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.nav-link-main {
    font-weight: 700;
    font-size: 0.88rem;
    line-height: 1.3;
    color: #f1f5f9;
}

.nav-link-sub {
    font-size: 0.72rem;
    color: #94a3b8;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
    text-align: right;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.1);
}

.nav-link:hover i {
    color: #ffffff;
}

.nav-link:hover .nav-link-sub {
    color: #cbd5e1;
}

.nav-link.active {
    background: var(--primary-color);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.nav-link.active i {
    color: #ffffff;
}

.nav-link.active .nav-link-main {
    color: #ffffff;
}

.nav-link.active .nav-link-sub {
    color: rgba(255, 255, 255, 0.9);
}

/* Main Area */
.main-content {
    flex: 1;
    padding: 28px;
    max-width: 1200px;
    margin: 0 auto;
}

.breadcrumbs {
    display: flex;
    list-style: none;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.breadcrumbs a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumbs li::after {
    content: '/';
    margin-right: 8px;
}

.breadcrumbs li:last-child::after {
    content: '';
}

/* Cards & Sections */
.kb-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 12px;
}

.card {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

/* EIM Management Phone Grid */
.eim-management-card {
    background: linear-gradient(135deg, rgba(2,132,199,0.05) 0%, rgba(99,102,241,0.05) 100%);
    border: 1px solid var(--primary-color);
}

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

.phone-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.phone-num {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1rem;
    letter-spacing: 0.5px;
}

/* Copy Buttons */
.copy-btn {
    background: var(--primary-soft);
    color: var(--primary-color);
    border: none;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    transition: var(--transition);
}

.copy-btn:hover {
    background: var(--primary-color);
    color: white;
}

.copy-btn-icon {
    background: var(--primary-soft);
    color: var(--primary-color);
    border: none;
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    margin-right: 6px;
    transition: var(--transition);
}

.copy-btn-icon:hover {
    background: var(--primary-color);
    color: white;
}

.back-btn {
    margin-left: 8px;
}

/* Quick Access Cards */
.quick-access-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.qa-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.qa-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.qa-icon {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

/* Alert Boxes */
.alert {
    padding: 16px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-info { background: #e0f2fe; color: #0369a1; border-right: 4px solid #0284c7; }
.alert-warning { background: #fef3c7; color: #b45309; border-right: 4px solid #f59e0b; }
.alert-danger { background: #ffe4e6; color: #be123c; border-right: 4px solid #f43f5e; }

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 0.9rem;
}

.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--primary-soft);
    color: var(--primary-color);
    font-weight: 700;
}

.phone-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 700;
    direction: ltr;
    display: inline-block;
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
}
.badge-blue { background: #e0f2fe; color: #0369a1; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }
.badge-cyan { background: #cffaff; color: #0e7490; }

/* Hover Pop-up Window for Images (Sections / Sidebar / Search results) */
.image-hover-popup {
    position: fixed;
    z-index: 900;
    pointer-events: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    width: 240px;
    overflow: hidden;
    opacity: 0;
    transform: translateY(4px) scale(0.98);
    transition: opacity 0.14s ease-out, transform 0.14s ease-out;
}

.image-hover-popup.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.image-hover-popup.hidden {
    display: none;
}

.hover-popup-img-wrap {
    width: 100%;
    height: 130px;
    background: #f1f5f9;
    overflow: hidden;
}

.image-hover-popup img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hover-popup-body {
    padding: 10px 12px 12px;
    border-top: 1px solid var(--border-color);
}

.hover-popup-title {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--text-main, #1e293b);
    margin-bottom: 2px;
}

.hover-popup-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.hover-popup-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary-color);
    padding-top: 6px;
    border-top: 1px dashed var(--border-color);
}

.hover-popup-hint.hidden-hint {
    display: none;
}

/* Elements that trigger the preview popup get a helpful cursor + subtle affordance */
[data-preview] {
    cursor: pointer;
}

/* Interactive Tabs */
.tabs-container { margin-top: 16px; }
.tab-buttons { display: flex; gap: 8px; border-bottom: 1px solid var(--border-color); }
.tab-btn {
    padding: 10px 18px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--primary-color); border-bottom-color: var(--primary-color); }
.tab-content { display: none; padding: 16px 0; }
.tab-content.active { display: block; }

/* Buttons & Modals */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-weight: 700;
    transition: var(--transition);
}
.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary-soft { background: var(--primary-soft); color: var(--primary-color); }
.btn-secondary { background: var(--border-color); color: var(--text-main); }

.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.modal-content {
    background: var(--bg-card);
    width: 100%;
    max-width: 600px;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

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

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 700; font-size: 0.85rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-main);
}

/* Lightbox */
.lightbox {
    position: fixed;
    top:0; left:0; right:0; bottom:0;
    background: rgba(0,0,0,0.85);
    z-index: 400;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.lightbox-close { position: absolute; top: 20px; right: 30px; color: white; font-size: 2rem; cursor: pointer; }
#lightbox-img { max-width: 90%; max-height: 80vh; border-radius: 8px; }
.lightbox-caption { color: white; margin-top: 12px; }

/* Utilities */
.hidden { display: none !important; }
.mt-20 { margin-top: 20px; }
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Back to top */
.back-to-top {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: var(--shadow-md);
    cursor: pointer;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar { position: fixed; height: 100%; z-index: 90; }
    .grid-2col { grid-template-columns: 1fr; }
    .header-center { margin: 0 8px; }
    .branch-search-wrapper { flex-direction: column; align-items: stretch; }
    .branch-filter-status { justify-content: center; }
}

/* Branch Search Bar & Filter */
.branch-search-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border-color);
}

.branch-search-box {
    position: relative;
    flex: 1;
    min-width: 260px;
    display: flex;
    align-items: center;
}

.branch-search-icon {
    position: absolute;
    right: 16px;
    color: var(--primary-color);
    font-size: 1rem;
    pointer-events: none;
}

#branch-filter {
    width: 100%;
    padding: 12px 46px 12px 42px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 0.92rem;
    font-weight: 500;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

#branch-filter:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow-md);
}

.clear-branch-btn {
    position: absolute;
    left: 14px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.clear-branch-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.branch-filter-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--primary-soft);
    color: var(--primary-color);
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 30px;
    border: 1px solid rgba(2, 132, 199, 0.2);
    white-space: nowrap;
}

/* Branch Cards Improvements */
.branches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.branch-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--shadow-sm);
}

.branch-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.branch-card h4 {
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.branch-card p {
    font-size: 0.9rem;
    color: var(--text-main);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.5;
}

.branch-card p i {
    color: var(--primary-color);
    margin-top: 4px;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.branch-card .badge {
    align-self: flex-start;
    margin-top: 4px;
}

/* Accordion Styling (FAQ & Workflows) */
.accordion {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 6px;
}

.accordion-item {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.accordion-item:hover {
    border-color: var(--primary-color);
}

.accordion-item.active {
    border-color: var(--primary-color);
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.12);
    background: var(--bg-card);
}

.accordion-header {
    width: 100%;
    padding: 16px 20px;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    cursor: pointer;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-main);
    text-align: right;
    transition: var(--transition);
}

.accordion-header:hover {
    background: var(--primary-soft);
    color: var(--primary-color);
}

.accordion-item.active .accordion-header {
    background: var(--primary-soft);
    color: var(--primary-color);
}

.accordion-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    line-height: 1.5;
}

.faq-icon {
    color: var(--primary-color);
    font-size: 1.15rem;
    flex-shrink: 0;
}

.accordion-icon {
    color: var(--text-muted);
    font-size: 0.88rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.accordion-item.active .accordion-icon {
    transform: rotate(180deg);
    color: var(--primary-color);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-card);
}

.accordion-item.active .accordion-content {
    max-height: 600px;
}

.accordion-body {
    padding: 16px 22px 20px 22px;
    border-top: 1px dashed var(--border-color);
    font-size: 0.92rem;
    line-height: 1.8;
    color: var(--text-main);
}

.accordion-body p {
    margin-bottom: 8px;
}

.accordion-body p:last-child {
    margin-bottom: 0;
}

.accordion-body ul {
    margin: 8px 22px 8px 0;
}

.accordion-body li {
    margin-bottom: 6px;
}

.faq-tags-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

/* Call Center Scripts & Dialogue Flow */
.script-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding-bottom: 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.script-title-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
}

.script-main-icon {
    font-size: 2rem;
    color: var(--primary-color);
    background: var(--primary-soft);
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(2, 132, 199, 0.2);
}

.script-title-wrap h3 {
    font-size: 1.15rem;
    color: var(--text-main);
    margin-bottom: 4px;
}

.dialogue-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dialogue-step {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    padding-right: 14px;
    border-right: 3px solid var(--primary-soft);
}

.step-badge {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--primary-soft);
    color: var(--primary-color);
    font-weight: 800;
    font-size: 0.85rem;
    border-radius: 20px;
    border: 1px solid rgba(2, 132, 199, 0.25);
    margin-bottom: 4px;
}

.chat-bubble {
    border-radius: var(--radius-md);
    padding: 14px 18px;
    line-height: 1.7;
    font-size: 0.95rem;
    max-width: 90%;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.agent-bubble {
    align-self: flex-start;
    background: var(--primary-soft);
    border: 1px solid rgba(2, 132, 199, 0.25);
    color: var(--text-main);
}

.customer-bubble {
    align-self: flex-end;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.bubble-sender {
    font-size: 0.8rem;
    font-weight: 800;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.agent-bubble .bubble-sender {
    color: var(--primary-color);
}

.customer-bubble .bubble-sender {
    color: var(--text-muted);
}

.bubble-text {
    font-size: 0.94rem;
}

.script-highlight {
    background: rgba(2, 132, 199, 0.18);
    color: var(--primary-color);
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(2, 132, 199, 0.3);
}

[data-theme="dark"] .script-highlight {
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
}

.script-tag {
    background: var(--border-color);
    color: var(--text-main);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

/* Quality & Escalation Policy Card */
.quality-policy-card {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.06), rgba(245, 158, 11, 0.06));
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-lg);
    padding: 22px;
}

.quality-policy-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.quality-icon {
    font-size: 1.8rem;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
    padding: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.quality-policy-header h4 {
    color: #dc2626;
    font-size: 1.05rem;
    font-weight: 800;
    margin-bottom: 4px;
}

[data-theme="dark"] .quality-policy-header h4 {
    color: #f87171;
}

.quality-policy-header p {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.quality-policy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.quality-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.quality-item-icon {
    color: #ef4444;
    font-size: 1.2rem;
    background: rgba(239, 68, 68, 0.1);
    padding: 8px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    margin-top: 2px;
}

.quality-item strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 4px;
}

.quality-item p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

