/* ================================================
   FINYATRA - PREMIUM WEALTH MANAGEMENT TERMINAL
   ================================================ */

:root {
    /* Premium Enterprise Palette - HSL based for dynamic styling */
    --h: 222;
    --s: 47%;
    
    --primary: hsl(var(--h), var(--s), 11%);
    --primary-light: hsl(var(--h), var(--s), 18%);
    --accent: hsl(239, 84%, 67%);
    --accent-hover: hsl(239, 84%, 60%);
    --accent-soft: hsla(239, 84%, 67%, 0.1);
    
    --bg: hsl(210, 40%, 98%);
    --card-bg: hsl(0, 0%, 100%);
    --text-primary: hsl(var(--h), var(--s), 11%);
    --text-secondary: hsl(215, 25%, 47%);
    --text-muted: hsl(215, 20%, 65%);
    
    --border: hsl(214, 32%, 91%);
    --border-hover: hsl(214, 32%, 82%);
    
    --negative: hsl(0, 84%, 60%);
    --negative-soft: hsla(0, 84%, 60%, 0.1);
    --positive: hsl(162, 72%, 48%);
    --positive-soft: hsla(162, 72%, 48%, 0.1);
    --warning: hsl(38, 92%, 50%);
    --warning-soft: hsla(38, 92%, 50%, 0.1);

    /* Sidebar Semantic Colors */
    --sidebar-bg: hsl(var(--h), var(--s), 11%);
    --sidebar-text: hsl(215, 20%, 65%);
    --sidebar-hover: hsl(var(--h), var(--s), 18%);
    --sidebar-active: var(--accent);

    /* Layout Tokens */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --header-height: 64px;

    /* Shadows - Layered for depth */
    --shadow-sm: 0 1px 2px 0 hsla(0, 0%, 0%, 0.05);
    --shadow-card: 0 4px 6px -1px hsla(0, 0%, 0%, 0.05), 0 2px 4px -2px hsla(0, 0%, 0%, 0.05);
    --shadow-lg: 0 10px 25px -5px hsla(var(--h), var(--s), 10%, 0.1), 0 8px 10px -6px hsla(var(--h), var(--s), 10%, 0.1);
    --shadow-modal: 0 20px 50px -12px hsla(var(--h), var(--s), 10%, 0.25);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === RESET & BASE === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--primary);
}

h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.9rem; font-weight: 600; }

/* === SIDEBAR === */
#sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    position: fixed;
    height: 100vh;
    transition: width var(--transition-base);
    z-index: 100;
    box-shadow: 4px 0 24px rgba(0,0,0,0.05);
}

#sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-brand {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition-base);
}

#sidebar.collapsed .sidebar-brand {
    flex-direction: column;
    padding: 16px 0;
    gap: 12px;
}

.brand-text {
    font-size: 1.15rem;
    font-weight: 800;
    transition: opacity 0.2s, width 0.2s;
    color: white;
}

#sidebar.collapsed .brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

#sidebar.collapsed .brand-icon {
    margin-bottom: 4px;
}

#sidebar-toggle {
    background: rgba(255,255,255,0.05);
    border: none;
    color: var(--sidebar-text);
    padding: 6px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

#sidebar-toggle:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

#sidebar.collapsed #sidebar-toggle {
    margin: 0;
}

.sidebar-nav {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 0 10px;
    gap: 4px;
}

.sidebar-nav button {
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-nav button:hover {
    background-color: var(--sidebar-hover);
    color: white;
}

.sidebar-nav button.active {
    background-color: var(--accent);
    color: white;
}

#sidebar.collapsed .sidebar-nav button {
    justify-content: center;
    padding: 10px 0;
    position: relative;
}

#sidebar.collapsed .sidebar-nav button .nav-text {
    display: none;
}

/* Hover Tooltip for Collapsed Sidebar */
#sidebar.collapsed .sidebar-nav button::after {
    content: attr(data-label);
    position: absolute;
    left: 100%;
    margin-left: 10px;
    background: var(--sidebar-bg);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s;
    box-shadow: 4px 4px 15px rgba(0,0,0,0.2);
    z-index: 1000;
}

#sidebar.collapsed .sidebar-nav button:hover::after {
    opacity: 1;
    transform: translateX(5px);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* === MAIN CONTENT === */
main {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: 12px 20px;
    width: calc(100% - var(--sidebar-width));
    transition: margin-left var(--transition-base);
    min-height: 100vh;
}

main.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed);
    width: calc(100% - var(--sidebar-collapsed));
}

/* === COMPACT EXPERT HEADERS === */
section header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    gap: 16px;
    min-height: 32px;
}

/* Unified Tab System (See Main Tab Block) */

/* Hide scrollbars everywhere as requested */
* {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
*::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

.header-left { display: flex; align-items: center; gap: 12px; flex: 1; }
.header-center { flex: 1.5; display: flex; justify-content: center; }
.header-right { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; }

/* In-Header Search Bar */
.header-search {
    width: 100%;
    max-width: 400px;
    position: relative;
    display: flex;
    align-items: center;
}

.header-search input {
    width: 100%;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 8px 16px 8px 36px;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.header-search input:focus {
    background: white;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.header-search .search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.card {
    background: white;
    padding: 16px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

/* === SEARCH === */
.search-container {
    width: 100%;
    max-width: 400px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
    height: 32px;
    transition: all var(--transition-fast);
}

.search-container:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-icon {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    margin-right: 8px;
}

#global-search {
    border: none !important;
    outline: none !important;
    font-size: 0.9rem !important;
    width: 100% !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* === CARDS & METRICS === */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

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

.metric-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--card-bg) 0%, #f8fafc 100%);
    border-left: 3px solid var(--accent);
}

.metric-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    letter-spacing: -0.02em;
}

/* === HEALTH BADGES === */
.badge-health {
    padding: 3px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #f1f5f9;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(0,0,0,0.05);
}

/* === LAYOUT HELPERS === */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.items-center { align-items: center; }
.text-center { text-align: center; }
.flex-1 { flex: 1; }
.border-right { border-right: 1px solid var(--border); }

.h-full { height: 100%; }
.flex-column { display: flex; flex-direction: column; }
.gap-4 { gap: 16px; }

.border-bottom { border-bottom: 1px solid var(--border); }
.pb-2 { padding-bottom: 8px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.mt-2 { margin-top: 8px; }
.mb-1 { margin-bottom: 4px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

/* === TABS (Premium Segmented Control) === */
.minimalist-tabs {
    display: inline-flex;
    background-color: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
    gap: 4px;
    border-bottom: none !important;
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 100%;
}

.minimalist-tabs::-webkit-scrollbar { display: none; }

.minimalist-tabs .tab-link {
    padding: 6px 16px;
    font-size: 0.725rem;
    font-weight: 700;
    color: #64748b;
    border-radius: 7px;
    border: none;
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: capitalize;
    letter-spacing: 0.01em;
}

.minimalist-tabs .tab-link:hover:not(.active) {
    background-color: rgba(255,255,255,0.6);
    color: var(--primary);
}

.minimalist-tabs .tab-link.active {
    background-color: white;
    color: var(--accent);
    box-shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1);
}

.tabs-row {
    margin-bottom: 0 !important;
}

#t-sub-tabs {
    margin-top: -1px;
}

/* === TABLES === */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
    background: white;
    margin-bottom: 24px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #f8fafc;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    box-shadow: inset 0 -1px 0 var(--border);
}

/* === MODERN ACTION BUTTONS === */
.action-btn {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
    padding: 0;
}

.metric-card {
    border-left: 3px solid var(--accent);
    padding: 16px 20px;
    transition: all var(--transition-base);
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgba(0,0,0,0.05);
}
.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-bg);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.action-btn.delete:hover {
    border-color: #fee2e2;
    color: #ef4444;
    background: #fef2f2;
}

.action-btn svg {
    stroke-width: 2.5px;
}

/* === AI SIDE PANEL (DRAWER) === */
.ai-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    justify-content: flex-end;
    transition: opacity 0.3s ease;
}

.ai-panel-overlay.show {
    display: flex;
    opacity: 1;
}

.ai-panel-content {
    width: 760px;
    max-width: 90vw;
    height: 100%;
    background: white;
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-panel-overlay.show .ai-panel-content {
    transform: translateX(0);
}

.ai-panel-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    background: white;
}

.ai-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f8fafc;
}

.ai-scroll::-webkit-scrollbar {
    width: 6px;
}
.ai-scroll::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

.ai-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: rotate(90deg);
}

/* AI Review Modern Design */
.ai-section-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    margin-top: 24px;
}
.ai-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.85rem;
}
.ai-stat-row .label { color: #475569; font-weight: 500; }
.ai-stat-row .value { color: #0f172a; font-weight: 700; }

.ai-perf-table {
    width: 100%;
    margin-bottom: 20px;
    border-collapse: collapse;
}
.ai-perf-table th {
    text-align: right;
    font-size: 0.65rem;
    font-weight: 800;
    color: #94a3b8;
    padding: 8px;
    text-transform: uppercase;
}
.ai-perf-table th:first-child { text-align: left; }
.ai-perf-table td {
    padding: 10px 8px;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: right;
    border-top: 1px solid #f1f5f9;
}
.ai-perf-table td:first-child { text-align: left; color: #475569; }
.ai-perf-table .alpha { color: var(--positive); }
.ai-perf-table .alpha.negative { color: var(--negative); }

.ai-verdict-box {
    padding: 12px 16px;
    border-radius: 6px;
    margin: 8px 0 20px 0;
    background: #ecfdf5;
}
.ai-verdict-text {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1;
}

.ai-content-block {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #334155;
    margin-bottom: 20px;
}
.ai-content-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
}

/* === EXPANDED CONTAINER === */
.expand-container {
    padding: 16px 24px 24px 60px;
    background: hsl(210, 40%, 98%);
    border-left: 4px solid var(--accent);
    margin: 8px 0;
}

.expand-container .data-table {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: var(--shadow-sm);
}

.expand-container th {
    background: #f1f5f9 !important;
    font-size: 0.65rem;
    padding: 8px 14px;
    position: static !important;
}

.expand-container td {
    padding: 8px 14px;
    font-size: 0.75rem;
}

/* Grouped Section Headers (e.g. Categories) */
.t-section-row td {
    position: sticky;
    top: 36px; /* Sits below the main thead th */
    z-index: 15;
    background: var(--bg);
    font-weight: 800;
    font-size: 0.75rem;
    padding: 8px 14px;
    color: var(--primary);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 10px 14px;
    font-size: 0.825rem;
    color: var(--text-primary);
    border-bottom: 1px solid #f1f5f9;
}

tr:last-child td { border-bottom: none; }

tr:hover td {
    background-color: #f8fafc;
}

/* === BUTTONS === */
.btn-primary, .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: var(--border-hover);
}

/* === FORMS === */
.form-group {
    margin-bottom: 12px;
}

label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

input, select, textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color var(--transition-fast);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* === ENTERPRISE MODALS & PANELS === */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-base);
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.side-panel {
    position: fixed;
    top: 0; right: -480px;
    width: 440px;
    height: 100vh;
    background: white;
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
    z-index: 2100;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.side-panel.show {
    right: 0;
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.modal-content {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 32px 16px;
    text-align: center;
    transition: all var(--transition-base);
    background: #f8fafc;
    cursor: pointer;
}

.upload-zone:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.upload-zone i {
    font-size: 2rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: block;
}

.upload-zone p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.upload-zone .btn-secondary {
    margin-top: 8px;
}

/* === CHART STYLES === */
.donut-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--border);
}

.donut-wrapper {
    position: relative;
    width: 160px;
    height: 160px;
    margin-bottom: 12px;
}

.donut-chart {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.donut-chart::before {
    content: '';
    position: absolute;
    top: 25%; left: 25%; right: 25%; bottom: 25%;
    background: white;
    border-radius: 50%;
    z-index: 1;
}

.donut-center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    text-align: center;
}

.donut-total {
    font-size: 1rem;
    font-weight: 800;
}

.donut-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* === UTILS === */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.m-0 { margin: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.p-0 { padding: 0; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 20px; }
.font-bold { font-weight: 700; }
.font-black { font-weight: 900; }
.text-xs { font-size: 0.75rem; }
.text-xxs { font-size: 10px; line-height: 1.4; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.05em; }
.overflow-hidden { overflow: hidden; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.border-bottom { border-bottom: 1px solid var(--border); }
.bg-light { background-color: hsl(210, 40%, 98%); }

/* Analytics Grid Layouts */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

/* Metric Card Top Borders */
.border-top-accent  { border-top: 3px solid var(--accent); }
.border-top-positive { border-top: 3px solid var(--positive); }
.border-top-negative { border-top: 3px solid var(--negative); }
.border-top-warning  { border-top: 3px solid var(--warning); }

/* Metric Card Values */
.metric-value { font-size: 1.35rem; font-weight: 900; margin: 4px 0; color: var(--text-primary); }
.metric-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.metric-sub { font-size: 10px; font-weight: 600; }

/* Analytics Data Tables */
.ana-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.ana-table th { 
    text-align: left; padding: 8px; border-bottom: 2px solid var(--border); 
    text-transform: uppercase; color: var(--text-muted); font-size: 9px; letter-spacing: 0.05em;
    position: sticky; top: 0; background: #fff; z-index: 10;
}
.ana-table td { padding: 8px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.ana-table tr:hover { background: #f8fafc; }
.ana-table .font-bold { font-weight: 700; color: var(--dark); }
.ana-table .text-right { text-align: right; }

/* Entity Analysis Cards - Minimalist High Density */
.analysis-card {
    background: white;
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 8px;
    transition: all var(--transition-base);
    overflow: hidden;
}

.analysis-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.analysis-card .card-main {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    width: 100%;
}
.analysis-card .entity-logo {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.75rem;
    color: var(--primary);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.analysis-card .entity-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.analysis-card .entity-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.analysis-card .entity-sub {
    font-size: 0.675rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.col-metrics {
    display: flex;
    align-items: center;
    gap: 0;
    flex: none;
    justify-content: flex-end;
}

.analysis-card .metric {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    flex-shrink: 0;
    width: 100px;
    text-align: right;
}

.analysis-card .metric.gain { width: 120px; }
.analysis-card .expand-content {
    display: none;
    padding: 8px 0 16px 0;
    border-top: 1px dashed var(--border);
    margin-top: 8px;
}
.analysis-card.expanded .expand-content {
    display: block;
}
.analysis-card .metric .label {
    display: none; /* Hide labels in card for density, show in header instead */
}
.analysis-card .metric .value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--dark);
}
.analysis-card .metric .sub-value {
    font-size: 0.7rem;
    font-weight: 700;
}

/* Unified Tab System (See Main Tab Block) */

.analysis-header {
    display: flex;
    align-items: center;
    padding: 4px 16px;
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    opacity: 0.8;
}

.analysis-header .col-main {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.analysis-header .col-metrics {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.analysis-header .metric-col {
    width: 120px;
    text-align: right;
    padding-right: 4px;
}

.analysis-header .col-actions {
    width: 60px; /* Space for edit/delete buttons */
    flex-shrink: 0;
}

/* === RESPONSIVENESS === */
@media (max-width: 1024px) {
    :root { --sidebar-width: 0px; }
    main { margin-left: 0; padding: 12px 16px; }
    #sidebar { left: -240px; }
    #sidebar.open { left: 0; width: 240px; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .metric-grid { grid-template-columns: 1fr; }
    .top-bar { flex-direction: column; align-items: stretch; }
    section header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .donut-card { width: 100%; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .grid-4 { grid-template-columns: 1fr; }
}
/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: white;
    padding: 12px 18px;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: toast-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--border);
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--negative); }

@keyframes toast-in {
    from { transform: translateY(20px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* === ELEGANT UI UTILITIES === */
.ml-4 { margin-left: 16px; }
.elegant-select {
    height: 32px;
    padding: 2px 10px;
    background: #f1f5f9;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-size: 0.725rem;
    font-weight: 700;
    color: var(--primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.elegant-select:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.metric-col.w-120 { width: 120px; }
.metric-col.w-100 { width: 100px; }
.metric-col.w-80 { width: 80px; }

/* === REDESIGNED AI INTELLIGENCE SYSTEM === */
.intel-split-layout {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr; /* Fully squeezed table (1.05fr) + expanded recommendation card (0.95fr) */
    gap: 16px;
    align-items: stretch;
    margin-top: 10px;
}

.intel-left-pane {
    display: flex;
    flex-direction: column;
}

.intel-right-pane {
    display: flex;
    flex-direction: column;
}

/* Redesigned Unified Header Bar */
.intel-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 10px 18px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.intel-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.intel-header-left h2 {
    margin: 0 !important;
    font-size: 1.1rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em;
    color: var(--primary);
}

.intel-header-badge {
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 99px;
}

.intel-header-selectors {
    display: flex;
    align-items: center;
    gap: 10px;
}

.intel-select-fund {
    width: 320px;
    height: 32px !important;
    font-size: 0.725rem !important;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid var(--border);
    padding: 0 8px;
    background-color: #f8fafc;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.intel-select-fund:focus {
    border-color: var(--accent);
    background-color: white;
    outline: none;
}

.intel-vs-divider {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-secondary);
    opacity: 0.6;
}

.intel-select-benchmark {
    width: 140px;
    height: 32px !important;
    font-size: 0.725rem !important;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid var(--border);
    padding: 0 8px;
    background-color: #f8fafc;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.intel-select-benchmark:focus {
    border-color: var(--accent);
    background-color: white;
    outline: none;
}

.intel-btn-analyze {
    height: 32px !important;
    padding: 0 14px !important;
    font-size: 0.725rem !important;
    font-weight: 700 !important;
    border-radius: 6px !important;
    background: var(--accent) !important;
    color: white !important;
    border: none !important;
    cursor: pointer;
    transition: all var(--transition-fast) !important;
}

.intel-btn-analyze:hover {
    background: hsl(239, 84%, 60%) !important;
    transform: translateY(-1px);
}

/* Squeezed Horizontal Summary Strip */
.intel-summary-strip {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    background: white;
    padding: 8px 16px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.summary-col {
    display: flex;
    align-items: center;
    gap: 12px;
}

.selection-col {
    justify-content: flex-start;
}

.peer-col {
    justify-content: flex-end;
}

.summary-label {
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    min-width: 85px;
}

.selection-col .summary-label {
    border-left: 3px solid var(--accent);
    padding-left: 6px;
}

.peer-col .summary-label {
    border-right: 3px solid var(--negative);
    padding-right: 6px;
    text-align: right;
    order: 2;
}

.summary-details {
    display: flex;
    align-items: center;
    gap: 8px;
}

.peer-col .summary-details {
    order: 1;
}

.summary-badge {
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
}

.summary-fund-name {
    font-size: 0.725rem;
    font-weight: 700;
    color: var(--text-primary);
    max-width: 480px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.summary-expense {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: #f1f5f9;
    padding: 1px 4px;
    border-radius: 4px;
}

.summary-divider {
    font-size: 0.65rem;
    font-weight: 900;
    color: var(--text-secondary);
    background: #f1f5f9;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border);
    margin: 0 10px;
}

/* Beautiful squeezed spacing between table rows */
.intel-table-container {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    margin-bottom: 0 !important;
    overflow: visible !important;
}

.intel-table-spaced {
    width: 100%;
    border-collapse: separate !important;
    border-spacing: 0 4px !important;
    margin-top: -4px;
}

.intel-table-spaced thead th {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 4px 12px !important;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    white-space: nowrap !important;
}

.intel-table-spaced tbody tr {
    background: white;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.intel-table-spaced tbody tr:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-card);
    background-color: #f8fafc;
}

.intel-table-spaced tbody td {
    padding: 8px 12px !important;
    border: none !important;
    font-size: 0.8rem;
    white-space: nowrap !important;
}

/* Round first/last cell corners to match tr's border-radius */
.intel-table-spaced tbody tr td:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    font-weight: 700;
}

.intel-table-spaced tbody tr td:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Right-side Verdict/Insights card redesign (squeezed) */
.intel-verdict-card {
    display: flex;
    flex-direction: column;
    padding: 16px 20px !important;
    border-radius: 12px !important;
    background: linear-gradient(135deg, var(--positive-soft) 0%, hsla(162, 72%, 48%, 0.03) 100%) !important;
    border: 1px solid var(--positive) !important;
    box-shadow: var(--shadow-card) !important;
    height: 100%;
    margin-top: 0 !important;
    min-height: 180px;
    transition: all var(--transition-base);
}

.intel-verdict-card:hover {
    box-shadow: var(--shadow-lg) !important;
    transform: translateY(-2px);
}

.verdict-icon-container {
    font-size: 2rem;
    margin-bottom: 12px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(16, 185, 129, 0.1));
    display: inline-block;
}

.verdict-text-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.verdict-title {
    font-size: 1.05rem !important;
    font-weight: 800 !important;
    color: hsl(162, 85%, 28%) !important;
    margin: 0 !important;
    letter-spacing: -0.01em;
}

.verdict-text {
    font-size: 0.8rem !important;
    line-height: 1.5 !important;
    color: hsl(162, 85%, 22%) !important;
    opacity: 0.9;
    margin: 0 !important;
    font-weight: 500;
}

@media (max-width: 1024px) {
    .intel-split-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .intel-verdict-card {
        min-height: auto;
    }
    .intel-header-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .intel-header-selectors {
        justify-content: space-between;
    }
    .intel-summary-strip {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .summary-col {
        justify-content: space-between;
    }
    .peer-col .summary-label {
        order: 0;
        text-align: left;
        border-right: none;
        border-left: 3px solid var(--negative);
        padding-left: 6px;
        padding-right: 0;
    }
    .peer-col .summary-details {
        order: 1;
    }
    .summary-divider {
        display: none;
    }
}

/* AI Smart Analysis Panel Redesign (Split Layout matching AI Intelligence) */
.ai-header-bar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.ai-header-left-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.ai-header-badge {
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.6rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.ai-header-title {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

.ai-header-right-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-compare-label {
    font-size: 0.65rem;
    font-weight: 900;
    color: var(--text-secondary);
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
}

.ai-panel-close-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 700;
    transition: all var(--transition-fast);
}

.ai-panel-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: rotate(90deg);
}

/* Split Grid for Panel Body */
.ai-panel-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr; /* Squeezed table left + expanded reasoning right */
    gap: 16px;
    align-items: stretch;
}

.ai-panel-col-left, .ai-panel-col-right {
    display: flex;
    flex-direction: column;
}

/* Squeezed Position Box */
.ai-position-box {
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 8px 12px;
    box-shadow: var(--shadow-sm);
}

.ai-position-box .ai-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.75rem;
    border-bottom: 1px dashed #e2e8f0;
}

.ai-position-box .ai-stat-row:last-child {
    border-bottom: none;
}

.ai-position-box .ai-stat-row.total-row {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}

.ai-position-box .ai-stat-row.total-row .label {
    font-weight: 700;
    color: var(--text-primary);
}

.ai-position-box .ai-stat-row.total-row .value-group {
    text-align: right;
}

.ai-position-box .ai-stat-row.total-row .value-group .val {
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.ai-position-box .ai-stat-row.total-row .value-group .pct {
    font-size: 0.65rem;
    font-weight: 700;
}

.ai-position-box .ai-stat-row.total-row .value-group .pct.positive {
    color: var(--positive);
}

.ai-position-box .ai-stat-row.total-row .value-group .pct.negative {
    color: var(--negative);
}

/* Redesigned Verdict Banner matching Recommendation Card styling */
.ai-verdict-banner {
    display: flex;
    align-items: center;
    border: 1px solid;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

.ai-verdict-banner .verdict-shield-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-verdict-banner .verdict-shield-group .shield-icon {
    font-size: 1.1rem;
}

.ai-verdict-banner .verdict-shield-group .verdict-title {
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Reasoning/Action Content Block Squeeze */
.ai-content-block {
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 10px 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

.ai-content-title {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    margin-bottom: 4px;
    border-left: 2px solid var(--accent);
    padding-left: 4px;
}

.ai-content-title.action-title {
    color: #6366f1;
    border-left-color: #6366f1;
}

.ai-content-text {
    font-size: 0.725rem;
    color: var(--text-primary);
    line-height: 1.4;
}

/* Squeezed Performance Table styling inside the panel */
.ai-perf-table {
    width: 100%;
    margin-bottom: 10px;
    border-collapse: separate !important;
    border-spacing: 0 3px !important;
}

.ai-perf-table thead th {
    text-align: right;
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--text-secondary);
    padding: 3px 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ai-perf-table thead th:first-child {
    text-align: left;
}

.ai-perf-table tbody tr {
    background: white;
    box-shadow: var(--shadow-sm);
}

.ai-perf-table tbody td {
    padding: 6px 8px !important;
    font-size: 0.725rem;
    font-weight: 700;
    text-align: right;
    border: none !important;
    white-space: nowrap !important;
}

.ai-perf-table tbody tr td:first-child {
    text-align: left;
    color: var(--text-primary);
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}

.ai-perf-table tbody tr td:last-child {
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
}

