/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: 240px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width 0.25s ease;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
}

/* Toggle button */
.sidebar-toggle {
    margin-left: auto;
    width: 26px;
    height: 26px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.06);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.15); }
.toggle-arrow {
    font-size: 18px;
    line-height: 1;
    transition: transform 0.25s ease;
}

/* === Collapsed (squeezed) sidebar === */
.sidebar.collapsed { width: 72px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .user-info { display: none; }
.sidebar.collapsed .sidebar-logo {
    justify-content: center;
    padding: 20px 0;
}
.sidebar.collapsed .sidebar-toggle {
    margin-left: 0;
    position: absolute;
    top: 16px;
    right: 50%;
    transform: translateX(50%);
}
.sidebar.collapsed .logo-icon { margin: 0 auto; }
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}
.sidebar.collapsed .nav-item.active { border-left-width: 0; }
.sidebar.collapsed .sidebar-footer { justify-content: center; padding: 16px 0; }
.sidebar.collapsed .toggle-arrow { transform: rotate(180deg); }

/* When collapsed, push logo down so the absolutely-positioned toggle has room */
.sidebar.collapsed .sidebar-logo { padding-top: 52px; }
.logo-icon {
    width: 36px;
    height: 36px;
    background: #4f46e5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.logo-text { font-size: 18px; font-weight: 700; }
.sidebar-nav { list-style: none; padding: 12px 0; flex: 1; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    color: rgba(255,255,255,0.7);
}
.nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-item.active {
    background: rgba(79,70,229,0.3);
    color: #fff;
    border-left: 3px solid #4f46e5;
}
.nav-icon { font-size: 16px; }
.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.user-avatar {
    width: 32px;
    height: 32px;
    background: #4f46e5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); }

/* === Main Content === */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px 32px;
    transition: margin-left 0.25s ease;
}
.app-shell.sidebar-collapsed .main-content { margin-left: 72px; }

/* === Breadcrumb === */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #6b7280;
}
.breadcrumb-item { cursor: pointer; }
.breadcrumb-item:hover { color: #4f46e5; }
.breadcrumb-item.active { color: #1a1a2e; font-weight: 600; }
.breadcrumb-separator { color: #d1d5db; }

/* === Page Header === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.page-header h1 { font-size: 24px; font-weight: 700; }
.header-meta { display: flex; align-items: center; gap: 12px; }
.run-status { font-size: 13px; color: #6b7280; }
.run-badge {
    background: #e0e7ff;
    color: #4f46e5;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    text-transform: uppercase;
}

/* === KPI Cards === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}
.kpi-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.kpi-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}
.kpi-bar.blue { background: #3b82f6; }
.kpi-bar.indigo { background: #4f46e5; }
.kpi-bar.green { background: #22c55e; }
.kpi-bar.amber { background: #f59e0b; }
.kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-bottom: 12px;
}
.blue-bg { background: #eff6ff; }
.indigo-bg { background: #eef2ff; }
.green-bg { background: #f0fdf4; }
.amber-bg { background: #fffbeb; }
.kpi-value { font-size: 32px; font-weight: 800; color: #1a1a2e; }
.kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* === Sections === */
.section {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.section h2 {
    font-size: 13px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}
.section-header h2 { margin-bottom: 0; }

/* === Search === */
.search-box input {
    padding: 8px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    width: 260px;
    outline: none;
    transition: border-color 0.2s;
}
.search-box input:focus { border-color: #4f46e5; }

/* === Filter Tabs === */
.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}
.filter-btn {
    padding: 6px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b7280;
}
.filter-btn:hover { border-color: #4f46e5; color: #4f46e5; }
.filter-btn.active {
    background: #1a1a2e;
    color: #fff;
    border-color: #1a1a2e;
}

/* === Rule Cards Grid === */
.rule-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.rule-card {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    position: relative;
}
.rule-card:hover {
    border-color: #4f46e5;
    box-shadow: 0 2px 8px rgba(79,70,229,0.1);
    transform: translateY(-1px);
}
.rule-rank {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.rank-high { background: #22c55e; }
.rank-medium { background: #f59e0b; }
.rank-low { background: #6b7280; }
.rule-card-content { flex: 1; }
.rule-card-title { font-size: 14px; font-weight: 600; color: #1a1a2e; }
.rule-card-priority {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
}
.priority-high { background: #dcfce7; color: #16a34a; }
.priority-medium { background: #fef3c7; color: #d97706; }
.priority-low { background: #f3f4f6; color: #6b7280; }
.rule-card-meta {
    display: flex;
    gap: 16px;
    margin-top: 10px;
    font-size: 12px;
    color: #9ca3af;
}
.rule-card-bar {
    height: 4px;
    border-radius: 2px;
    margin-top: 10px;
}
.bar-high { background: linear-gradient(90deg, #22c55e 70%, #e5e7eb 70%); }
.bar-medium { background: linear-gradient(90deg, #f59e0b 45%, #e5e7eb 45%); }
.bar-low { background: linear-gradient(90deg, #6b7280 20%, #e5e7eb 20%); }
.rule-card-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #d1d5db;
    font-size: 16px;
}

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.pagination-info {
    font-size: 12px;
    color: #9ca3af;
    margin-right: 12px;
}
.page-ellipsis {
    width: 34px;
    text-align: center;
    font-size: 14px;
    color: #9ca3af;
}
.page-btn {
    width: 34px;
    height: 34px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.page-btn:hover { border-color: #4f46e5; color: #4f46e5; }
.page-btn.active { background: #4f46e5; color: #fff; border-color: #4f46e5; }

/* === Rule Hero (Enquiry Line Page) === */
.rule-hero {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #818cf8 100%);
    border-radius: 16px;
    padding: 28px 32px;
    color: #fff;
    margin-bottom: 24px;
    position: relative;
}
.rule-hero-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
    margin-bottom: 6px;
}
.rule-hero-title { font-size: 22px; font-weight: 700; margin-bottom: 12px; }
.rule-hero-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-tag {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
}
.dominant-badge {
    position: absolute;
    top: 24px;
    right: 28px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    margin-bottom: 16px;
    cursor: pointer;
}
.back-link:hover { color: #fff; text-decoration: underline; }

/* === Priority Breakdown === */
.priority-breakdown {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
.priority-card {
    padding: 16px 20px;
    border-radius: 10px;
    border-left: 4px solid;
    background: #f8fafc;
}
.priority-card.high { border-left-color: #22c55e; }
.priority-card.medium { border-left-color: #f59e0b; }
.priority-card.low { border-left-color: #6b7280; }
.priority-count { font-size: 24px; font-weight: 800; display: inline; }
.priority-text { font-size: 14px; font-weight: 500; margin-left: 6px; }
.priority-text.high-text { color: #16a34a; }
.priority-text.medium-text { color: #d97706; }
.priority-text.low-text { color: #6b7280; }

/* === Recommendations layout === */
.recommendations-layout {
    display: block;
}
.recommendations-table-wrap {
    min-width: 0;
}

/* Inline analysis spinner (next to Upload button) */
.inline-analysis {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: #eef2ff;
    border: 1px solid #e0e7ff;
    border-radius: 8px;
    animation: fadeIn 0.2s ease;
}
.inline-spinner {
    width: 15px;
    height: 15px;
    border: 2px solid #c7d2fe;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
.inline-analysis-text {
    font-size: 13px;
    font-weight: 600;
    color: #4f46e5;
    white-space: nowrap;
}
label.btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Recommendations toolbar (row below the heading) */
.recommendations-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0 20px;
    flex-wrap: wrap;
}

/* Result source dropdown */
.result-source-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 4px;
}
.result-source-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
}
.result-source-select {
    padding: 7px 12px;
    font-size: 13px;
    min-width: 200px;
}

/* Accept button */
.btn-accept {
    padding: 5px 14px;
    border: 1px solid #4f46e5;
    background: #fff;
    color: #4f46e5;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-accept:hover { background: #eef2ff; }
.btn-accept.accepted {
    background: #22c55e;
    border-color: #22c55e;
    color: #fff;
}
.btn-accept.accepted:hover { background: #16a34a; }
.row-accepted { background: #f0fdf4; }
.row-accepted:hover { background: #dcfce7; }

/* Changed / new recommendation highlighting */
.row-changed { background: #fffbeb; }
.row-changed:hover { background: #fef3c7; }
.changed-badge {
    display: inline-block;
    background: #22c55e;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

/* === Data Table === */
.table-container { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table thead th {
    background: #4f46e5;
    color: #fff;
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.data-table thead th:first-child { border-radius: 8px 0 0 0; }
.data-table thead th:last-child { border-radius: 0 8px 0 0; }
.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
}
.data-table tbody tr:hover { background: #f8fafc; }
.action-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.action-modify { background: #fef3c7; color: #d97706; }
.action-add { background: #dcfce7; color: #16a34a; }
.action-remove { background: #fee2e2; color: #dc2626; }
.rule-tag {
    display: inline-block;
    background: #eef2ff;
    color: #4f46e5;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'SF Mono', Monaco, monospace;
    white-space: nowrap;
}

/* === Buttons === */
.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-secondary { background: #22c55e; color: #fff; }
.btn-secondary:hover { background: #16a34a; }
.btn-outline {
    background: #fff;
    color: #4f46e5;
    border: 1px solid #e5e7eb;
}
.btn-outline:hover { border-color: #4f46e5; }

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal {
    background: #fff;
    border-radius: 16px;
    width: 560px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal.modal-lg {
    width: 720px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
.modal.modal-lg .modal-body {
    overflow-y: auto;
    flex: 1;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #f3f4f6;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
    width: 28px;
    height: 28px;
    border: none;
    background: #f3f4f6;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-body { padding: 24px; }
.modal-body p { font-size: 14px; color: #6b7280; margin-bottom: 16px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid #f3f4f6;
}
.modal-info { background: #f8fafc; border-radius: 10px; padding: 16px; }
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}
.info-label { color: #6b7280; }
.results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 16px;
}
.result-card {
    background: #f8fafc;
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}
.result-label { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.result-value { font-size: 28px; font-weight: 800; }
.result-value.red { color: #dc2626; }
.result-value.green { color: #22c55e; }
.result-value.blue { color: #4f46e5; }
.upload-status { text-align: center; padding: 24px; }
.upload-success {
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: #22c55e;
    margin-bottom: 12px;
}

/* === Spinner === */
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Utilities === */
.hidden { display: none !important; }
.page { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 14px;
    grid-column: 1 / -1;
}

/* === Login Screen === */
.login-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}
.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 48px 44px;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 24px 80px rgba(0,0,0,0.3);
    text-align: center;
    animation: slideUp 0.4s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.login-logo { margin-bottom: 24px; }
.login-logo-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 16px;
    box-shadow: 0 8px 24px rgba(79,70,229,0.3);
}
.login-title {
    font-size: 26px;
    font-weight: 800;
    color: #1a1a2e;
    margin-bottom: 4px;
}
.login-subtitle {
    font-size: 14px;
    color: #9ca3af;
}
.login-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 24px 0;
}
.login-sso {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
.sso-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-btn {
    width: 100%;
    padding: 14px 24px;
    background: #2f2f2f;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.login-btn:hover {
    background: #1a1a1a;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.login-btn:active { transform: translateY(0); }
.login-hint {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 20px;
}
.login-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 28px;
    font-size: 11px;
    color: #d1d5db;
}
.login-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
    font-size: 13px;
    color: #6b7280;
}
.login-loading.show { display: flex; }
.login-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e5e7eb;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* === Configuration Page === */
.section-desc {
    font-size: 13px;
    color: #9ca3af;
    margin-bottom: 12px;
}
.last-synced {
    font-size: 12px;
    color: #6b7280;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 12px;
    display: inline-block;
    margin-bottom: 16px;
}
.btn-spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}
.btn:disabled { opacity: 0.85; cursor: default; }
.golden-dataset-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}
.golden-card {
    background: #f8fafc;
    border-radius: 10px;
    padding: 18px;
    border: 1px solid #e5e7eb;
}
.golden-label { font-size: 11px; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.golden-value { font-size: 20px; font-weight: 700; color: #1a1a2e; }
.golden-history { margin-top: 8px; }
.golden-history h3 { font-size: 13px; font-weight: 600; color: #6b7280; margin-bottom: 12px; }
.version-list { display: flex; flex-direction: column; gap: 8px; }
.version-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    font-size: 13px;
}
.version-tag {
    background: #e5e7eb;
    color: #6b7280;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    min-width: 40px;
    text-align: center;
}
.version-tag.current { background: #4f46e5; color: #fff; }
.version-detail { flex: 1; color: #6b7280; }
.version-badge { font-size: 11px; font-weight: 600; }
.active-badge { color: #22c55e; }

/* Config Form */
.config-form { max-width: 800px; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.form-group { display: flex; flex-direction: column; }
.form-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.form-input, .form-select {
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: #1a1a2e;
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus { border-color: #4f46e5; }
.form-input[readonly] { background: #f8fafc; color: #6b7280; }
.form-actions { margin-top: 8px; }

/* Status Toggle */
.status-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.toggle-track {
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: #d1d5db;
    position: relative;
    transition: background 0.2s;
}
.toggle-track.active { background: #22c55e; }
.toggle-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: left 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-track.active .toggle-thumb { left: 20px; }
.toggle-label { font-size: 12px; font-weight: 500; }
.toggle-label.on { color: #22c55e; }
.toggle-label.off { color: #9ca3af; }

/* Action icons in table */
.table-actions { display: flex; gap: 8px; }
.icon-btn {
    width: 30px;
    height: 30px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s;
}
.icon-btn:hover { border-color: #4f46e5; background: #eef2ff; }
.icon-btn.danger:hover { border-color: #dc2626; background: #fee2e2; }

/* Upload Zone */
.upload-zone {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.upload-zone:hover { border-color: #4f46e5; background: #f8fafc; }
.upload-zone-icon { font-size: 32px; margin-bottom: 8px; }
.upload-zone-text { font-size: 14px; color: #6b7280; }
.upload-zone-hint { font-size: 12px; color: #d1d5db; margin-top: 4px; }
.upload-zone.has-file { border-color: #22c55e; background: #f0fdf4; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1a1a2e;
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    z-index: 300;
    animation: slideInToast 0.3s ease;
}
@keyframes slideInToast {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Run History === */
.manual-run-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}
.manual-run-label {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
}
.manual-run-controls .form-select {
    min-width: 150px;
}
.trigger-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.trigger-scheduled { background: #e0e7ff; color: #4f46e5; }
.trigger-manual { background: #fef3c7; color: #d97706; }

.run-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.status-completed { background: #dcfce7; color: #16a34a; }
.status-partial { background: #fef3c7; color: #d97706; }
.status-failed { background: #fee2e2; color: #dc2626; }
.status-running { background: #e0e7ff; color: #4f46e5; }

.enquiry-progress { display: flex; flex-direction: column; gap: 4px; }
.progress-text { font-size: 12px; font-weight: 600; }
.progress-bar-track {
    width: 100%;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.progress-bar-fill.completed { background: #22c55e; }
.progress-bar-fill.partial { background: #f59e0b; }
.progress-bar-fill.failed { background: #dc2626; }

/* Run Detail Panel */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.detail-card {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px;
}
.detail-label { font-size: 11px; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; }
.detail-value { font-size: 14px; font-weight: 600; color: #1a1a2e; }

.detail-section { margin-bottom: 20px; }
.detail-section h3 { font-size: 13px; font-weight: 600; color: #6b7280; margin-bottom: 12px; }

.line-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.line-tag {
    background: #eef2ff;
    color: #4f46e5;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.summary-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.summary-item {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px 20px;
    text-align: center;
    min-width: 120px;
}
.summary-num { display: block; font-size: 24px; font-weight: 800; color: #1a1a2e; }
.summary-item.success .summary-num { color: #22c55e; }
.summary-item.fail .summary-num { color: #dc2626; }
.summary-label { font-size: 11px; color: #9ca3af; text-transform: uppercase; }

.error-list { display: flex; flex-direction: column; gap: 8px; }
.error-item {
    display: flex;
    gap: 12px;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    font-size: 13px;
}
.error-enquiry {
    font-weight: 600;
    color: #dc2626;
    white-space: nowrap;
    flex-shrink: 0;
}
.error-message { color: #7f1d1d; }

/* =========================================================================
   Recommendations — clean rule list + per-rule modal
   ========================================================================= */
.rec-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    line-height: 1.4;
}
.rec-chip.count { background: #eef2ff; color: #4338ca; }
.rec-chip.accepted { background: #dcfce7; color: #166534; }
.rec-chip.prio-high { background: #fee2e2; color: #b91c1c; }
.rec-chip.prio-medium { background: #fef3c7; color: #b45309; }
.rec-chip.prio-low { background: #d1fae5; color: #047857; }
.rec-chip.sta { background: #ecfeff; color: #0e7490; }

/* STA impact badge in the rule table */
.sta-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    color: #0e7490;
    background: #ecfeff;
    border: 1px solid #cffafe;
    border-radius: 6px;
    padding: 2px 9px;
    min-width: 42px;
    text-align: center;
}

/* ---------- Rule list (original data-table look) ---------- */
.rec-rules-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.rec-rules-head .rec-list-total { font-size: 13px; color: #6b7280; font-weight: 600; }
.rec-search {
    box-sizing: border-box;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    background: #fff;
    outline: none;
    width: 260px;
    max-width: 100%;
    transition: border-color 0.15s;
}
.rec-search:focus { border-color: #a5b4fc; }

/* The table itself inherits the standard .data-table styling (indigo header). */
.rec-rule-view {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #4f46e5;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.rec-rule-view:hover { background: #4f46e5; color: #fff; border-color: #4f46e5; }

.rec-dot {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    background: #cbd5e1;
}
.rec-dot.prio-high { background: #ef4444; }
.rec-dot.prio-medium { background: #f59e0b; }
.rec-dot.prio-low { background: #10b981; }

/* acceptance meter cell */
.rec-rule-progress { display: flex; align-items: center; gap: 10px; }
.rec-rule-progress-track {
    flex: 1;
    min-width: 70px;
    height: 6px;
    background: #eef1f5;
    border-radius: 999px;
    overflow: hidden;
}
.rec-rule-progress-track > span { display: block; height: 100%; background: #16a34a; border-radius: 999px; transition: width 0.2s; }
.rec-rule-progress-label { font-size: 11px; color: #6b7280; font-weight: 600; white-space: nowrap; }

.rec-rules-foot { padding: 12px; display: flex; justify-content: center; }
.rec-rules-foot .pagination { margin: 0; }

/* ---------- Accept-all button (used in modal header) ---------- */
.btn-accept-all {
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    border-radius: 9px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.btn-accept-all:hover { border-color: #4f46e5; color: #4f46e5; background: #f5f3ff; }
.btn-accept-all.all-accepted { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-accept-all.all-accepted:hover { background: #15803d; }

/* ---------- Recommendations modal ---------- */
.modal.rec-modal { width: 860px; max-width: 94vw; }
.rec-modal .modal-header { align-items: flex-start; }
.rec-modal-sub { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.rec-modal-head-actions { display: flex; align-items: center; gap: 12px; }
.rec-modal-foot-info { font-size: 12.5px; color: #64748b; margin-right: auto; }
.rec-modal-search-wrap {
    padding: 12px 24px;
    border-bottom: 1px solid #eef0f4;
    background: #fff;
}
.rec-modal-search { width: 100%; }
.rec-modal .modal-body { max-height: 56vh; overflow-y: auto; background: #f8fafc; }

.rec-item {
    border: 1px solid #eef0f4;
    border-radius: 12px;
    padding: 16px 18px;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    margin-bottom: 10px;
}
.rec-item:last-child { margin-bottom: 0; }
.rec-item:hover { border-color: #dbe2ea; box-shadow: 0 2px 10px rgba(17,24,39,0.05); }
.rec-item.accepted { border-color: #bbf7d0; background: #f7fef9; }

.rec-item-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.rec-item-index {
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
    margin-right: 2px;
}
.rec-item-change {
    font-size: 14px;
    color: #111827;
    line-height: 1.55;
    font-weight: 500;
    margin-bottom: 10px;
}
.rec-item-impact {
    font-size: 13px;
    color: #475569;
    line-height: 1.5;
    background: #f8fafc;
    border-radius: 8px;
    padding: 10px 12px;
    border-left: 3px solid #e2e8f0;
    margin-bottom: 12px;
}
.rec-item-foot {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}
.rec-metric { font-size: 12px; color: #64748b; }
.rec-metric strong { color: #0f172a; font-weight: 700; font-size: 13px; }
.rec-item-foot .btn-accept { margin-left: auto; }

@media (max-width: 768px) {
    .rec-rules-table th.col-accepted,
    .rec-rules-table td.col-accepted { display: none; }
    .rec-rules-table th.col-num,
    .rec-rules-table td.col-num { width: auto; }
    .rec-item-foot .btn-accept { margin-left: 0; }
}

/* =========================================================================
   Responsive layout
   ========================================================================= */

/* Tablet and below */
@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .rule-cards-grid { grid-template-columns: 1fr; }
    .page-header {
        flex-wrap: wrap;
        gap: 12px;
    }
    .recommendations-toolbar {
        flex-wrap: wrap;
        gap: 10px;
    }
    .config-form .form-row { flex-wrap: wrap; }
}

/* Mobile */
@media (max-width: 768px) {
    /* Sidebar becomes a top bar */
    .app-shell { flex-direction: column; }
    .sidebar {
        position: static;
        width: 100%;
        flex-direction: column;
    }
    .sidebar-nav {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        padding: 4px 8px;
        gap: 4px;
    }
    .nav-item {
        padding: 10px 14px;
        white-space: nowrap;
        border-left: none !important;
        border-radius: 8px;
    }
    .nav-item.active {
        border-left: none !important;
        border-bottom: 3px solid #4f46e5;
    }
    .sidebar-footer { display: none; }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .kpi-grid { grid-template-columns: 1fr; }

    .page-header h1 { font-size: 20px; }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .search-box, .search-box input { width: 100%; box-sizing: border-box; }

    .filter-tabs { flex-wrap: wrap; }

    .manual-run-controls { flex-wrap: wrap; gap: 8px; }

    /* Modal fills the screen more comfortably */
    .modal, .modal.modal-lg {
        width: 94vw;
        max-width: 94vw;
        margin: 0 auto;
    }
    .detail-grid { grid-template-columns: 1fr 1fr; }
    .summary-grid { grid-template-columns: 1fr 1fr; }

    /* Login card fluid */
    .login-card { width: 92vw; max-width: 400px; }

    /* Accordion header actions wrap under the title on small screens */
    .rec-group-actions { justify-content: flex-start; }
}

/* Very small screens */
@media (max-width: 480px) {
    .detail-grid, .summary-grid { grid-template-columns: 1fr; }
    .kpi-value { font-size: 22px; }
}

/* =========================================================================
   Charts
   ========================================================================= */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.charts-grid-2 { grid-template-columns: repeat(2, 1fr); }

.chart-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(17,24,39,0.05);
    display: flex;
    flex-direction: column;
}
.chart-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.01em;
}
.chart-sub {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 3px;
    margin-bottom: 14px;
}
.chart-canvas-wrap {
    position: relative;
    flex: 1;
    height: 260px;
}
.chart-canvas-wrap canvas { max-height: 260px; }

@media (max-width: 1024px) {
    .charts-grid, .charts-grid-2 { grid-template-columns: 1fr; }
}

/* =========================================================================
   Decision-flow tree (per-rule modal)
   ========================================================================= */
.tree-panel {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    padding: 16px 18px;
    margin-bottom: 16px;
}
.tree-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.tree-panel-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}
.tree-panel-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.tree-chip {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
}
.tree-chip.changed { background: #fef3c7; color: #b45309; }

.tree-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #94a3b8;
    margin-bottom: 8px;
}

/* Nodes needing change */
.tree-changed { margin-bottom: 16px; }
.tree-changed-node {
    border: 1px solid #fde68a;
    background: #fffbeb;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
}
.tree-changed-node:last-child { margin-bottom: 0; }
.tree-changed-node-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.tree-node-kind {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 8px;
    border-radius: 6px;
    background: #e2e8f0;
    color: #475569;
}
.tree-node-kind.kind-branch { background: #e0e7ff; color: #4338ca; }
.tree-node-kind.kind-contribution { background: #dcfce7; color: #166534; }
.tree-node-kind.kind-trigger { background: #fee2e2; color: #b91c1c; }
.tree-node-label {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    font-family: 'SF Mono', Monaco, monospace;
}
.tree-node-count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    color: #b45309;
    background: #fef3c7;
    padding: 2px 9px;
    border-radius: 999px;
}
.tree-decisions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tree-decision {
    font-size: 11px;
    color: #0e7490;
    background: #ecfeff;
    border: 1px solid #cffafe;
    border-radius: 6px;
    padding: 2px 8px;
    font-family: 'SF Mono', Monaco, monospace;
}
.tree-enq-list { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tree-enq-chip {
    font-size: 11px;
    color: #334155;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 2px 8px;
    font-family: 'SF Mono', Monaco, monospace;
}
.tree-enq-more { font-size: 11px; color: #94a3b8; font-weight: 600; }
.tree-empty { font-size: 13px; color: #94a3b8; padding: 6px 0; }

/* Compact flow */
.tree-flow-wrap {
    border-top: 1px dashed #e5e7eb;
    padding-top: 14px;
}
.tree-flow {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.tree-flow-node {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 8px;
    padding: 6px 10px;
    max-width: 220px;
}
.tree-flow-node.changed {
    border-color: #f59e0b;
    background: #fffbeb;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}
.tree-flow-kind {
    width: 8px; height: 8px; border-radius: 50%;
    background: #cbd5e1; flex-shrink: 0;
}
.tree-flow-kind.kind-branch { background: #6366f1; }
.tree-flow-kind.kind-contribution { background: #16a34a; }
.tree-flow-kind.kind-trigger { background: #ef4444; }
.tree-flow-label {
    font-size: 12px;
    color: #334155;
    font-family: 'SF Mono', Monaco, monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tree-flow-affected {
    font-size: 10px;
    font-weight: 700;
    color: #b45309;
    background: #fef3c7;
    border-radius: 999px;
    padding: 1px 7px;
    white-space: nowrap;
}
.tree-flow-arrow { color: #cbd5e1; font-size: 13px; }

/* Rule-list tree flag */
.tree-flag { margin-right: 6px; font-size: 13px; vertical-align: middle; }

/* =========================================================================
   Decision-flow tree — interactive node cards + two-pointer recommendations
   ========================================================================= */
.tree-hint {
    font-size: 12px;
    color: #64748b;
    margin: 8px 0 14px;
    line-height: 1.5;
}
/* =========================================================================
   Mermaid-based decision tree: full-size diagram in its own scroll box,
   plus a click-through detail panel. The diagram is NEVER shrunk to fit —
   it renders at its natural (enlarged) size so every node stays legible,
   and the box scrolls both horizontally and vertically to reach it all.
   ========================================================================= */

/* Large, always-both-directions scroll box. Sized relative to the viewport
   (not a fixed small box) so there's real room to view a big tree, while
   still capping it so the page itself doesn't grow unbounded. */
.tree-mermaid-wrap {
    border: 1px solid #eef0f4;
    border-radius: 10px;
    background: #fbfcfe;
    width: 100%;
    height: 75vh;
    min-height: 480px;
    overflow-x: scroll;
    overflow-y: scroll;
    padding: 24px;
}
.tree-mermaid-wrap svg {
    display: block;
    max-width: none !important;   /* override Mermaid's shrink-to-fit */
    height: auto !important;
}
.tree-mermaid-wrap .node { cursor: pointer; }
.tree-mermaid-wrap .node.tree-node-selected rect,
.tree-mermaid-wrap .node.tree-node-selected polygon {
    stroke: #4f46e5 !important;
    stroke-width: 4px !important;
}

/* Detail panel: a slide-in drawer on the right, overlaying the diagram
   rather than sharing column width with it, so the diagram always gets
   full width to render at full size. */
.tree-detail-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    box-shadow: -8px 0 24px rgba(15, 23, 42, 0.12);
    overflow-y: auto;
    z-index: 200;
    transition: right 0.2s ease;
    display: flex;
    flex-direction: column;
}
.tree-detail-panel.open { right: 0; }
.tree-detail-placeholder { display: none; }
.tree-detail-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 16px 18px;
    border-bottom: 1px solid #eef0f4;
    position: sticky;
    top: 0;
    background: #fff;
}
.tree-detail-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    font-family: 'SF Mono', Monaco, monospace;
}
.tree-detail-close {
    margin-left: auto;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.tree-detail-close:hover { background: #f1f5f9; color: #0f172a; }
.tree-detail-body { padding: 14px; }
.tree-detail-stat {
    font-size: 12.5px;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #eef0f4;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 10px;
}
.tree-enq-details {
    margin-bottom: 12px;
    font-size: 12px;
}
.tree-enq-details summary {
    cursor: pointer;
    color: #4338ca;
    font-weight: 600;
    padding: 4px 0;
}
.tree-enq-details .tree-node-enqs-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tree-node-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
    overflow: hidden;
}
.tree-node-card.changed {
    border-color: #f59e0b;
    background: #fffbeb;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.12);
}
.tree-node-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    cursor: pointer;
    flex-wrap: wrap;
}
.tree-node-row:hover { background: rgba(79, 70, 229, 0.04); }
.tree-node-caret {
    font-size: 10px;
    color: #94a3b8;
    width: 12px;
    flex-shrink: 0;
}
.tree-node-name {
    font-size: 13.5px;
    font-weight: 700;
    color: #0f172a;
    font-family: 'SF Mono', Monaco, monospace;
}
.tree-node-flag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #b45309;
    background: #fef3c7;
    border-radius: 999px;
    padding: 2px 8px;
}
.tree-node-affected {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    color: #4338ca;
    background: #eef2ff;
    border: 1px solid #e0e7ff;
    border-radius: 999px;
    padding: 3px 10px;
    cursor: pointer;
    white-space: nowrap;
}
.tree-node-affected:hover { background: #e0e7ff; }

/* Enquiry dropdown inside a node */
.tree-node-enqs {
    padding: 0 14px 12px 36px;
    border-top: 1px dashed #e5e7eb;
}
.tree-node-enqs-label {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
    margin: 10px 0 8px;
}
.tree-node-enqs-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tree-enq-link {
    font-size: 11px;
    color: #334155;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 3px 9px;
    font-family: 'SF Mono', Monaco, monospace;
    cursor: pointer;
    transition: all 0.15s;
}
.tree-enq-link:hover { border-color: #4f46e5; color: #4f46e5; background: #eef2ff; }

/* Node detail (why + recommendations), shown on node click */
.tree-node-detail {
    padding: 12px 14px 14px 36px;
    border-top: 1px solid #eef0f4;
    background: #fff;
}
.tree-node-why {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 10px;
}
.tree-node-detail-empty {
    font-size: 12.5px;
    color: #94a3b8;
    padding: 6px 14px 12px 36px;
}
.tree-node-rec {
    border: 1px solid #eef0f4;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #f8fafc;
}
.tree-node-rec:last-child { margin-bottom: 0; }
.tree-node-rec-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.tree-node-rec-count {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
}
.tree-node-engine { margin-bottom: 8px; }

/* Per-fix affected-enquiry links, shown under each deduplicated fix so a
   fix resolving 8 enquiries lists all 8 links once, instead of the fix
   text repeating 8 times. */
.tree-node-rec-enqs {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #e5e7eb;
}
.tree-node-rec-enqs-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 6px;
}

/* Two-pointer recommendation rendering (Why referred / Proposed change) */
.rec-point {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 8px;
    line-height: 1.55;
}
.rec-point:last-child { margin-bottom: 0; }
.rec-point-tag {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 8px;
    border-radius: 6px;
    margin-top: 1px;
    white-space: nowrap;
}
.rec-point-tag.why { background: #fee2e2; color: #b91c1c; }
.rec-point-tag.change { background: #dcfce7; color: #166534; }
.rec-point-tag.engine { background: #ecfeff; color: #0e7490; }
.rec-point-text { font-size: 13px; color: #1f2937; }
.muted { color: #94a3b8; }

/* Recommendation card change block now uses rec-point rows */
.rec-item-change { font-size: 13px; color: #111827; line-height: 1.55; margin-bottom: 10px; }
.rec-item-change .rec-point { margin-bottom: 8px; }

/* Enquiry report (nested) modal */
.enq-report-rec {
    border: 1px solid #eef0f4;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
    background: #fff;
}
.enq-report-rec-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.enq-report-rule {
    font-size: 12px;
    font-weight: 700;
    color: #4f46e5;
    background: #eef2ff;
    border-radius: 6px;
    padding: 2px 8px;
    font-family: 'SF Mono', Monaco, monospace;
}
.enq-report-sta { margin-left: auto; font-size: 12px; font-weight: 700; color: #0e7490; }
.enq-report-change { margin-bottom: 8px; }
.enq-report-impact {
    font-size: 12.5px;
    color: #475569;
    background: #f8fafc;
    border-left: 3px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
}

.node-expand-hint { display: inline-block; font-size: 11px; color: #2563eb; margin-top: 4px; font-weight: 600; }
.node-impact-cell { font-size: 12.5px; color: #475569; line-height: 1.5; }

/* =========================================================================
   Page 2 — Suggestion table (one row per suggestion) + node cell + Page 3
   ========================================================================= */
.node-tr { cursor: pointer; transition: background .12s ease; }
.node-tr:hover { background: #f8fafc; }
.node-tr.open { background: #eff6ff; }
.node-tr > td { vertical-align: top; }

.node-cell-ref { font-weight: 600; color: #1e293b; font-size: 13px; }
.node-cell-meta { font-size: 11px; color: #64748b; margin-top: 2px; }
.node-expand-hint { display: inline-block; font-size: 11px; color: #2563eb; margin-top: 4px; font-weight: 600; }

.node-change-cell { font-size: 12.5px; color: #1f2937; line-height: 1.5; max-width: 340px; }
.node-impact-cell { font-size: 12.5px; color: #475569; line-height: 1.5; }

/* Affected-count dropdown → click an id to open its report (Page 3) */
.affected-dd { display: inline-block; }
.affected-dd > summary {
    cursor: pointer; list-style: none; font-size: 13px; font-weight: 600;
    color: #1d4ed8; user-select: none;
}
.affected-dd > summary::-webkit-details-marker { display: none; }
.affected-dd-list {
    display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-top: 8px;
    max-height: 180px; overflow-y: auto; padding: 6px;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
}

/* Affected enquiry id chips — blue, one per line */
.affected-enq-link {
    display: block; width: 100%; text-align: left;
    font-family: ui-monospace, monospace; font-size: 11px;
    background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 6px;
    padding: 3px 7px; color: #1d4ed8; font-weight: 600;
    cursor: pointer; transition: all .12s;
}
.affected-enq-link:hover { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }

/* Expanded suggestion-row detail */
.node-detail-tr > td { background: #f8fafc; padding: 0 16px 16px; }
.node-detail-panel { padding-top: 12px; }
.node-sugg-group { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 14px; }
.node-sugg-head { display: flex; align-items: center; justify-content: flex-end; margin-bottom: 8px; }
.node-sugg-support { font-size: 11px; font-weight: 600; color: #166534; background: #dcfce7; border-radius: 999px; padding: 2px 10px; }
.node-sugg-enqs { margin-top: 10px; }
.node-sugg-enqs-label { font-size: 11px; color: #64748b; margin-bottom: 6px; }

/* Two-pointer rendering (fallback if not already defined) */
.rec-point { display: flex; gap: 8px; margin-bottom: 8px; line-height: 1.55; }
.rec-point:last-child { margin-bottom: 0; }
.rec-point-tag { flex-shrink: 0; font-size: 10px; font-weight: 700; border-radius: 4px; padding: 2px 7px; height: fit-content; white-space: nowrap; text-transform: uppercase; }
.rec-point-tag.why { background: #fee2e2; color: #b91c1c; }
.rec-point-tag.change { background: #dcfce7; color: #166534; }
.rec-point-tag.engine { background: #ecfeff; color: #0e7490; }
.rec-point-text { font-size: 13px; color: #1f2937; }
.muted { color: #94a3b8; }

/* STA badge (fallback if not already defined) */
.sta-badge { display: inline-block; font-size: 12px; font-weight: 700; color: #0f172a; background: #f1f5f9; border-radius: 6px; padding: 2px 8px; }

/* Page 3 — enquiry report markdown */
.enq-report-md { font-size: 13.5px; color: #1f2937; line-height: 1.6; }
.enq-report-md h1 { font-size: 18px; margin: 4px 0 12px; }
.enq-report-md h2 { font-size: 16px; margin: 16px 0 8px; color: #1e293b; }
.enq-report-md h3 { font-size: 14px; margin: 12px 0 6px; color: #334155; }
.enq-report-md ul { padding-left: 20px; margin: 8px 0; }
.enq-report-md li { margin-bottom: 4px; }
.enq-report-md p { margin: 8px 0; }
.enq-report-md code { background: #f1f5f9; border-radius: 4px; padding: 1px 5px; font-family: ui-monospace, monospace; font-size: 12px; color: #0f172a; }

/* === Enquiry report markdown tables (in-page fallback) === */
.enq-report-md .md-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 13px;
}
.enq-report-md .md-table th {
    background: #4f46e5;
    color: #fff;
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.enq-report-md .md-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #eef1f5;
    vertical-align: top;
}
.enq-report-md .md-table tbody tr:nth-child(even) { background: #f8fafc; }

/* === Page 2 — Enquiry Analysis (clickable enquiry boxes) === */
.section-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin: -4px 0 16px;
}

/* Opportunity-type filter chips */
.opportunity-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}
.opp-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #fff;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.opp-chip:hover {
    border-color: #c7d2fe;
    background: #f5f7ff;
}
.opp-chip.active {
    border-color: #6366f1;
    background: #6366f1;
    color: #fff;
}
.opp-chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 11px;
    font-weight: 700;
}
.opp-chip.active .opp-chip-count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

/* Grid of clickable enquiry boxes — 2–3 per row, roomy enough for the full id */
.enquiry-box-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}
.enq-box {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    position: relative;
    padding: 16px 18px;
    min-height: 72px;
    border: 1px solid #e5e7eb;
    border-radius: 11px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}
.enq-box:hover {
    border-color: #6366f1;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
    transform: translateY(-1px);
}
.enq-box.disabled {
    cursor: default;
    opacity: 0.55;
}
.enq-box.disabled:hover {
    border-color: #e5e7eb;
    box-shadow: none;
    transform: none;
}
.enq-box-id {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    word-break: break-all;
    padding-right: 16px;
}
.enq-box-type {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
}
.enq-box-prio {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9ca3af;
}
.enq-box-prio.prio-high { background: #22c55e; }
.enq-box-prio.prio-medium { background: #f59e0b; }
.enq-box-prio.prio-low { background: #6b7280; }
