/* ================================================================
   Reliam Analytics — CSS System (Identidade Reliam Analytics)
   ================================================================ */

/* === VARIABLES === */
:root {
    --primary:           #081028;
    --primary-dark:      #050b1e;
    --primary-light:     #12224f;
    --accent:            #00B088;
    --accent-dark:       #00997a;
    --bg-page:           #F4F4F4;
    --bg-card:           #ffffff;
    --bg-header:         #F0F2F5;
    --bg-sidebar:        #E8E9EA;
    --sidebar-hover:     #d4d5d7;
    --sidebar-active-bg: #ffffff;
    --sidebar-active:    #081028;
    --text-main:         #333333;
    --text-muted:        #6c757d;
    --text-light:        #9a9ca3;
    --card-radius:       8px;
    --card-shadow:       0 2px 10px rgba(0,0,0,0.08);
    --card-border:       1px solid #e5e7eb;
    --input-radius:      6px;
    --input-border:      #ced4da;
    --navbar-h:          56px;
    --sidebar-w:         290px;
    --sidebar-w-min:     56px;
    --t-fast:            0.15s ease;
    --t-norm:            0.3s ease;
    --green:  #28a745; --red: #dc3545; --orange: #fd7e14;
    --blue:   #12224f; --teal: #20c997; --purple: #6f42c1;
}

/* === BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; overflow: hidden; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px; line-height: 1.5;
    color: var(--text-main);
    background: var(--bg-page);
    height: 100%;
    overflow: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: none; }

/* === LAYOUT === */
.wrapper {
    display: flex;
    margin-top: var(--navbar-h);
    height: calc(100vh - var(--navbar-h));
    overflow: hidden;
}
.content {
    flex: 1;
    min-width: 0;
    padding: 22px 26px;
    background: var(--bg-page);
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    transition: margin-left var(--t-norm);
}
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: #c8c8c8; border-radius: 4px; }

/* === NAVBAR === */
.app-navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1050;
    height: var(--navbar-h);
    background: var(--primary);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.navbar-left, .navbar-right { display: flex; align-items: center; gap: 10px; }
.navbar-brand {
    color: #fff; font-size: 1.15rem; font-weight: 700;
    letter-spacing: 0.3px; white-space: nowrap;
}
.navbar-brand span { color: #2DBE9D; }
.navbar-subtitle { color: rgba(255,255,255,0.6); font-size: 0.75rem; font-weight: 400; }
.btn-nav {
    background: none; border: none; color: #fff;
    padding: 6px 10px; border-radius: 6px; cursor: pointer;
    font-size: 1rem; display: flex; align-items: center; gap: 6px;
    transition: background var(--t-fast);
}
.btn-nav:hover { background: rgba(255,255,255,0.15); }
.nav-file-badge {
    background: rgba(255,255,255,0.18); color: #fff;
    padding: 3px 10px; border-radius: 10px; font-size: 0.75rem;
    display: flex; align-items: center; gap: 5px; max-width: 220px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-file-badge i { color: var(--accent); flex-shrink: 0; }
.nav-user-name {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === SIDEBAR === */
.app-sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid #d0d2d4;
    display: flex; flex-direction: column;
    transition: width var(--t-norm), min-width var(--t-norm);
    overflow: hidden; z-index: 1040;
    position: sticky; top: var(--navbar-h);
    height: calc(100vh - var(--navbar-h));
}
.app-sidebar.collapsed { width: var(--sidebar-w-min); min-width: var(--sidebar-w-min); }

.sb-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 0 12px; }
.sb-scroll::-webkit-scrollbar { width: 4px; }
.sb-scroll::-webkit-scrollbar-thumb { background: #c0c0c0; border-radius: 2px; }

/* ── SIDEBAR: 3-LEVEL STRUCTURE ──────────────────────────────── */

/* LEVEL 0: section divider label */
.sb-section-title {
    padding: 12px 14px 3px;
    font-size: 0.65rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-light); white-space: nowrap;
    border-top: 1px solid #d8d9db; margin-top: 4px;
}
.sb-section-title:first-child { border-top: none; margin-top: 0; }

/* LEVEL 1: main menu button (Arquivo, Dados, Calc, Estat, Gráficos…) */
.sb-menu-btn {
    display: flex; align-items: center; width: 100%;
    padding: 10px 14px; background: none; border: none;
    color: var(--text-main); cursor: pointer;
    font-size: 0.86rem; font-weight: 700;
    transition: background var(--t-fast), border-left-color var(--t-fast);
    text-align: left; gap: 10px;
    border-left: 3px solid transparent;
    white-space: nowrap;
}
.sb-menu-btn:hover { background: var(--sidebar-hover); }
.sb-menu-btn[aria-expanded="true"],
.sb-menu-btn.sb-active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: rgba(8,16,40,0.06);
}
.sb-menu-btn .sb-menu-icon {
    width: 20px; text-align: center; font-size: 0.95rem;
    color: var(--primary); flex-shrink: 0;
}
.sb-menu-btn[aria-expanded="true"] .sb-arrow { transform: rotate(90deg); }
.sb-menu-btn .sb-arrow {
    font-size: 0.6rem; color: var(--text-muted);
    transition: transform var(--t-fast); margin-left: auto; flex-shrink: 0;
}

/* LEVEL 1 body: contains sub-groups or leaf items */
.sb-menu-body { padding: 0 0 4px; }

/* LEVEL 2: sub-category button (Estat.Básicas, ANOVA, Regressão…) */
.sb-group-btn {
    display: flex; align-items: center; width: 100%;
    padding: 7px 12px 7px 28px; background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    font-size: 0.8rem; font-weight: 600;
    transition: all var(--t-fast); text-align: left; gap: 8px;
    white-space: nowrap;
}
.sb-group-btn:hover { background: var(--sidebar-hover); color: var(--text-main); }
.sb-group-btn[aria-expanded="true"] { color: var(--primary); }
.sb-group-btn .sb-arrow {
    font-size: 0.55rem; margin-left: auto; flex-shrink: 0;
    transition: transform var(--t-fast);
}
.sb-group-btn[aria-expanded="true"] .sb-arrow { transform: rotate(90deg); }
.sb-group-btn i:first-child { width: 16px; text-align: center; flex-shrink: 0; font-size: 0.78rem; }

/* LEVEL 2 body */
.sb-group-body { padding: 0; }

/* LEVEL 3: nested sub-group button (submenus within Regressão, etc.) */
.sb-subgroup-btn {
    display: flex; align-items: center; width: 100%;
    padding: 6px 12px 6px 42px; background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    font-size: 0.78rem; font-weight: 500;
    transition: all var(--t-fast); text-align: left; gap: 8px;
    white-space: nowrap;
}
.sb-subgroup-btn:hover { background: var(--sidebar-hover); color: var(--text-main); }
.sb-subgroup-btn[aria-expanded="true"] { color: var(--primary); }
.sb-subgroup-btn .sb-arrow {
    font-size: 0.55rem; margin-left: auto; flex-shrink: 0;
    transition: transform var(--t-fast);
}
.sb-subgroup-btn[aria-expanded="true"] .sb-arrow { transform: rotate(90deg); }
.sb-subgroup-btn i:first-child { width: 16px; text-align: center; flex-shrink: 0; font-size: 0.75rem; }

/* LEVEL 3 body */
.sb-subgroup-body { padding: 0; }

/* LEVEL 4: nested leaf */
.sb-sub-leaf {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 12px 5px 56px;
    color: #555; font-size: 0.76rem; font-weight: 400;
    transition: all var(--t-fast); white-space: nowrap;
    border-left: 2px solid transparent;
    text-decoration: none;
}
.sb-sub-leaf:hover { background: var(--sidebar-hover); color: var(--text-main); text-decoration: none; }
.sb-sub-leaf.active {
    background: var(--sidebar-active-bg);
    color: var(--primary); font-weight: 700;
    border-left-color: var(--primary);
}
.sb-sub-leaf i { width: 14px; text-align: center; font-size: 0.72rem; flex-shrink: 0; color: var(--text-muted); }
.sb-sub-leaf.active i { color: var(--primary); }

/* Disabled nested leaf */
.sb-sub-leaf.sb-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    color: var(--text-muted);
}
.sb-sub-leaf.sb-disabled:hover {
    background: transparent;
    color: var(--text-muted);
}
.sb-sub-leaf.sb-disabled i {
    color: var(--text-light);
}

/* LEVEL 3: leaf tool link (renamed from original LEVEL 3) */
.sb-leaf {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px 6px 42px;
    color: #555; font-size: 0.79rem; font-weight: 400;
    transition: all var(--t-fast); white-space: nowrap;
    border-left: 2px solid transparent;
    text-decoration: none;
}
.sb-leaf:hover { background: var(--sidebar-hover); color: var(--text-main); text-decoration: none; }
.sb-leaf.active {
    background: var(--sidebar-active-bg);
    color: var(--primary); font-weight: 700;
    border-left-color: var(--primary);
}
.sb-leaf i { width: 14px; text-align: center; font-size: 0.75rem; flex-shrink: 0; color: var(--text-muted); }
.sb-leaf.active i { color: var(--primary); }

/* Direct leaf (no sub-group, under level 1) */
.sb-direct-leaf {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 12px 7px 30px;
    color: var(--text-main); font-size: 0.83rem; font-weight: 400;
    transition: all var(--t-fast); white-space: nowrap;
    border-left: 2px solid transparent;
    text-decoration: none;
}
.sb-direct-leaf:hover { background: var(--sidebar-hover); color: var(--text-main); text-decoration: none; }
.sb-direct-leaf.active {
    background: var(--sidebar-active-bg);
    color: var(--primary); font-weight: 700;
    border-left-color: var(--primary);
}
.sb-direct-leaf i { width: 18px; text-align: center; font-size: 0.85rem; flex-shrink: 0; color: var(--text-muted); }
.sb-direct-leaf.active i { color: var(--primary); }

/* Disabled leaf (no dataset loaded) */
.sb-leaf.sb-disabled,
.sb-direct-leaf.sb-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    color: var(--text-muted);
}
.sb-leaf.sb-disabled:hover,
.sb-direct-leaf.sb-disabled:hover {
    background: transparent;
    color: var(--text-muted);
}
.sb-leaf.sb-disabled i,
.sb-direct-leaf.sb-disabled i {
    color: var(--text-light);
}

/* Disabled menu / group buttons */
.sb-menu-btn.sb-disabled,
.sb-group-btn.sb-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    color: var(--text-muted);
}
.sb-menu-btn.sb-disabled:hover,
.sb-group-btn.sb-disabled:hover {
    background: transparent;
    color: var(--text-muted);
}
.sb-menu-btn.sb-disabled i,
.sb-group-btn.sb-disabled i {
    color: var(--text-light);
}

/* Collapsed sidebar: hide text layers */
.app-sidebar.collapsed .sb-section-title,
.app-sidebar.collapsed .sb-text,
.app-sidebar.collapsed .sb-arrow,
.app-sidebar.collapsed .sb-menu-body,
.app-sidebar.collapsed .sb-group-body,
.app-sidebar.collapsed .sb-subgroup-body { display: none; }
.app-sidebar.collapsed .sb-menu-btn { justify-content: center; padding: 11px 0; border-left: none; }
.app-sidebar.collapsed .sb-menu-btn .sb-menu-icon { margin: 0; font-size: 1.1rem; }

/* Legacy compatibility (keep old selectors working if any ref remains) */
.sb-cat-btn { display: none; }
.sb-item { display: none; }

/* Sidebar bottom toggle */
.sb-footer {
    border-top: 1px solid #d0d2d4; padding: 8px;
}
.sb-footer button {
    width: 100%; background: none; border: none;
    color: var(--text-muted); padding: 7px; cursor: pointer;
    border-radius: 6px; transition: background var(--t-fast);
    font-size: 0.82rem; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.sb-footer button:hover { background: var(--sidebar-hover); }
.sb-footer button i { transition: transform var(--t-norm); }
.app-sidebar.collapsed .sb-footer button i { transform: rotate(180deg); }

/* ── SIDEBAR FLYOUT (collapsed mode) ──────────────────────────── */
/* Level 1: main menu flyout (subgroups only) */
.sb-flyout {
    position: fixed;
    left: var(--sidebar-w-min);
    min-width: 220px;
    max-width: 260px;
    background: var(--bg-sidebar);
    border: 1px solid #d0d2d4;
    border-left: none;
    border-radius: 0 8px 8px 0;
    box-shadow: 4px 4px 20px rgba(0,0,0,0.15);
    z-index: 1050;
    padding: 0;
    display: none;
}
.sb-flyout.show { display: block; }

.sb-flyout-header {
    padding: 10px 14px;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--primary);
    border-bottom: 1px solid #d0d2d4;
    background: rgba(8,16,40,0.05);
    white-space: nowrap;
    border-radius: 0 8px 0 0;
}

.sb-flyout-link {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 14px;
    color: var(--text-main);
    font-size: 0.82rem;
    text-decoration: none;
    white-space: nowrap;
    border-left: 3px solid transparent;
    transition: all var(--t-fast);
}
.sb-flyout-link:hover {
    background: var(--sidebar-hover);
    color: var(--primary);
    text-decoration: none;
}
.sb-flyout-link i { width: 16px; text-align: center; font-size: 0.8rem; color: var(--text-muted); flex-shrink: 0; }
.sb-flyout-link.active { background: var(--sidebar-active-bg); color: var(--primary); font-weight: 700; border-left-color: var(--primary); }
.sb-flyout-link.active i { color: var(--primary); }
.sb-flyout-link.sb-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    color: var(--text-muted);
}
.sb-flyout-link.sb-disabled:hover {
    background: transparent;
    color: var(--text-muted);
}

/* Sub-group button in flyout (level 1 → level 2) */
.sb-flyout-group-btn {
    display: flex; align-items: center;
    width: 100%;
    padding: 7px 14px;
    background: none; border: none;
    color: var(--text-main);
    font-size: 0.82rem; font-weight: 600;
    cursor: pointer;
    text-align: left;
    gap: 8px;
    border-left: 3px solid transparent;
    transition: all var(--t-fast);
    white-space: nowrap;
}
.sb-flyout-group-btn:hover { background: var(--sidebar-hover); color: var(--primary); }
.sb-flyout-group-btn i:first-child { width: 16px; text-align: center; font-size: 0.8rem; color: var(--text-muted); flex-shrink: 0; }
.sb-flyout-arrow { margin-left: auto; font-size: 0.55rem; color: var(--text-muted); transition: transform var(--t-fast); flex-shrink: 0; }

/* Level 2: cascaded panel (fixed, separate from level 1) */
.sb-flyout-cascade {
    position: fixed;
    min-width: 220px;
    max-width: 280px;
    background: var(--bg-sidebar);
    border: 1px solid #d0d2d4;
    border-radius: 0 8px 8px 0;
    box-shadow: 4px 4px 20px rgba(0,0,0,0.15);
    z-index: 1060;
    max-height: calc(100vh - var(--navbar-h) - 20px);
    overflow-y: auto;
    padding: 6px 0;
    display: none;
}
.sb-flyout-cascade.show { display: block; }
.sb-flyout-cascade::-webkit-scrollbar { width: 4px; }
.sb-flyout-cascade::-webkit-scrollbar-thumb { background: #c0c0c0; border-radius: 2px; }

/* Connector line between flyout levels */
.sb-flyout-connector {
    position: fixed;
    width: 8px;
    height: 1px;
    background: #d0d2d4;
    z-index: 1055;
    display: none;
}
.sb-flyout-connector.show { display: block; }

/* === PAGE HEADER === */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; padding-bottom: 14px;
    border-bottom: 2px solid var(--primary);
}
.page-header h1 {
    font-size: 1.55rem; font-weight: 700; color: var(--text-main);
    display: flex; align-items: center; gap: 10px; margin: 0;
}
.page-header h1 i { color: var(--primary); }
.page-header .page-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-top: 3px; }

/* === CARDS === */
.panel {
    background: var(--bg-card);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: var(--card-border);
    margin-bottom: 20px; overflow: hidden;
}
.panel-header {
    background: var(--bg-header);
    padding: 11px 18px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600; font-size: 0.9rem;
    color: var(--text-main);
}
.panel-header i { color: var(--primary); margin-right: 8px; }
.panel-body { padding: 18px 20px; }
.panel-footer { padding: 10px 18px; border-top: 1px solid #e5e7eb; background: var(--bg-header); }

/* Shortcut/KPI cards (home page) */
.shortcut-card {
    background: var(--bg-card);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: var(--card-border);
    padding: 24px 20px; text-align: center; cursor: pointer;
    transition: transform var(--t-fast), box-shadow var(--t-fast);
    display: block; color: var(--text-main);
}
.shortcut-card:hover { transform: translateY(-3px); box-shadow: 0 5px 18px rgba(0,0,0,0.12); color: var(--text-main); }
.shortcut-icon {
    width: 56px; height: 56px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center; margin: 0 auto 12px;
}
.shortcut-icon i { font-size: 1.6rem; color: #fff; }
.shortcut-card h6 { font-size: 0.92rem; font-weight: 600; margin-bottom: 4px; }
.shortcut-card p { font-size: 0.78rem; color: var(--text-muted); margin: 0; line-height: 1.4; }

/* Tool header inside analysis */
.tool-header {
    display: flex; align-items: flex-start; gap: 14px;
    margin-bottom: 16px; flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
    background: #f5f6fa;
    padding: 10px;
    margin-top: -22px;
    width: 100%;
    box-sizing: border-box;
    isolation: isolate;
    transform: translateZ(0);
}
.tool-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}
.tool-meta-right { display: flex; align-items: center; }
.tool-icon {
    width: 48px; height: 48px; border-radius: 12px;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tool-icon i { color: #fff; font-size: 1.3rem; }
.tool-meta h2 { font-size: 1.3rem; font-weight: 700; margin: 0; color: var(--text-main); }
.tool-meta p { font-size: 0.83rem; color: var(--text-muted); margin: 3px 0 0; }

/* === FORMS === */
.form-control, .form-select {
    border: 1px solid var(--input-border);
    border-radius: var(--input-radius);
    font-size: 0.87rem; padding: 7px 11px;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(8,16,40,0.15);
    outline: none;
}
.form-label { font-size: 0.83rem; font-weight: 600; color: var(--text-main); margin-bottom: 4px; }
.form-text { font-size: 0.76rem; color: var(--text-muted); }

/* === BUTTONS === */
.btn-primary {
    background: var(--primary); border-color: var(--primary);
    font-weight: 600; font-size: 0.87rem;
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-dark); border-color: var(--primary-dark);
}
.btn-outline-primary { color: var(--primary); border-color: var(--primary); font-size: 0.87rem; }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-accent {
    background: var(--accent); border-color: var(--accent);
    color: #111; font-weight: 700;
}
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #111; }
.btn-run {
    background: var(--primary); color: #fff; border: none;
    padding: 9px 22px; border-radius: 6px; font-weight: 600; font-size: 0.88rem;
    cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
    transition: background var(--t-fast), transform var(--t-fast);
    width: 100%; justify-content: center; margin-top: 6px;
}
.btn-run:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-run:disabled,
.btn-run.btn-running {
  opacity: 0.85;
  cursor: wait;
  transform: none;
  pointer-events: none;
}

.btn-run .btn-spinner,
.btn-primary .btn-spinner {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.35em;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* === TABLES === */
.result-table-wrap { overflow-x: auto; overflow-y: hidden; border-radius: 6px; width: 100%; max-width: 100%; }
.result-table-wrap table { margin: 0; font-size: 0.83rem; width: 100%; border-collapse: collapse; table-layout: auto; }
.result-table-wrap thead th {
    background: var(--bg-header); color: #344054;
    font-weight: 600; font-size: 0.78rem; padding: 9px 12px;
    white-space: nowrap; text-transform: uppercase; letter-spacing: 0.3px;
    position: sticky; top: 0; border-bottom: 2px solid #d0d2d4;
}
.result-table-wrap tbody td { padding: 7px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.result-table-wrap tbody tr:nth-child(even) { background: #f9fafb; }
.result-table-wrap tbody tr:hover { background: #e8f0fe; }
/* Override Bootstrap table used in statistics.py */
.table { font-size: 0.83rem; }
.table thead th {
    background: var(--bg-header); color: #344054;
    font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.3px; border-bottom-width: 2px;
}

/* === ALERTS === */
.alert { border-radius: 6px; font-size: 0.87rem; }
.alert-danger { background: #fff0f0; border-color: #f5c2c7; color: #842029; }
.alert-success { background: #f0fff4; border-color: #b7dfca; color: #1a5e35; }
.alert-warning { background: #fffbec; border-color: #f7e4a3; color: #6b4c0a; }
.alert-info { background: #f0f5ff; border-color: #b6ccf5; color: #1a3577; }

/* === DL (result dict display) === */
dl.row dt { font-weight: 600; font-size: 0.85rem; color: var(--primary); padding-top: 5px; }
dl.row dd { font-size: 0.85rem; padding-top: 5px; word-break: break-word; }
dl.row pre { font-size: 0.78rem; background: #f8f9fa; padding: 8px; border-radius: 4px; margin: 0; }

/* === RESULT IMAGE === */
.result-img { max-width: 100%; border-radius: 6px; box-shadow: var(--card-shadow); }

/* === Assistant Modal Layout === */
.assistant-flow {
    display: grid;
    gap: 22px;
    position: relative;
}
.flow-chart {
    grid-template-columns: 1fr;
}
.flow-row {
    display: grid;
    gap: 16px;
}
.flow-options,
.flow-suboptions {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.flow-result {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.flow-node {
    position: relative;
    min-height: 70px;
    padding: 18px 20px;
    text-align: center;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #d8dadd;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
    font-weight: 700;
    color: var(--text-main);
    display: grid;
    place-items: center;
}
.flow-node::after {
    content: '';
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 18px;
    background: #c3c7d1;
}
.flow-row.flow-result .assistant-flow-card {
    position: relative;
    min-width: 220px;
}
.flow-row.flow-result .assistant-flow-card::before {
    content: '';
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 18px;
    background: #c3c7d1;
}
.flow-row.flow-result .assistant-flow-card:first-child::before {
    top: -12px;
}
.assistant-flow-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    border: 1px solid #e6e8ed;
    border-radius: 14px;
    background: var(--bg-card);
    color: inherit;
    text-decoration: none;
    transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
}
.assistant-flow-card:hover,
.assistant-flow-card:focus {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.1);
    border-color: rgba(8,16,40, 0.18);
}
.assistant-flow-card .icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
}
.assistant-flow-card h6 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}
.assistant-flow-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

/* === UPLOAD ZONE === */
.upload-zone {
    border: 2px dashed #b0b4ba;
    border-radius: 10px; padding: 36px 24px; text-align: center;
    cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast);
    background: #fafbfc;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--primary); background: #f0f4ff; }
.upload-zone i { font-size: 2.4rem; color: #b0b4ba; margin-bottom: 12px; transition: color var(--t-fast); }
.upload-zone:hover i { color: var(--primary); }
.upload-zone p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
.upload-zone .upload-hint { font-size: 0.78rem; color: var(--text-light); margin-top: 6px; }

/* === BADGE === */
.badge-pill { padding: 3px 10px; border-radius: 10px; font-size: 0.73rem; font-weight: 600; }
.badge-primary { background: var(--primary); color: #fff; }
.badge-accent { background: var(--accent); color: #111; }
.badge-muted { background: #e5e7eb; color: var(--text-muted); }

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.8rem; opacity: 0.3; margin-bottom: 14px; }
.empty-state p { font-size: 0.92rem; margin-top: 6px; }

/* ── CONFIG PANEL (top, full-width) ─────────────────────────────── */
.config-panel { margin-bottom: 14px; }

/* Flex row of fields — wraps naturally at smaller sizes */
.config-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px 18px;
}

/* Individual field wrapper */
.cfg-field {
    display: flex;
    flex-direction: column;
    min-width: 180px;
    flex: 1 1 180px;
    max-width: 280px;
}
.cfg-field--wide { min-width: 240px; flex: 2 1 240px; max-width: 360px; }
.cfg-field--sm   { min-width: 130px; flex: 0 1 150px; max-width: 160px; }

/* Run button wrapper — pushes to baseline */
.cfg-run {
    display: flex;
    align-items: flex-end;
    flex-shrink: 0;
}
.cfg-run .btn-run {
    width: auto;
    padding: 8px 26px;
    white-space: nowrap;
}

/* Inline info text inside config row */
.config-info {
    align-self: center;
    font-size: 0.83rem;
    color: var(--text-muted);
    background: #f0f4ff;
    border: 1px solid #c8d4f8;
    border-radius: 6px;
    padding: 7px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 200px;
}
.config-info i { color: var(--primary); }

/* ── RESULT PANEL ────────────────────────────────────────────────── */
.result-panel { margin-top: 16px; }
.result-chart-wrap {
    width: 100%;
    padding: 8px 0 16px;
}
.result-chart-wrap .result-img { max-width: 100%; max-height: 560px; object-fit: contain; }
/* Plotly charts fill their wrapper width and remain responsive */
.result-chart-wrap > div,
.result-chart-wrap .plotly-graph-div,
.result-section > div,
.result-section .plotly-graph-div {
    width: 100% !important;
    min-width: 0;
}
.js-plotly-plot .plotly { overflow: visible; }
/* Chart sections inside result-table-wrap should be full-width */
.result-section:has(.plotly-graph-div) {
    flex: 1 1 100%;
}

/* Fitted Line Plot — gráfico principal em largura total */
.fl-main-chart {
    width: 100% !important;
    flex: 1 1 100% !important;
}
.fl-main-chart .plotly-graph-div {
    width: 100% !important;
}

/* Desc-wrap sections dentro de result-table-wrap — largura total */
.result-table-wrap > .desc-wrap {
    width: 100%;
}
.result-table-wrap .desc-sec {
    flex: 1 1 100%;
    min-width: 100%;
}

/* Multi-section result layout */
.result-table-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: flex-start;
}
.result-table-wrap .desc-charts-grid {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Standard chart grid used across all analysis tools.
   NOTA: as regras .desc-charts-grid / .desc-chart-cell foram centralizadas
   em static/css/charts.css. Não redeclare aspect-ratio/height aqui —
   main.css é carregado ANTES de charts.css, mas propriedades com
   !important aqui teriam prioridade e sobrescreveriam a altura definida
   em CHART_HEIGHT (services/stats/_chart_theme.py). */
/* Legado: aliases visuais do padrão canônico desc-sec/desc-sec-title
   (largura total empilhada — igual à tela Estatísticas Básicas). */
.result-section {
    flex: 1 1 100%;
    min-width: 100%;
    margin-bottom: 22px;
}
.result-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 4px;
    margin-bottom: 10px;
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Desc-cards (shared with test results) */
.desc-wrap { width: 100%; box-sizing: border-box; }
.desc-cards { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; width: 100%; }
.desc-card {
    background: #e6f4f0; border: 1px solid #ccd4dd; border-radius: 8px;
    padding: 10px 18px; flex: 1 1 0; min-width: 80px; text-align: center;
}
.desc-card__val { font-size: 1.5rem; font-weight: 700; color: var(--primary); line-height: 1; }
.desc-card__lbl { font-size: .7rem; color: #6c757d; margin-top: 3px; }
.desc-sec { margin-bottom: 22px; width: 100%; }

/* === TABELAS DE RESULTADO — padrão canônico =========================
   Referência: tela Estatísticas Básicas > Estatísticas Descritivas.
   Toda tabela de resultado usa <table class="desc-tbl"> dentro de
   <div class="desc-tbl-wrap" data-fixed-cols="N">; seções usam
   .desc-sec + .desc-sec-title; blocos por variável/grupo usam
   .desc-var-title + .desc-var-inner (+ .desc-group-badge).
   Especificidade igual às regras genéricas acima — estas vencem por
   estarem declaradas depois. */
.desc-group-wrap { margin-bottom: 30px; }
.desc-sec-title {
    font-size: .9rem; font-weight: 700; color: var(--primary);
    border-bottom: 2px solid var(--primary); padding-bottom: 4px;
    margin-bottom: 10px; margin-top: 0;
    display: flex; align-items: center; gap: 8px;
}
.desc-tbl-wrap { width: 100%; overflow-x: visible; margin-bottom: 10px; }
.desc-tbl {
    width: 100%; border-collapse: collapse;
    font-size: .81rem; table-layout: auto;
}
.desc-tbl.last-tbl { width: auto; min-width: 0; }
.desc-tbl thead th {
    background: #f6f8fa; color: #4C5968; padding: 5px 10px;
    font-weight: 700; text-align: right; white-space: nowrap;
    border-bottom: 2px solid #cfd6dd; border-top: 1px solid #e3e8ee;
}
.desc-tbl thead th:first-child { text-align: left; }
.desc-tbl tbody td {
    padding: 4px 10px; text-align: right;
    border-bottom: 1px solid #eef1f5; white-space: nowrap;
}
.desc-tbl tbody td:first-child { text-align: left; font-weight: 600; color: var(--primary); }
.desc-tbl tbody tr:hover td { background: #e6f4f0; }
.desc-tbl th.sortable-header { cursor: pointer; user-select: none; }
.desc-tbl td.cell-wide { min-width: 220px; }
.desc-tbl th.cell-w20 { width: 20%; }
.desc-var-title {
    background: #e9ecef; color: #495057; padding: 7px 14px;
    border-radius: 6px 6px 0 0; font-weight: 700; font-size: .88rem;
    display: flex; align-items: center; gap: 8px; margin-top: 18px;
}
.desc-var-inner {
    border: 1px solid #e3e8ee; border-top: none;
    border-radius: 0 0 6px 6px; padding: 12px; background: #fff;
}
.desc-group-badge {
    background: #e8ecf8; border: 1px solid #ccd4dd; border-radius: 6px;
    padding: 2px 10px; font-size: .72rem; color: var(--primary);
    margin-left: auto; font-weight: 400;
}
/* Nota de rodapé sob tabela + linhas texto de método/hipótese */
.desc-tbl-note { font-size: .78rem; color: #555; font-style: italic; margin-top: 4px; }
.method-line, .hypothesis-line {
    display: flex; gap: 12px; align-items: baseline;
    font-size: .85rem; padding: 2px 0;
}
.method-line span, .hypothesis-line span {
    font-weight: 600; color: #4C5968; min-width: 140px;
}
.method-line strong, .hypothesis-line strong {
    font-weight: 600; color: var(--primary);
}
.flp-equation { font-size: 0.9rem; font-weight: 500; color: #1a1a1a; margin: 0 0 .5rem 0; }

/* Key-value table (test results) — cobre markup com classes
   kv-key/kv-val e markup plano (th=chave, td=valor). */
.kv-table { width: 100%; border-collapse: collapse; }
.kv-table tbody tr:nth-child(odd) { background: #f8f9ff; }
.kv-key, .kv-table th {
    font-weight: 600;
    font-size: 0.79rem;
    color: var(--text-muted);
    width: 52%;
    padding: 4px 8px;
    vertical-align: top;
    text-align: left;
    border: 1px solid #e5e7eb;
}
.kv-val, .kv-table td {
    font-size: 0.82rem;
    color: var(--text-main);
    padding: 4px 8px;
    vertical-align: top;
    text-align: right;
    border: 1px solid #e5e7eb;
}

/* Significance stars */
.result-table-wrap .table td,
.result-table-wrap .table th {
    font-size: 0.8rem;
    padding: 4px 8px;
    vertical-align: middle;
}

/* ── P-VALUE BADGE (panel-header inline) ──────────────────────────── */
.pvalue-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: 20px; font-size: 0.78rem; font-weight: 700;
    border: 1.5px solid; cursor: default; white-space: nowrap;
}
.pvalue-badge--sig {
    background: #eafaf1; border-color: #198754; color: #1e7e34;
}
.pvalue-badge--ns {
    background: #fef9e7; border-color: #e6a23c; color: #c0620a;
}
.pvalue-badge__label {
    font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .04em; opacity: .75;
}
.pvalue-badge__val { font-size: 0.9rem; }
.pvalue-badge__stars { letter-spacing: 1px; }

/* ── P-VALUE BAR (full-width, below panel-header) ─────────────────── */
.pvalue-bar {
    padding: 10px 20px 12px;
    border-bottom: 1px solid #e5e7eb;
}
.pvalue-bar--sig { background: linear-gradient(90deg,#eafaf1 0%,#f6fffa 100%); }
.pvalue-bar--ns  { background: linear-gradient(90deg,#fef9e7 0%,#fffdf4 100%); }
.pvalue-bar__inner {
    display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.pvalue-bar__number {
    font-size: 1.45rem; font-weight: 800; min-width: 110px;
    color: var(--primary);
}
.pvalue-bar--sig .pvalue-bar__number { color: #1e7e34; }
.pvalue-bar--ns  .pvalue-bar__number { color: #c0620a; }
.pvalue-bar__verdict {
    font-size: 0.88rem; font-weight: 600; flex: 1; min-width: 200px;
    color: var(--text-main);
}
.pvalue-bar__scale {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.72rem; color: var(--text-muted); min-width: 220px; flex: 2;
}
.pvalue-bar__track {
    flex: 1; height: 8px; border-radius: 4px;
    background: #e9ecef; position: relative; overflow: visible;
}
.pvalue-bar__fill {
    height: 100%; border-radius: 4px;
    background: linear-gradient(90deg,#198754,#7fdcc9);
    transition: width .5s ease;
}
.pvalue-bar--ns .pvalue-bar__fill {
    background: linear-gradient(90deg,#e6a23c,#f5cd8a);
}
.pvalue-bar__marker {
    position: absolute; top: -4px;
    width: 2px; height: 16px; background: #e74c3c;
    border-radius: 1px;
}
.pvalue-bar__marker::after {
    content: 'α'; position: absolute; top: -14px; left: -5px;
    font-size: 0.6rem; color: #e74c3c; font-weight: 700;
}

/* ── GROUP-BY selector ────────────────────────────────────────────── */
.cfg-groupby {
    border-top: 1px dashed #d0d7e2;
    padding-top: 10px;
    margin-top: 4px;
}
.cfg-groupby .form-label { color: var(--primary); font-weight: 600; }

/* ── GROUP SECTION (result blocks) ────────────────────────────────── */
.group-section {
    border: 1px solid #d6e4f7;
    border-radius: 8px;
    margin-bottom: 18px;
    overflow: hidden;
}
.group-section-header {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 16px; font-size: 0.88rem;
    background: linear-gradient(90deg, #eaf1fb 0%, #f4f8ff 100%);
    border-bottom: 1px solid #c8daf5;
    border-left: 4px solid var(--primary);
}
.group-section-header i { color: var(--primary); }
.group-section-header .group-val {
    font-weight: 700; color: var(--primary); font-size: 0.95rem;
}
.group-section-header .group-n {
    margin-left: auto; font-size: 0.78rem;
    color: var(--text-muted); background: #dce8f8;
    padding: 1px 7px; border-radius: 10px;
}
.group-section > .result-chart-wrap,
.group-section > .result-table-wrap,
.group-section > .kv-table,
.group-section > table { padding: 12px 16px; }

/* ── GROUP-BY badge in results header ─────────────────────────────── */
.group-by-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 10px; border-radius: 12px; font-size: 0.78rem;
    background: #eaf1fb; border: 1px solid #b8d0ee; color: var(--primary);
}

/* === RESPONSIVE === */
@media (max-width: 991px) {
    .app-sidebar { position: fixed; top: var(--navbar-h); left: 0; bottom: 0; z-index: 1040; box-shadow: 4px 0 16px rgba(0,0,0,0.12); }
    .app-sidebar.collapsed { transform: translateX(-100%); width: var(--sidebar-w); }
    .content { margin-left: 0 !important; max-height: unset; }
}
@media (max-width: 575px) {
    .panel-body { padding: 12px 14px; }
    .page-header h1 { font-size: 1.2rem; }
}

/* ═══════════════════════════════════════════════════════════════════
   ASSISTANT MODALS - Padrao visual unificado Reliam Analytics
   ═══════════════════════════════════════════════════════════════════ */

/* Decision Diamond - Large */
.decision-diamond {
    display: inline-block;
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, rgba(8,16,40,0.18) 0%, rgba(8,16,40,0.28) 100%);
    border: 2px solid rgba(8,16,40,0.35);
    transform: rotate(45deg);
    border-radius: 8px;
    position: relative;
    box-shadow: 0 4px 12px rgba(8,16,40,0.12);
    margin: 20px;
}
.decision-diamond span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-align: center;
    width: 140%;
    line-height: 1.3;
}

/* Decision Diamond - Small */
.decision-diamond-sm {
    display: inline-block;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, rgba(8,16,40,0.18) 0%, rgba(8,16,40,0.28) 100%);
    border: 2px solid rgba(8,16,40,0.35);
    transform: rotate(45deg);
    border-radius: 6px;
    position: relative;
    box-shadow: 0 2px 8px rgba(8,16,40,0.08);
    margin: 10px;
}
.decision-diamond-sm small {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--primary);
    text-align: center;
    width: 140%;
    line-height: 1.2;
}

/* Flow connectors */
.flow-connector-v {
    width: 2px;
    height: 24px;
    background: #9ca3af;
    margin: 0 auto;
    position: relative;
}
.flow-connector-v::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: -3px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #9ca3af;
}
.flow-connector-h {
    height: 2px;
    background: #9ca3af;
    position: relative;
    margin: 12px 0;
}
.flow-connector-h::after {
    content: '';
    position: absolute;
    right: -5px;
    top: -4px;
    width: 0;
    height: 0;
    border-left: 6px solid #9ca3af;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
}
.flow-connector-h-left::after {
    right: auto;
    left: -5px;
    border-left: none;
    border-right: 6px solid #9ca3af;
}
.flow-connector-h-center::after {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 5px solid #9ca3af;
    border-bottom: none;
    top: -5px;
}
.flow-branch-line {
    position: relative;
    padding-top: 20px;
}
.flow-branch-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: #9ca3af;
}
.flow-branch-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 20px;
    background: #9ca3af;
}

/* Assistant Modal - Uniform header with system primary color */
.assistant-modal .modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.assistant-modal .modal-header {
    background: var(--primary) !important;
    color: #fff !important;
    border-radius: 12px 12px 0 0;
    padding: 1rem 1.5rem;
}
.assistant-modal .modal-header .modal-title {
    font-weight: 600;
    font-size: 1.25rem;
    color: #fff;
}
.assistant-modal .modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}
.assistant-modal .modal-body {
    padding: 1.5rem;
    background: #f5f5f0;
}
.assistant-modal .modal-footer {
    background: #f5f5f0;
    border-radius: 0 0 12px 12px;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e0e0d8;
}

/* Assistant question text */
.assistant-question {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 1.1rem;
    letter-spacing: 0.3px;
}

/* Assistant Card */
.assistant-card {
    border: 1px solid #e0e0d8;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.assistant-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.assistant-card-header {
    background: #e8e4dc !important;
    color: #3a3530 !important;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 12px 16px;
    border-bottom: 1px solid #d8d4cc;
}
.assistant-card-header i {
    color: var(--primary);
}

/* Nested card inside assistant */
.assistant-nested-card {
    border: 1px solid #d8d4cc;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.assistant-card-header-nested {
    background: #f0ede8 !important;
    color: #3a3530 !important;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 10px 14px;
    border-bottom: 1px solid #e0dcd4;
}

/* Assistant Link Cards */
.assistant-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #fff;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid #e5e5e5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.assistant-link:hover {
    background: #f0f4ff;
    border-color: var(--primary);
    transform: translateX(4px);
    text-decoration: none;
    color: var(--primary);
}
.assistant-link i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    color: var(--primary);
}

/* DOE Flow */
.doe-flow {
    background: #f5f5f0;
    padding: 20px;
    border-radius: 12px;
}
.doe-box {
    background: #e8dcc8;
    padding: 20px;
    border-radius: 8px;
    color: #5a4a3a;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.doe-branch {
    display: flex;
    align-items: center;
    background: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border: 1px solid #e5e5e5;
}

/* Buttons inside assistant - use primary consistently */
.assistant-modal .btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}
.assistant-modal .btn-outline-primary:hover {
    background: var(--primary);
    color: #fff;
}
.assistant-modal .btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.assistant-modal .btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* ================================================================
   PDF Report Styles
   ================================================================ */
#report-pdf-container {
    width: 100%;
    max-width: 100%;
    background: #fff;
    color: #1a1a1a;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.85rem;
    line-height: 1.5;
}
#report-pdf-container .report-body {
    width: 100%;
}
#report-pdf-container .desc-sec {
    margin-bottom: 18px;
    width: 100%;
    page-break-inside: avoid;
    break-inside: avoid;
}
#report-pdf-container .desc-sec-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 4px;
    margin-bottom: 8px;
    page-break-after: avoid;
    break-after: avoid;
}
#report-pdf-container .desc-tbl {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    font-size: 0.65rem;
    table-layout: auto;
    page-break-inside: auto;
}
#report-pdf-container .desc-tbl thead {
    display: table-header-group;
}
#report-pdf-container .desc-tbl thead th {
    background: #f5f6fa;
    color: #344054;
    padding: 3px 5px;
    font-weight: 700;
    text-align: right;
    overflow-wrap: break-word;
    word-wrap: break-word;
    border-bottom: 2px solid #bec5d4;
    border-top: 1px solid #dde0ee;
}
#report-pdf-container .desc-tbl thead th:first-child {
    text-align: left;
}
#report-pdf-container .desc-tbl tbody td {
    padding: 3px 5px;
    text-align: right;
    border-bottom: 1px solid #eef0f8;
    overflow-wrap: break-word;
    word-wrap: break-word;
}
#report-pdf-container .desc-tbl tbody td:first-child {
    text-align: left;
    font-weight: 600;
    color: var(--primary);
}
#report-pdf-container .desc-tbl tbody tr {
    page-break-inside: avoid;
}
#report-pdf-container .desc-charts-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
}
#report-pdf-container .desc-chart-cell {
    flex: 1 1 48%;
    min-width: 200px;
    max-width: 48%;
    margin-bottom: 12px;
    page-break-inside: avoid;
    break-inside: avoid;
}
#report-pdf-container .fl-main-chart {
    width: 100%;
    margin-bottom: 12px;
    page-break-inside: avoid;
    break-inside: avoid;
}
#report-pdf-container .plotly-graph-div,
#report-pdf-container .result-chart-wrap,
#report-pdf-container .result-chart-wrap img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
}
#report-pdf-container .pvalue-bar {
    page-break-inside: avoid;
    break-inside: avoid;
}
#report-pdf-container .kv-table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    font-size: 0.65rem;
}
#report-pdf-container .kv-table td,
#report-pdf-container .kv-table th {
    padding: 3px 5px;
    border: 1px solid #e5e7eb;
    overflow-wrap: break-word;
    word-wrap: break-word;
}
#report-pdf-container .result-table-wrap {
    display: block;
    width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}
#report-pdf-container .table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    font-size: 0.65rem;
    table-layout: auto;
}
#report-pdf-container .table th,
#report-pdf-container .table td {
    padding: 3px 5px;
    border: 1px solid #e5e7eb;
    overflow-wrap: break-word;
    word-wrap: break-word;
}
#report-pdf-container .table thead th {
    word-wrap: break-word;
    overflow-wrap: break-word;
}
#report-pdf-container img,
#report-pdf-container svg {
    max-width: 100% !important;
    height: auto !important;
}
#report-pdf-container .result-section {
    flex: 1 1 100%;
    min-width: 100%;
    page-break-inside: avoid;
    break-inside: avoid;
}

/* ── Assistant Decision Flowchart (regression, capability, etc.) ── */
.adf-flowchart {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
}

/* Branch row: two (or more) arms with horizontal connector */
.adf-branch {
    display: flex;
    width: 100%;
    justify-content: space-around;
    position: relative;
    padding-top: 24px;
}
.adf-branch::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 24px;
    background: #9ca3af;
}
.adf-branch::after {
    content: '';
    position: absolute;
    top: 0;
    left: 16%;
    right: 16%;
    height: 2px;
    background: #9ca3af;
}

.adf-branch-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 280px;
    position: relative;
    padding-top: 24px;
}
.adf-branch-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 24px;
    background: #9ca3af;
}

/* Sub-branch: second-level split */
.adf-sub-branch {
    display: flex;
    width: 100%;
    justify-content: center;
    gap: 20px;
    position: relative;
    padding-top: 20px;
    margin-top: 4px;
}
.adf-sub-branch::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: #9ca3af;
}
.adf-sub-branch::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 20px;
    background: #9ca3af;
}

.adf-sub-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 200px;
    position: relative;
    padding-top: 20px;
}
.adf-sub-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 20px;
    background: #9ca3af;
}

/* Decision diamond wrapper to center properly */
.adf-diamond-wrap { display: flex; justify-content: center; }

/* Labels */
.adf-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #3a3530;
    background: #e8e4dc;
    padding: 4px 14px;
    border-radius: 6px;
    border: 1px solid #d8d4cc;
    margin-bottom: 4px;
    white-space: nowrap;
}

/* Result cards / action buttons */
.adf-card {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1.5px solid var(--primary);
    border-radius: 8px;
    background: #fff;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.adf-card:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(8,16,40,0.2);
}
.adf-card i { font-size: 0.9rem; }

/* Override diamond margins for flowchart context */
.adf-flowchart .decision-diamond { margin: 0 auto 0; }
.adf-flowchart .decision-diamond-sm { margin: 0 auto 4px; }

/* ── Assistant Wizard Card Layout ── */
.wiz-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 12px;
    row-gap: 16px;
    padding: 6px 0;
}

/* Pergunta — texto simples, sem balão */
.wiz-question {
    color: #3a3530;
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
    padding: 12px;
}

/* Espaço vazio para manter alinhamento do grid */
.wiz-empty { min-height: 1px; }

/* Sub-grid dentro de uma célula do grid principal */
.wiz-nested {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Resposta / opção — balão com fundo bege */
.wiz-answer {
    background: #e8e4dc;
    color: #3a3530;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    padding: 10px 8px;
    border-radius: 10px;
    border: 1px solid #d8d4cc;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ação final — card destaque com borda azul */
.wiz-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #fff;
    color: #081028;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    padding: 14px 12px;
    border-radius: 10px;
    border: 2px solid #081028;
    transition: all 0.2s ease;
    min-height: 52px;
}
.wiz-action:hover {
    background: #081028;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(8,16,40,0.25);
}

@media (max-width: 575px) {
    .wiz-wrap { grid-template-columns: 1fr; }
    .wiz-nested { grid-template-columns: 1fr; }
}

/* ================================================================
   Help Document Styles (contextual help modal)
   ================================================================ */
.help-doc {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #1a1a1a;
    background: #fff;
    padding: 0;
}
.help-doc-header {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #081028;
    color: #fff;
    padding: 18px 24px;
    border-bottom: 4px solid #00B088;
}
.help-doc-logo {
    display: flex;
    align-items: center;
    font-size: 1.4rem;
    font-weight: 700;
}
.help-doc-logo-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #00B088;
    color: #081028;
    border-radius: 6px;
    margin-right: 4px;
}
.help-doc-logo-text {
    color: #fff;
}
.help-doc-meta h1 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: #fff;
}
.help-doc-meta p {
    margin: 0;
    font-size: 0.82rem;
    color: #c8d0e8;
}
.help-doc-toc {
    background: #f5f6fa;
    padding: 16px 24px;
    border-bottom: 1px solid #e8eaed;
}
.help-doc-toc h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #081028;
    margin-bottom: 8px;
}
.help-doc-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}
.help-doc-toc li a {
    color: #12224f;
    text-decoration: none;
    font-size: 0.85rem;
}
.help-doc-toc li a:hover {
    text-decoration: underline;
}
.help-section {
    padding: 18px 24px;
    border-bottom: 1px solid #eef0f8;
}
.help-section h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #081028;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid #081028;
}
.help-section h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #344054;
    margin-top: 16px;
    margin-bottom: 8px;
}
.help-section h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: #344054;
    margin-top: 12px;
    margin-bottom: 6px;
}
.help-section p {
    margin-bottom: 10px;
}
.help-section ul,
.help-section ol {
    padding-left: 22px;
    margin-bottom: 12px;
}
.help-section li {
    margin-bottom: 6px;
}
.help-note {
    background: #f0f4ff;
    border-left: 4px solid #12224f;
    padding: 10px 14px;
    border-radius: 0 6px 6px 0;
    font-size: 0.85rem;
}
.help-figure {
    background: #f9fafc;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    padding: 14px;
    margin: 12px 0;
}
.help-figure h4 {
    margin-top: 0;
    color: #081028;
}
.help-doc-footer {
    background: #f5f6fa;
    color: #6c757d;
    font-size: 0.78rem;
    text-align: center;
    padding: 14px 24px;
    border-top: 1px solid #e8eaed;
}
.help-doc-footer p {
    margin: 2px 0;
}
#globalHelpBody {
    max-height: 72vh;
    overflow-y: auto;
}
.help-svg {
    width: 100%;
    max-width: 420px;
    height: auto;
    display: block;
    margin: 12px auto 0;
    background: #fff;
    border-radius: 6px;
}
body.help-disabled .modal-help-btn,
body.help-disabled .help-toggle-btn {
    display: none !important;
}
@media (max-width: 767px) {
    .help-doc-header,
    .help-doc-toc,
    .help-section,
    .help-doc-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
}
