/* Shared tokens live in design-system.css. This file owns application layout. */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--base-font-size);
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family-base);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: var(--line-height-base);
    padding: calc(var(--spacing-unit) * 12) calc(var(--spacing-unit) * 2.5) calc(var(--spacing-unit) * 5);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile (handles browser bars) */
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.5s ease, color 0.5s ease;
    width: 100%;
    max-width: 100vw;
}

/* --- Liquid Background Animations --- */
.liquid-bg {
    position: fixed;
    inset: 0; width: 100vw; height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: var(--bg-color);
    transition: background-color 0.5s ease;
}
.orb {
    position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.6;
    animation: float 20s infinite alternate ease-in-out;
}
.orb-1 { width: 50vw; height: 50vw; background: var(--accent-hover); inset-block-start: -10%; inset-inline-start: -10%; animation-delay: 0s; }
.orb-2 { width: 40vw; height: 40vw; background: var(--accent-purple); inset-block-end: -20%; inset-inline-end: -10%; animation-delay: -5s; animation-duration: 25s; }
.orb-3 { width: 30vw; height: 30vw; background: var(--accent-color); inset-block-start: 40%; inset-inline: 0; margin-inline: auto; transform: translateY(-50%); animation-delay: -10s; animation-duration: 18s; opacity: 0.4; }

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(5vw, 10vh) scale(1.1); }
    66% { transform: translate(-10vw, 5vh) scale(0.9); }
    100% { transform: translate(0, -10vh) scale(1.05); }
}

/* --- 2. Main Layout & Header --- */
.main-container {
    width: 100%;
    max-width: 900px; /* Wider layout */
    text-align: center;
    padding-bottom: calc(var(--spacing-unit) * 6); /* 48px */
}

.main-header {
    margin-bottom: calc(var(--spacing-unit) * 5); /* 40px */
}
.brand-header-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: var(--spacing-unit);
}

.app-main-logo {
    height: 55px; /* اندازه لوگو در حالت دسکتاپ */
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 12px rgba(0, 242, 255, 0.4)); /* سایه نئونی برای هماهنگی با تم سایبر */
}

.main-header h1 {
    font-size: clamp(2.2rem, 5vw, 3rem); /* Slightly larger */
    font-weight: 700;
    margin-bottom: 0; /* صفر شد چون gap در کانتینر والد تنظیم شده است */
    color: var(--heading-accent);
    text-shadow: 0 0 10px rgba(88, 166, 255, 0.75); /* Enhanced glow */
}
.main-header p {
    font-size: clamp(1rem, 3vw, 1.2rem); /* Slightly larger */
    color: var(--text-primary);
    max-width: 650px;
    margin: 0 auto;
}

/* --- Unified Top Navigation Bar (Admin, Lang, Logout) --- */
/* کانتینر اصلی که هر سه دکمه را نگه می‌دارد */
#top-nav-container {
    position: fixed !important;
    inset-block-start: 25px !important;
    inset-inline-end: 25px !important;
    z-index: var(--layer-sticky) !important;
    display: flex !important;
    align-items: center;
    gap: 12px;
    background: var(--primary-card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    padding: 6px 8px;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#top-nav-container:hover {
    box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

/* جایگاه در انگلیسی (راست) */
/* --- استایل دکمه‌های داخل نوار --- */

/* استایل مشترک برای دکمه‌های ادمین و خروج داخل این نوار */
#top-nav-container .btn,
#top-nav-container button,
#top-nav-container a {
    border-radius: 10px !important;
    font-size: 0.9rem !important;
    padding: 8px 16px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    white-space: nowrap;
}

/* استایل دکمه ادمین (تیره) */
#top-nav-container .admin-btn { 
    background-color: #1e293b;
    color: #fff !important;
    box-shadow: 0 4px 10px rgba(30, 41, 59, 0.3);
}

/* استایل دکمه پلن ها (تضمین نمایش 100 درصدی) */
#top-nav-container .plan-nav-btn {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.1), rgba(0, 242, 255, 0.1));
    color: var(--text-primary) !important;
    border: 1px solid rgba(0, 242, 255, 0.6);
    display: inline-flex !important;
    font-weight: 800 !important;
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.2);
}
#top-nav-container .plan-nav-btn:hover {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.2), rgba(0, 242, 255, 0.2));
    border-color: rgba(0, 242, 255, 0.9);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.4);
}
#top-nav-container .admin-btn:hover,
#top-nav-container button:first-child:hover {
    background-color: #0f172a;
    transform: translateY(-1px);
}

/* استایل دکمه خروج (قرمز ملایم) */
#top-nav-container .logout-btn,
#top-nav-container a[href*="logout"] {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--status-error-text) !important;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
#top-nav-container .logout-btn:hover,
#top-nav-container a[href*="logout"]:hover {
    background-color: #ef4444;
    color: #fff !important;
}

/* --- 3. Companion Selection Cards --- */
.companion-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); /* Wider cards */
    gap: calc(var(--spacing-unit) * 3.5); /* Increased gap */
    margin-bottom: calc(var(--spacing-unit) * 5);
}
.companion-card {
    background-color: var(--primary-card-bg);
    border: 1px solid var(--border-color-light);
    border-radius: var(--border-radius-large);
    padding: 35px 25px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    box-shadow: var(--card-shadow);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* افکت نوری پس‌زمینه هنگام هاور */
.companion-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 0%, var(--accent-subtle-bg), transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 0;
}

.companion-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--card-hover-shadow);
    border-color: rgba(59, 130, 246, 0.3);
}

.companion-card:hover::after {
    opacity: 1;
}

.companion-card.selected {
    background-color: var(--accent-subtle-bg);
    border: 2px solid var(--accent-color);
    box-shadow: var(--neon-blue-glow);
    transform: translateY(-5px);
}

/* آیکون‌ها و متن روی لایه افکت باشند */
.companion-card i, .companion-card h2, .companion-card p {
    position: relative;
    z-index: 1;
}

.card-icon {
    font-size: 3rem;
    color: var(--interactive-default);
    margin-bottom: 20px;
    transition: transform 0.4s ease;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.companion-card:hover .card-icon {
    transform: scale(1.1) rotate(-8deg);
}

/* --- 3b. Global Markets card + controls --- */
.companion-card-new { border-color: rgba(0, 242, 255, 0.35); }

.card-flag {
    position: absolute;
    top: 14px;
    inset-inline-end: 14px;
    z-index: 2;
    padding: 3px 9px;
    border-radius: 999px;
    background: linear-gradient(135deg, #00f2ff, #58a6ff);
    color: #04121a;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    line-height: 1.5;
    box-shadow: 0 4px 14px rgba(0, 242, 255, 0.32);
}

#global-controls-container {
    background-color: var(--primary-card-bg);
    padding: calc(var(--spacing-unit) * 4);
    border-radius: var(--border-radius-large);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    margin-bottom: calc(var(--spacing-unit) * 4);
    animation: fadeIn 0.4s ease-out;
}

.global-source-note {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 4px 0 18px;
    padding: 11px 14px;
    border: 1px solid var(--border-color);
    border-radius: 11px;
    background: var(--secondary-card-bg);
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.6;
}
.global-source-note i { margin-top: 2px; color: var(--accent-color); flex-shrink: 0; }

.global-availability-status {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    margin: 0 0 16px;
    padding: 11px 14px;
    border: 1px solid var(--border-color);
    border-inline-start-width: 2px;
    border-radius: 11px;
    background: var(--secondary-card-bg);
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.analysis-feature-unavailable {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-block: 18px 24px;
    padding: 16px 18px;
    border: 1px solid var(--status-warning-border);
    border-radius: var(--border-radius-medium);
    background: var(--secondary-card-bg);
    color: var(--text-primary);
    box-shadow: var(--card-shadow);
}

.companion-card[data-analysis-availability="unavailable"] {
    border-color: var(--status-warning-border);
}

.analysis-card-status {
    position: relative;
    z-index: 1;
    align-self: center;
    margin-block-start: auto;
    padding: 3px 9px;
    border: 1px solid var(--status-warning-border);
    border-radius: 999px;
    background: var(--status-warning-surface);
    color: var(--status-warning-text);
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.4;
}

.analysis-feature-unavailable > i {
    margin-block-start: 3px;
    color: var(--status-warning-text);
    font-size: 1.15rem;
}

.analysis-feature-unavailable strong {
    display: block;
    color: var(--status-warning-text);
    line-height: 1.4;
}

.analysis-feature-unavailable p {
    margin: 5px 0 0;
    color: var(--text-secondary);
    line-height: 1.55;
}

.global-availability-status strong {
    flex: 0 0 auto;
    color: var(--text-primary);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
}

.global-availability-status span { min-width: 0; }
.global-availability-status.checking { border-inline-start-color: var(--accent-color); }
.global-availability-status.available { border-inline-start-color: var(--buy-color); }
.global-availability-status.available strong { color: var(--status-success-text); }
.global-availability-status.unavailable { border-inline-start-color: var(--sell-color); }
.global-availability-status.unavailable strong { color: var(--status-error-text); }
.global-availability-status:is(.stale, .delayed, .market_closed, .reference_only, .research_only) {
    border-inline-start-color: var(--status-warning);
}
.global-availability-status:is(.stale, .delayed, .market_closed, .reference_only, .research_only) strong {
    color: var(--status-warning-text);
}
.global-availability-status:is(.license_blocked, .rate_limited, .provider_outage, .insufficient_history) {
    border-inline-start-color: var(--status-error);
}
.global-availability-status:is(.license_blocked, .rate_limited, .provider_outage, .insufficient_history) strong {
    color: var(--status-error-text);
}

.global-instrument-metadata {
    min-width: 0;
    margin-block-end: var(--space-4);
    padding: clamp(var(--space-3), 2vw, var(--space-4));
    border: 1px solid var(--border-semantic);
    border-radius: var(--border-radius-medium);
    background: var(--surface-subtle);
}

.global-metadata-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-block-end: var(--space-3);
}

.global-metadata-heading h3 {
    min-width: 0;
    margin: 0;
    color: var(--text-primary);
    font-size: .95rem;
    overflow-wrap: anywhere;
}

.global-contract-badge {
    flex: 0 0 auto;
    padding: 5px 9px;
    border: 1px solid var(--border-semantic);
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 800;
}

.global-contract-badge.state-available { color: var(--status-success-text); border-color: var(--status-success); }
.global-contract-badge:is(.state-stale, .state-delayed, .state-market_closed, .state-reference_only, .state-research_only) { color: var(--status-warning-text); border-color: var(--status-warning); }
.global-contract-badge:is(.state-unavailable, .state-license_blocked, .state-rate_limited, .state-provider_outage, .state-insufficient_history) { color: var(--status-error-text); border-color: var(--status-error); }

.global-instrument-metadata dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
    margin: 0;
}

.global-metadata-item {
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-small);
    background: var(--primary-card-bg);
}

.global-metadata-item dt {
    color: var(--text-secondary);
    font-size: .64rem;
    font-weight: 750;
}

.global-metadata-item dd {
    margin-block-start: 4px;
    color: var(--text-primary);
    font-size: .76rem;
    overflow-wrap: anywhere;
}

.global-metadata-item dd[data-missing="true"] { color: var(--text-secondary); font-style: italic; }

@media (max-width: 820px) {
    .global-instrument-metadata dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 430px) {
    .global-metadata-heading { align-items: flex-start; flex-direction: column; }
    .global-instrument-metadata dl { grid-template-columns: minmax(0, 1fr); }
}

.global-symbol-option.unavailable {
    border-inline-start: 2px solid var(--sell-color);
}

.global-unavailable-message {
    margin: calc(var(--spacing-unit) * 2) 0;
    padding: calc(var(--spacing-unit) * 2.5);
    border: 1px solid rgba(248, 81, 73, 0.38);
    border-inline-start: 2px solid var(--sell-color);
    border-radius: var(--border-radius-medium);
    background: rgba(248, 81, 73, 0.1);
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.global-unavailable-message strong {
    display: block;
    margin-block-end: 6px;
    color: var(--status-error-text);
    letter-spacing: 0.06em;
}

.global-unavailable-message p { margin: 0; }
.global-unavailable-code { margin-block-start: 8px !important; color: var(--text-secondary); font-size: 0.78rem; }

/* #global-submit-btn previously declared only layout and min-height, so it fell
   back to the browser's native grey button chrome instead of the product's primary
   style. It now shares the #submit-btn contract above; only the keyboard focus ring
   is defined here, and it applies to every primary button. */
#submit-btn:focus-visible,
#load-market-btn:focus-visible,
#global-submit-btn:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px rgba(88, 166, 255, 0.28);
}

/* --- Measured accuracy panel --- */
.validation-card {
    margin: 22px 0;
    padding: 20px 22px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-large);
    background: var(--primary-card-bg);
    box-shadow: var(--card-shadow);
}
.validation-card h3 {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 4px;
    font-size: 1.05rem;
    color: var(--text-primary);
    border-bottom: 0;
}
.validation-card h3 i { color: var(--accent-color); }
.validation-subtitle {
    margin: 0 0 18px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.6;
}
.validation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 12px;
}
.validation-metric {
    padding: 14px 15px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--secondary-card-bg);
}
.validation-metric .vm-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}
.validation-metric .vm-value {
    display: block;
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.2;
}
.validation-metric .vm-hint {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 0.7rem;
    line-height: 1.5;
}
.validation-metric.is-strong { border-color: rgba(47, 181, 116, 0.45); }
.validation-metric.is-strong .vm-value { color: #2fb574; }
.validation-metric.is-weak { border-color: rgba(248, 81, 73, 0.4); }
.validation-metric.is-weak .vm-value { color: #f85149; }
.validation-note {
    margin: 16px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.65;
}
.validation-card.is-unavailable .validation-subtitle { margin-bottom: 0; }

/* --- 4. Controls & Forms --- */
#controls-container, #market-controls-container {
    background-color: var(--primary-card-bg);
    padding: calc(var(--spacing-unit) * 4); /* 32px */
    border-radius: var(--border-radius-large);
    border: 1px solid var(--border-color);
    margin-top: calc(var(--spacing-unit) * -2.5); /* Keep overlap */
    animation: fadeIn 0.5s ease-out forwards;
    box-shadow: var(--card-shadow);
    margin-bottom: calc(var(--spacing-unit) * 4); /* 32px */
    position: relative; /* Ensure it stays above results */
    z-index: 10;
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Flexible columns */
    gap: calc(var(--spacing-unit) * 3); /* 24px */
    margin-bottom: calc(var(--spacing-unit) * 4); /* 32px */
}

.control-group {
    text-align: start;
    position: relative; /* For potential icons/tooltips */
}

label {
    display: block;
    margin-bottom: calc(var(--spacing-unit) * 1.25); /* 10px */
    font-size: 0.95rem; /* Slightly larger label */
    color: var(--text-secondary);
    font-weight: 500;
}

select, input[type="text"], input[type="email"], input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    background-color: var(--secondary-card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-medium);
    color: var(--text-primary);
    font-size: 16px; /* CRITICAL: 16px to prevent iOS auto-zoom on focus */
    font-family: inherit;
    font-weight: 500;
    transition: all var(--transition-fast);
    box-shadow: inset 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    -webkit-appearance: none;
    appearance: none;
}
select:focus, input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px var(--accent-subtle-bg);
    background-color: var(--primary-card-bg);
}

/* Custom dropdown arrow for select */
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%238b949e'%3E%3Cpath fill-rule='evenodd' d='M4.22 6.03a.75.75 0 0 1 1.06 0L8 8.75l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.09a.75.75 0 0 1 0-1.06Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-inline-end: calc(var(--spacing-unit) * 4.5);
    cursor: pointer;
}

input[type="text"]::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

select:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: var(--input-focus-shadow);
    background-color: var(--primary-card-bg); /* Slightly lighter background on focus */
}
select:hover, input[type="text"]:hover {
    border-color: var(--border-color-light); /* Lighter border on hover */
}

/* Datalist styling */
datalist option {
    background-color: var(--primary-card-bg);
    color: var(--text-primary);
}
/* Style input when datalist option is selected (limited support) */
input:focus::-webkit-calendar-picker-indicator { display: none; }


#submit-btn, #load-market-btn, #global-submit-btn {
    width: 100%;
    padding: calc(var(--spacing-unit) * 2); /* 16px */
    background: linear-gradient(145deg, var(--accent-color), var(--accent-hover));
    color: #ffffff;
    border: none;
    border-radius: var(--border-radius-medium);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    display: inline-flex; /* Align icon and text */
    align-items: center;
    justify-content: center;
    gap: var(--spacing-unit);
}
#submit-btn:hover, #load-market-btn:hover, #global-submit-btn:hover {
    background: linear-gradient(145deg, var(--accent-hover), var(--accent-color));
    box-shadow: 0 6px 15px rgba(88, 166, 255, 0.45);
    transform: translateY(-2px);
}
#submit-btn:active, #load-market-btn:active, #global-submit-btn:active {
    transform: scale(0.98) translateY(0px); /* Adjusted active state */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}
#submit-btn:disabled, #load-market-btn:disabled, #global-submit-btn:disabled {
    /* --border-color is an 8%-opacity hairline token. Using it as a fill left the
       button nearly invisible against the card while an analysis was running, which
       reads as a broken control rather than a busy one. Keep the primary gradient
       and dim it instead, so the button stays legible and obviously the same
       control in its inactive state. */
    background: linear-gradient(145deg, var(--accent-color), var(--accent-hover));
    color: #ffffff;
    opacity: 0.55;
    filter: saturate(0.65);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}
/* The result status owns the sole analysis spinner. Buttons retain their label. */
#submit-btn.loading::before, #load-market-btn.loading::before, #global-submit-btn.loading::before {
    content: none;
}

#market-type-group {
    display: none; /* Hidden by default, shown via JS */
}
/* --- 5. Result & Output Area --- */
#result-container {
    margin-top: calc(var(--spacing-unit) * 5); /* 40px */
    background-color: var(--primary-card-bg);
    padding: calc(var(--spacing-unit) * 3.5) calc(var(--spacing-unit) * 4); /* 28px 32px */
    border-radius: var(--border-radius-large);
    border: 1px solid var(--border-color);
    text-align: start;
    animation: fadeIn 0.6s ease-out forwards;
    box-shadow: var(--card-shadow);
    overflow: visible; /* Allow tooltips/dropdowns to escape; use overflow-x: hidden on children if needed */
}

#loader {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    margin: 12px 0;
    border: 1px solid var(--border-semantic);
    border-radius: 12px;
    background: var(--surface-secondary);
    color: var(--text-primary);
}
#loader::before { content: ''; flex: 0 0 28px; width: 28px; height: 28px; border: 3px solid var(--border-semantic); border-top-color: var(--action-primary); border-radius: 50%; animation: spin .8s linear infinite; }
#loader strong { display: block; line-height: 1.6; }
#loader p { margin: 4px 0 0; color: var(--text-muted); font-size: .875rem; line-height: 1.6; }
#result-container[data-analysis-busy="true"] #professional-result-content { display: none; }
@media (prefers-reduced-motion: reduce) { #loader::before { animation: none; } }

/* General styles for output sections */
#analysis-output h2, #market-overview-output h2 { /* Analysis Title or Market Title */
    color: var(--accent-color);
    text-align: center;
    margin-top: 0;
    margin-bottom: calc(var(--spacing-unit) * 3.5);
    font-size: clamp(1.6rem, 4vw, 2rem); /* Larger title */
    border-bottom: 1px solid var(--border-color);
    padding-bottom: calc(var(--spacing-unit) * 2);
    font-weight: 600;
}
#analysis-output h3 { /* Section Titles */
    border-bottom: 1px solid var(--border-color);
    padding-bottom: calc(var(--spacing-unit) * 1.5);
    margin-top: calc(var(--spacing-unit) * 4.5);
    margin-bottom: calc(var(--spacing-unit) * 2.5);
    color: var(--text-primary);
    font-size: 1.4rem; /* Larger section titles */
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 1.25);
    font-weight: 600;
}
#analysis-output h3 i { /* Icons in Section Titles */
    color: var(--accent-color);
    font-size: 1.1em;
    width: 26px; /* Slightly larger icon space */
    text-align: center;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}
#analysis-output h3:hover i {
    transform: scale(1.1); /* Subtle icon hover effect */
}
#analysis-output p, #analysis-output li, .signal-item {
    line-height: var(--line-height-base);
    color: var(--text-secondary);
    margin-bottom: calc(var(--spacing-unit) * 1.5);
    font-size: 1rem;
}
#analysis-output strong, .signal-item strong {
    color: var(--text-primary);
    font-weight: 500;
}
#analysis-output a {
    color: var(--link-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}
#analysis-output a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* List styling */
#analysis-output ul {
    padding-inline-start: calc(var(--spacing-unit) * 3);
    list-style: none;
    margin-top: calc(var(--spacing-unit) * 0.5);
}
#analysis-output ul li {
    position: relative;
    padding-inline-start: calc(var(--spacing-unit) * 2.5);
    margin-bottom: var(--spacing-unit);
}
#analysis-output ul li::before { /* Custom bullet */
    content: '◆';
    color: var(--accent-color);
    position: absolute;
    inset-inline-start: 0;
    top: 1px;
    font-size: 0.9em; /* Slightly smaller bullet */
    line-height: inherit;
}
.error-message {
    color: var(--status-error-text) !important;
    background-color: rgba(248, 81, 73, 0.1); /* Use var(--sell-color) with alpha */
    border: 1px solid rgba(248, 81, 73, 0.3);
    padding: calc(var(--spacing-unit) * 2);
    border-radius: var(--border-radius-medium);
    text-align: center;
    margin: calc(var(--spacing-unit) * 2) 0;
    font-weight: 500; /* Make error text slightly bolder */
}

/* Interactive Chart Placeholder (TradingView) */
#chart-image-placeholder {
    margin: calc(var(--spacing-unit) * 3.5) auto; 
    border-radius: var(--border-radius-large);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    background-color: var(--secondary-card-bg); 
    overflow: hidden; /* Important to keep chart inside rounded corners */
    position: relative;
    width: 100%;
}

/* Placeholder divs styling */
#glance-dashboard-output,
#chart-image-placeholder,
#confidence-breakdown-placeholder,
#signal-card-placeholder,
#key-drivers-placeholder,
#general-rec-placeholder,
#radar-chart-wrapper,
#detailed-pillars-placeholder {
    margin-bottom: calc(var(--spacing-unit) * 4); /* Increased spacing between sections */
}

/* --- 6. Market Overview Styles --- */
#market-overview-output {
    width: 100%;
}
/* Sector Heatmap (Refined) */
.sector-heatmap {
    background-color: var(--secondary-card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-large);
    padding: calc(var(--spacing-unit) * 2.5);
    margin-bottom: calc(var(--spacing-unit) * 4); /* Increased margin */
    box-shadow: var(--card-shadow);
}
.sector-heatmap h3 {
    text-align: center;
    margin-top: 0;
    margin-bottom: calc(var(--spacing-unit) * 3); /* More space */
    font-size: 1.3rem; /* Adjusted size */
    color: var(--text-secondary);
    border-bottom: none;
    padding-bottom: 0;
    justify-content: center;
    font-weight: 500; /* Lighter weight for subtitle feel */
}
.heatmap-items {
    display: flex;
    justify-content: center; /* Center items */
    flex-wrap: wrap;
    gap: calc(var(--spacing-unit) * 2) calc(var(--spacing-unit) * 3); /* Increased gap */
}
.heatmap-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.95rem; /* Larger font */
    min-width: 80px; /* Wider */
    padding: var(--spacing-unit) 0; /* Add vertical padding */
    transition: transform var(--transition-fast);
}
.heatmap-item:hover {
    transform: scale(1.05); /* Slight scale on hover */
}
.heatmap-item span:first-child { /* Sector Name */
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: calc(var(--spacing-unit) * 0.75);
    text-transform: capitalize;
}
.heatmap-item span:last-child { /* Percentage */
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    padding: 2px 6px; /* Add padding for better visual */
    border-radius: var(--border-radius-small);
}
.heatmap-item .positive { background-color: rgba(47, 181, 116, 0.15); color: var(--buy-color); }
.heatmap-item .negative { background-color: rgba(248, 81, 73, 0.1); color: var(--sell-color); }
.heatmap-item .neutral { background-color: rgba(139, 148, 158, 0.1); color: var(--text-secondary); }
.heatmap-item .unavailable { color: var(--text-secondary); border: 1px dashed var(--border-color); }
/* End Sector Heatmap */

.market-filters {
    margin-bottom: calc(var(--spacing-unit) * 3);
    display: flex;
    flex-wrap: wrap;
    gap: calc(var(--spacing-unit) * 1.5); /* Slightly larger gap */
    justify-content: center;
    padding-bottom: calc(var(--spacing-unit) * 2.5); /* More padding */
    border-bottom: 1px solid var(--border-color);
}
.filter-btn {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: calc(var(--spacing-unit) * 1) calc(var(--spacing-unit) * 2);
    border-radius: var(--border-radius-medium);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap; /* Prevent button text wrapping */
}
.filter-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background-color: var(--accent-subtle-bg);
    transform: translateY(-1px); /* Slight lift */
}
.filter-btn.active {
    background-color: var(--accent-color);
    color: var(--bg-color); /* Dark text on active button */
    border-color: var(--accent-color);
    font-weight: 600;
    box-shadow: 0 0 12px rgba(88, 166, 255, 0.5);
    transform: translateY(-1px);
}

.coin-list-wrapper { /* Add wrapper */
    margin-top: var(--spacing-unit); /* Space below filters */
}
.coin-list-header { /* Style header row */
    display: grid;
    grid-template-columns: minmax(130px, 2fr) minmax(100px, 1fr) minmax(100px, 1fr); /* Match coin row */
    gap: var(--spacing-unit);
    padding: calc(var(--spacing-unit)*0.75) calc(var(--spacing-unit) * 2);
    color: var(--text-secondary);
    font-size: 0.8rem; /* Smaller header text */
    font-weight: 600;
    border-bottom: 1px solid var(--border-color-light);
    margin-bottom: var(--spacing-unit);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.coin-list-header span:nth-child(n+2) { /* Align Price & Change Right (LTR) */
    text-align: end;
}


.coin-list {
    max-height: 650px; /* Increased height */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-unit); /* Keep gap between rows */
    padding-inline-end: var(--spacing-unit);
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color-light) var(--primary-card-bg);
}
.coin-list::-webkit-scrollbar { width: 8px; }
.coin-list::-webkit-scrollbar-track { background: var(--primary-card-bg); border-radius: var(--border-radius-small); }
.coin-list::-webkit-scrollbar-thumb { background-color: var(--border-color-light); border-radius: var(--border-radius-small); border: 2px solid var(--primary-card-bg); }
.coin-list::-webkit-scrollbar-thumb:hover { background-color: var(--text-secondary); }

.coin-row {
    display: grid;
    grid-template-columns: minmax(130px, 2fr) minmax(100px, 1fr) minmax(100px, 1fr); /* Wider price/change */
    align-items: center;
    padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 2);
    background-color: var(--secondary-card-bg);
    border-radius: var(--border-radius-medium);
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
    gap: var(--spacing-unit);
}
.coin-row:hover {
    background-color: #2a3038;
    transform: translateX(4px); /* Shift right slightly */
    border-color: var(--accent-color); /* Highlight border */
}

.coin-symbol {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--spacing-unit);
    font-size: 1rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.market-type-tag {
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: var(--border-radius-small);
    font-weight: 500;
    text-transform: uppercase;
    margin-inline-start: var(--spacing-unit);
    border: 1px solid var(--border-color); /* Add border */
}
.market-type-tag.spot { border-color: var(--buy-color); color: var(--buy-color); }
.market-type-tag.futures { border-color: var(--accent-color); color: var(--accent-color); }
.coin-price {
    text-align: end;
    color: var(--text-primary); /* Use primary color for price */
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}
.coin-change {
    text-align: end;
    font-size: 1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.coin-change.positive { color: var(--buy-color); }
.coin-change.negative { color: var(--sell-color); }
/* End Market Overview */


/* --- 7. Professional Signal Card Styles (v9.1 Updates) --- */
.signal-card {
    background-color: var(--signal-card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-large); /* 12px */
    padding: calc(var(--spacing-unit) * 3) calc(var(--spacing-unit) * 3.5); /* 24px 28px */
    margin-top: calc(var(--spacing-unit) * 3); /* 24px */
    font-size: 1rem;
    box-shadow: var(--card-shadow);
    position: relative; /* For potential badges */
    overflow: hidden; /* Ensure consistent styling */
}
/* Optional: Add a subtle top border highlight based on action */
.signal-card.long::before, .signal-card.short::before, .signal-card.hold::before {
    content: '';
    position: absolute;
    top: 0;
    inset-inline: 0;
    height: 4px; /* Highlight height */
    border-top-left-radius: var(--border-radius-large);
    border-top-right-radius: var(--border-radius-large);
}
.signal-card.long::before { background-color: var(--buy-color); }
.signal-card.short::before { background-color: var(--sell-color); }
.signal-card.hold::before { background-color: var(--hold-color); }

.locked-analysis-feature {
    width: 100%;
    min-height: 44px;
    border: 1px solid rgba(248, 81, 73, 0.35);
    border-radius: var(--border-radius-medium);
    background: rgba(248, 81, 73, 0.08);
    color: var(--sell-color);
    font: inherit;
    font-weight: 700;
    text-align: center;
    padding: 10px;
    cursor: pointer;
}
.locked-analysis-feature:hover { background: rgba(248, 81, 73, 0.14); }
.locked-analysis-feature:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.signal-evidence-state {
    display: grid;
    justify-items: center;
    gap: 12px;
    margin-top: calc(var(--spacing-unit) * 3);
    padding: clamp(24px, 5vw, 40px);
    border: 1px solid var(--border-semantic);
    border-radius: var(--border-radius-large);
    background: var(--signal-card-bg);
    color: var(--text-primary);
    text-align: center;
    box-shadow: var(--card-shadow);
}
.signal-evidence-state.stale { border-color: color-mix(in srgb, var(--status-warning) 58%, transparent); }
.signal-evidence-state.insufficient { border-color: color-mix(in srgb, var(--status-info) 58%, transparent); }
.signal-evidence-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-subtle-bg);
    color: var(--status-info);
    font-size: 1.25rem;
}
.signal-evidence-state.stale .signal-evidence-icon { color: var(--status-warning-text); }
.signal-evidence-code {
    border: 1px solid var(--border-semantic);
    border-radius: 999px;
    background: var(--surface-subtle);
    color: var(--text-secondary);
    font-family: var(--font-family-monospace);
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .035em;
    padding: 5px 10px;
}
.signal-evidence-state h2 { margin: 0; font-size: clamp(1.2rem, 3vw, 1.55rem); }
#analysis-output .signal-evidence-state h2 { color: var(--text-primary); }
.signal-evidence-state p { max-width: 62ch; margin: 0; color: var(--text-secondary); }


.signal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: calc(var(--spacing-unit) * 2); /* 16px */
    margin-bottom: calc(var(--spacing-unit) * 3); /* 24px */
    flex-wrap: wrap; /* Allow wrapping */
    gap: calc(var(--spacing-unit) * 1.5); /* 12px */
}
.signal-header h2 { /* Pair + TF Info */
    margin: 0;
    font-size: 1.5rem; /* Slightly larger */
    color: var(--text-primary);
    text-align: start;
    border-bottom: none;
    padding-bottom: 0;
    line-height: 1.3;
    flex-grow: 1;
    font-weight: 600; /* Bolder title */
}
#analysis-output .signal-header h2 { color: var(--text-primary); }
.signal-header .provider { /* Exchange Name */
    font-size: 0.9rem;
    color: var(--text-secondary);
    background-color: var(--primary-card-bg); /* Use primary card bg */
    padding: calc(var(--spacing-unit) * 0.75) calc(var(--spacing-unit) * 1.5); /* 6px 12px */
    border-radius: var(--border-radius-medium);
    display: inline-flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.75);
    border: 1px solid var(--border-color);
    white-space: nowrap;
}
.signal-header .provider i {
    color: var(--accent-color); /* Color the icon */
}

.signal-details {
    display: grid;
    gap: calc(var(--spacing-unit) * 1.75); /* Slightly adjusted gap */
}
.signal-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline; /* Align text baselines */
    line-height: var(--line-height-base);
    gap: calc(var(--spacing-unit) * 2); /* 16px */
    flex-wrap: wrap;
    padding: calc(var(--spacing-unit) * 0.5) 0; /* Add slight vertical padding */
}
.signal-item strong { /* Label */
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}
.signal-item span, .signal-item ul { /* Value or List */
    color: var(--text-primary);
    text-align: end; /* Logical property — works for both LTR and RTL */
    font-weight: 500;
    word-break: break-word; /* Allow long values to wrap */
}
.signal-item span.value-long, .signal-item span.value-short, .signal-item span.value-hold {
    font-weight: bold;
    padding: calc(var(--spacing-unit) * 0.6) calc(var(--spacing-unit) * 1.5); /* 5px 12px */
    border-radius: var(--border-radius-small);
    text-transform: uppercase;
    color: #fff; /* White text on colored backgrounds */
    font-size: 0.95rem; /* Slightly larger action */
    letter-spacing: 0.5px;
    min-width: 70px; /* Ensure minimum width */
    text-align: center; /* Center text within badge */
}
.signal-item span.value-long { background-color: var(--action-success); box-shadow: 0 0 8px rgba(47, 181, 116, 0.5); }
.signal-item span.value-short { background-color: var(--action-danger); box-shadow: 0 0 8px rgba(248, 81, 73, 0.5); }
.signal-item span.value-hold { background-color: var(--hold-color); box-shadow: 0 0 8px rgba(247, 183, 49, 0.5); color: var(--bg-color); } /* Dark text on hold */

.signal-list { /* Entries and Targets */
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: end;
}
.signal-list li {
    margin-bottom: calc(var(--spacing-unit) * 0.75); /* 6px */
    color: var(--text-primary);
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
}
.signal-list li:last-child { margin-bottom: 0; }

.target-profit {
    color: var(--buy-color);
    font-size: 0.85em;
    margin-inline-start: var(--spacing-unit);
    font-weight: normal;
}
.stop-loss-value { font-weight: bold; font-variant-numeric: tabular-nums; }
.stop-loss-percent {
    color: var(--sell-color);
    font-size: 0.85em;
    margin-inline-start: var(--spacing-unit);
    font-weight: normal;
}

/* --- Capital Allocation (Margin) Smart Bar Styles --- */
.capital-alloc-container {
    background: var(--secondary-card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-top: 15px;
    margin-bottom: 5px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.alloc-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.alloc-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.alloc-title i {
    color: var(--accent-color);
}

.alloc-percent-badge {
    font-size: 0.9rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid;
    background: rgba(255, 255, 255, 0.05);
    letter-spacing: 0.5px;
}

.alloc-progress-track {
    width: 100%;
    height: 10px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
    position: relative;
}

.alloc-progress-fill {
    height: 100%;
    border-radius: 10px;
    position: relative;
}

/* افکت نور متحرک روی نوار پر شده */
.alloc-progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0) 100%);
    animation: shimmer 2s infinite linear;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.alloc-footer-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.capital-alloc-container { text-align: start; }

/* Strategy Suggestion */
.strategy-suggestion {
    margin-top: calc(var(--spacing-unit) * 2.5); /* 20px */
    padding-top: calc(var(--spacing-unit) * 2); /* 16px */
    border-top: 1px dashed var(--border-color-light); /* Lighter dash */
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: start;
    white-space: pre-line;
}
.strategy-suggestion strong {
    color: var(--accent-color);
    font-weight: 600;
}
.strategy-suggestion i {
    margin-inline-end: calc(var(--spacing-unit) * 0.75);
    color: var(--accent-color);
    vertical-align: middle;
}
/* Rationale & Risk Scenarios */
.signal-rationale, .risk-scenario {
    margin-top: calc(var(--spacing-unit) * 2); /* Reduced margin */
    padding: calc(var(--spacing-unit) * 2) calc(var(--spacing-unit) * 2.5); /* Add padding */
    border: 1px solid var(--border-color); /* Use solid border */
    border-radius: var(--border-radius-medium);
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: start;
    white-space: pre-line;
    background-color: var(--primary-card-bg); /* Slightly different background */
}
.signal-rationale strong, .risk-scenario strong {
    color: var(--text-primary);
    font-weight: 600;
    display: block;
    margin-bottom: var(--spacing-unit);
    font-size: 1em; /* Relative to parent */
    border-bottom: 1px solid var(--border-color-light); /* Underline title */
    padding-bottom: calc(var(--spacing-unit) * 0.5);
}
.signal-rationale ul, .risk-scenario ul { /* Style lists if used */
    list-style: none;
    padding-inline-start: 0;
    margin-top: var(--spacing-unit);
}
.signal-rationale li, .risk-scenario li {
    padding-inline-start: calc(var(--spacing-unit) * 2);
    position: relative;
    margin-bottom: calc(var(--spacing-unit) * 0.5);
}
.signal-rationale li::before, .risk-scenario li::before {
    content: '-';
    position: absolute;
    inset-inline-start: 0;
    color: var(--accent-color);
    font-weight: bold;
}

/* --- 8. Key Drivers & Radar Chart Styles --- */
.key-drivers-card {
    background-color: var(--key-drivers-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-large);
    padding: calc(var(--spacing-unit) * 3);
    margin-top: calc(var(--spacing-unit) * 4);
    box-shadow: var(--card-shadow);
}
.key-drivers-card h3 { /* Main Title */
    color: var(--accent-color);
    text-align: center;
    margin-top: 0;
    margin-bottom: calc(var(--spacing-unit) * 3);
    font-size: 1.4rem; /* Consistent section title size */
    border-bottom: 1px solid var(--border-color);
    padding-bottom: calc(var(--spacing-unit) * 2);
    justify-content: center; /* Center icon+text */
}
.drivers-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(var(--spacing-unit) * 3.5);
}
.drivers-column h4 { /* Bullish/Bearish Title */
    margin-top: 0;
    margin-bottom: calc(var(--spacing-unit) * 2);
    font-size: 1.15rem; /* Slightly larger */
    text-align: center;
    font-weight: 600;
}
.drivers-column ul { padding: 0; margin: 0; list-style: none; }
.drivers-column li {
    background-color: var(--secondary-card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-medium);
    padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 2);
    margin-bottom: var(--spacing-unit);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    text-align: start;
    transition: background-color var(--transition-fast);
    position: relative;
    padding-inline-start: calc(var(--spacing-unit) * 3.5);
}
.drivers-column li:hover {
    background-color: var(--border-color); /* Darken on hover */
}
.drivers-column li::before { /* Icons */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    inset-inline-start: calc(var(--spacing-unit) * 1.5);
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9em;
}
.drivers-column:first-child h4 { color: var(--buy-color); } /* Bullish Title */
.drivers-column:last-child h4 { color: var(--sell-color); } /* Bearish Title */
.drivers-column:first-child li::before { content: '\f067'; color: var(--buy-color); } /* Plus */
.drivers-column:last-child li::before { content: '\f068'; color: var(--sell-color); } /* Minus */
/* Radar Chart */
.radar-chart-container {
    margin-top: calc(var(--spacing-unit) * 4);
    padding: calc(var(--spacing-unit) * 3);
    background-color: var(--secondary-card-bg);
    border-radius: var(--border-radius-large);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
}
.radar-chart-container h3 {
    text-align: center;
    margin-top: 0;
    margin-bottom: calc(var(--spacing-unit) * 3);
    font-size: 1.4rem; /* Consistent */
    color: var(--accent-color);
    border-bottom: none;
    padding-bottom: 0;
    justify-content: center; /* Center icon+text */
}
#aiRadarChart {
    max-width: 100%;
    height: auto;
    max-height: 450px; /* Allow slightly taller chart */
    display: block;
    margin: 0 auto;
}

/* --- 9. At-a-Glance Dashboard --- */
.glance-dashboard {
    background-color: var(--glance-bg);
    border: 1px solid var(--glance-border);
    border-radius: var(--border-radius-large);
    padding: calc(var(--spacing-unit) * 3);
    margin-bottom: calc(var(--spacing-unit) * 4); /* Consistent spacing */
    box-shadow: var(--card-shadow);
}
.glance-dashboard h3 {
    color: var(--accent-color);
    text-align: center;
    margin-top: 0;
    margin-bottom: calc(var(--spacing-unit) * 3);
    font-size: 1.4rem; /* Consistent */
    border-bottom: none;
    padding-bottom: 0;
    justify-content: center; /* Center icon+text */
}
.glance-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); /* Wider items */
    gap: calc(var(--spacing-unit) * 2.5) calc(var(--spacing-unit) * 3);
    text-align: center;
}
.glance-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-unit); /* Add padding */
    border-radius: var(--border-radius-medium);
    transition: background-color var(--transition-fast);
}
.glance-item:hover {
    background-color: var(--primary-card-bg); /* Hover effect */
}
.glance-item i { /* Icon */
    font-size: 2rem; /* Larger icon */
    margin-bottom: calc(var(--spacing-unit) * 1.25);
    /* Icon colors are applied via data-key in JS */
}
.glance-item strong { /* Label */
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: calc(var(--spacing-unit) * 0.5);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.glance-item span { /* Value */
    font-size: 1.05rem; /* Slightly larger value */
    font-weight: 600;
    color: var(--text-primary);
}
/* Apply Icon Colors (map key to CSS var) - Example for trend */
.glance-item[data-key*='up'] i { color: var(--glance-icon-trend-up); }
.glance-item[data-key*='down'] i { color: var(--glance-icon-trend-down); }
.glance-item[data-key*='chop'] i { color: var(--glance-icon-trend-chop); }
/* Add similar rules for sentiment, whales, risk keys */
.glance-item[data-key*='fear'] i { color: var(--glance-icon-senti-fear); }
.glance-item[data-key*='greed'] i { color: var(--glance-icon-senti-greed); }
.glance-item[data-key*='neutral'] i { color: var(--glance-icon-senti-neutral); } /* Default/Neutral */
.glance-item[data-key*='whale_buy'] i { color: var(--glance-icon-whale-buy); }
.glance-item[data-key*='whale_sell'] i { color: var(--glance-icon-whale-sell); }
.glance-item[data-key*='whale_neutral'] i { color: var(--glance-icon-whale-neutral); }
.glance-item[data-key*='risk_high'] i { color: var(--glance-icon-risk-high); }
.glance-item[data-key*='risk_med'] i { color: var(--glance-icon-risk-med); }
.glance-item[data-key*='risk_low'] i { color: var(--glance-icon-risk-low); }
.glance-item[data-key*='risk_none'] i { color: var(--glance-icon-risk-none); }


/* --- 10. Confidence Breakdown --- */
.confidence-breakdown-card {
    background-color: var(--confidence-breakdown-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-large);
    padding: calc(var(--spacing-unit) * 3);
    margin-bottom: calc(var(--spacing-unit) * 4); /* Consistent spacing */
    box-shadow: var(--card-shadow);
}
.confidence-breakdown-card h3 {
    color: var(--accent-color);
    text-align: center;
    margin-top: 0;
    margin-bottom: calc(var(--spacing-unit) * 3);
    font-size: 1.4rem; /* Consistent */
    border-bottom: 1px solid var(--border-color);
    padding-bottom: calc(var(--spacing-unit) * 2);
    justify-content: center; /* Center icon+text */
}
.confidence-items {
    display: grid;
    gap: calc(var(--spacing-unit) * 1.25); /* Adjusted gap */
}
.confidence-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    line-height: 1.5;
    font-size: 0.95rem;
    padding: calc(var(--spacing-unit) * 1) 0; /* Increased padding */
    border-bottom: 1px solid var(--border-color-light); /* Slightly more visible divider */
}
.confidence-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.confidence-item strong { /* Label */
    color: var(--text-secondary);
    font-weight: 500;
}
.confidence-item span { /* Value */
    color: var(--text-primary);
    font-weight: 500;
    text-align: end;
    white-space: nowrap;
    display: flex; /* Align value parts if needed */
    align-items: center;
}
/* Color coding for adjustment values */
.confidence-item span.positive-adjust { color: var(--confidence-positive-adjust); font-weight: bold; }
.confidence-item span.negative-adjust { color: var(--confidence-negative-adjust); font-weight: bold; }
.confidence-item span.neutral-adjust { color: var(--confidence-neutral-adjust); }

.confidence-item span.final-confidence { /* Style the final score */
    font-weight: bold;
    font-size: 1.15em; /* Larger final score */
    color: var(--accent-color);
    background-color: var(--accent-subtle-bg);
    padding: calc(var(--spacing-unit)*0.5) calc(var(--spacing-unit)*1.25); /* Adjust padding */
    border-radius: var(--border-radius-small);
}
/* --- 11. Detailed Pillars (Data Analyst Mode) --- */
.detailed-pillars-section {
    margin-top: calc(var(--spacing-unit) * 4);
    background-color: var(--primary-card-bg); /* Use primary as base */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-large);
    padding: calc(var(--spacing-unit) * 3);
    box-shadow: var(--card-shadow);
}
.detailed-pillars-section h3 { /* Main Title */
    color: var(--accent-color);
    text-align: center;
    margin-top: 0;
    margin-bottom: calc(var(--spacing-unit) * 3);
    font-size: 1.4rem; /* Consistent */
    border-bottom: 1px solid var(--border-color);
    padding-bottom: calc(var(--spacing-unit) * 2);
    justify-content: center; /* Center icon+text */
}
/* New v9.1: Collapsible Pillar Groups */
.pillar-group-details {
    margin-bottom: calc(var(--spacing-unit) * 1.5); /* Space between collapsed groups */
    border-radius: var(--border-radius-medium);
    border: 1px solid var(--border-color-light);
    background-color: var(--secondary-card-bg);
}
.pillar-group-summary { /* The <summary> tag */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(var(--spacing-unit) * 2); /* 16px */
    cursor: pointer;
    background-color: var(--secondary-card-bg);
    transition: background-color var(--transition-fast);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    border-radius: calc(var(--border-radius-medium) - 1px) calc(var(--border-radius-medium) - 1px) 0 0;
}
.pillar-group-summary:hover {
    background-color: #2a3038;
}
.pillar-group-summary::marker { /* Hide default arrow */
    display: none;
    content: '';
}
.pillar-group-summary:after { /* Custom Arrow */
    content: '\f078'; /* Font Awesome chevron-down */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.8em;
    color: var(--text-secondary);
    transition: transform var(--transition-base);
    transform-origin: center;
}
.pillar-group-details[open] > .pillar-group-summary:after {
    transform: rotate(180deg);
}

.pillar-group-content {
    padding: calc(var(--spacing-unit) * 2.5); /* 20px */
    padding-top: var(--spacing-unit); /* Less top padding */
    border-top: 1px solid var(--border-color); /* Separator */
    background-color: var(--primary-card-bg); /* Slightly different bg for content */
}

.pillar-item {
    display: grid;
    /* Updated grid layout for better spacing and wrapping */
    grid-template-columns: minmax(150px, auto) 1fr auto; /* Name | Note | Score */
    gap: var(--spacing-unit) calc(var(--spacing-unit) * 2);
    align-items: start; /* Align items to the start */
    margin-bottom: calc(var(--spacing-unit) * 1.5); /* More space between items */
    font-size: 0.9rem;
    padding-bottom: calc(var(--spacing-unit) * 1.5);
    border-bottom: 1px solid var(--border-color); /* Separator */
}
.pillar-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.pillar-name {
    font-weight: 500;
    color: var(--text-primary); /* Use primary color for name */
    white-space: nowrap;
    grid-row: 1 / 2; /* Ensure name stays on first row */
}
.pillar-note {
    color: var(--text-secondary);
    font-style: italic;
    grid-column: 1 / 3; /* Span note across name and middle column */
    grid-row: 2 / 3; /* Place note on the second row */
    margin-top: calc(var(--spacing-unit) * 0.5); /* Add space above note */
    text-align: start;
    line-height: 1.4; /* Improve note readability */
    word-break: break-word; /* Allow long notes to wrap */
}
.pillar-score {
    font-weight: bold;
    font-variant-numeric: tabular-nums;
    padding: calc(var(--spacing-unit)*0.5) calc(var(--spacing-unit)*1); /* Adjust padding */
    border-radius: var(--border-radius-small);
    min-width: 45px;
    text-align: center;
    grid-column: 3 / 4; /* Score in the last column */
    grid-row: 1 / 2; /* Score on the first row, aligned with name */
    justify-self: end; /* Align score to the right (LTR) */
    align-self: center; /* Center score vertically */
}
.pillar-score.positive { background-color: rgba(47, 181, 116, 0.15); color: var(--buy-color); }
.pillar-score.negative { background-color: rgba(248, 81, 73, 0.1); color: var(--sell-color); }
.pillar-score.neutral { background-color: rgba(139, 148, 158, 0.1); color: var(--text-secondary); } /* Align score left */


/* --- 12. Utility & RTL Support & Responsive --- */
.hidden { display: none !important; }

/* Spin Animation (for loader/buttons) */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* FadeIn Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); } /* Subtle fade-in */
    to { opacity: 1; transform: translateY(0); }
}
[dir="ltr"] { direction: ltr; }
/* --- Responsive & Mobile App Feel adjustments --- */
/* ============================================ */
/* === MOBILE OPTIMIZED — TABLET (≤ 768px) === */
/* ============================================ */
@media (max-width: 768px) {
    body { 
        padding: 80px 12px 24px 12px;
    }
    .main-container { max-width: 100%; }
    
    /* Reduce blur intensity on tablets/mobiles for better performance */
    .orb { filter: blur(80px); opacity: 0.4; }
    .orb-1 { width: 80vw; height: 80vw; }
    .orb-2 { width: 70vw; height: 70vw; }
    .orb-3 { width: 50vw; height: 50vw; }
    
    .controls { grid-template-columns: 1fr 1fr; gap: 14px; }
    .drivers-columns { grid-template-columns: 1fr; gap: calc(var(--spacing-unit) * 2.5); }
    .glance-items { grid-template-columns: repeat(2, 1fr); }
    
    #analysis-output h2 { font-size: 1.5rem; }
    #analysis-output h3 { font-size: 1.15rem; }
    .signal-header h2 { font-size: 1.25rem; }
    
    .pillar-item { grid-template-columns: auto 1fr; grid-template-rows: auto auto; }
    .pillar-name { grid-column: 1 / 2; grid-row: 1 / 2; }
    .pillar-note { grid-column: 1 / 3; grid-row: 2 / 3; text-align: start; }
    .pillar-score { grid-column: 2 / 3; grid-row: 1 / 2; justify-self: end; }
    
    /* Top nav: flexible wrap for tablet */
    #top-nav-container {
        flex-wrap: wrap;
        justify-content: center;
        width: auto;
        inset-inline: 15px !important;
        top: 12px !important;
        padding: 6px;
        gap: 6px;
        box-sizing: border-box;
    }
    #top-nav-container .btn,
    #top-nav-container button,
    #top-nav-container a {
        font-size: 0.8rem !important;
        padding: 6px 10px !important;
        min-height: 44px;
        height: auto;
    }
}

/* ============================================ */
/* === MOBILE OPTIMIZED — PHONE (≤ 600px) === */
/* ============================================ */
@media (max-width: 600px) {
    :root { 
        --base-font-size: 15px;
        --border-radius-large: 18px;
        --border-radius-medium: 12px;
    }
    
    body { 
        padding: 70px 14px 28px 14px;
    }
    
    .main-container { 
        max-width: 100%; 
        padding-bottom: calc(var(--spacing-unit) * 4);
    }
    
    /* === Header (logo + title) === */
    .brand-header-wrapper {
        flex-direction: column;
        gap: 8px;
    }
    .app-main-logo {
        height: 42px;
    }
    .main-header { margin-bottom: calc(var(--spacing-unit) * 4); }
    .main-header h1 { 
        font-size: 1.65rem; 
        letter-spacing: -0.5px;
    }
    .main-header p { font-size: 0.95rem; padding: 0 8px; }
    
    /* === Companion Cards: native-app row style === */
    .companion-selection { 
        grid-template-columns: 1fr; 
        gap: 12px;
        margin-bottom: calc(var(--spacing-unit) * 3);
    }
    .companion-card { 
        min-height: 86px;
        padding: 18px 18px;
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr);
        grid-template-rows: auto auto;
        align-items: center; 
        column-gap: 16px;
        row-gap: 4px;
        text-align: start;
        border-radius: 16px;
    }
    .companion-card:hover {
        transform: translateY(-2px); /* subtler hover on mobile */
    }
    .companion-card .card-icon { 
        margin-bottom: 0; 
        font-size: 1.6rem;
        width: 48px; 
        height: 48px;
        display: flex; 
        align-items: center; 
        justify-content: center; 
        background: var(--accent-subtle-bg);
        color: var(--accent-color);
        -webkit-text-fill-color: currentColor;
        border-radius: 12px;
        flex-shrink: 0;
        grid-column: 1;
        grid-row: 1 / 3;
    }
    .companion-card h2 { grid-column: 2; grid-row: 1; font-size: 1.05rem; margin: 0; align-self: end; }
    .companion-card p { grid-column: 2; grid-row: 2; font-size: 0.85rem; margin: 0; align-self: start; line-height: 1.45; }
    
    /* The NEW flag must not overlap the icon in the mobile row layout. */
    .card-flag { top: 10px; inset-inline-end: 10px; font-size: 0.55rem; padding: 2px 7px; }
    .companion-card-new h2 { padding-inline-end: 52px; }

    .validation-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .validation-card { padding: 16px 14px; }
    .validation-metric { padding: 12px 11px; }
    .validation-metric .vm-value { font-size: 1.12rem; }

    /* === Controls / Forms === */
    .controls { grid-template-columns: 1fr; gap: 14px; margin-bottom: calc(var(--spacing-unit) * 3); }
    #controls-container, #market-controls-container, #global-controls-container, #result-container {
        padding: 18px 16px;
        border-radius: 18px; 
        margin-top: 0;
    }
    select, input[type="text"], input[type="email"], input[type="password"] {
        padding: 13px 14px;
        font-size: 16px; /* prevent iOS zoom */
    }
    
    #submit-btn, #load-market-btn {
        font-size: 1rem;
        padding: 14px;
        letter-spacing: 0.5px;
    }
    
    /* === Glance / dashboard items === */
    .glance-items { grid-template-columns: 1fr 1fr; gap: 10px; }
    .glance-item { padding: 14px 10px; }
    .glance-item i { font-size: 1.4rem; }
    .glance-item span { font-size: 0.95rem; }
    
    /* === Coin rows / market lists === */
    .coin-row,
    .coin-list-header { 
        grid-template-columns: 1fr auto auto; 
        gap: 8px; 
        padding: 12px 10px; 
        font-size: 0.85rem; 
    }
    .coin-symbol { font-size: 0.9rem; flex-wrap: wrap; }
    .market-type-tag { font-size: 0.6rem; padding: 1px 4px; margin-inline-start: 0; margin-top: 4px; display: inline-block; }
    
    /* === Signal cards === */
    .signal-item { 
        flex-direction: column; 
        align-items: flex-start; 
        gap: 6px; 
        margin-bottom: 14px; 
        padding-bottom: 12px;
        border-bottom: 1px solid var(--border-color);
    }
    .signal-item:last-child { border-bottom: none; }
    .signal-item span, .signal-item ul { text-align: start; width: 100%; font-size: 1rem; }
    
    /* === Filter buttons === */
    .filter-btn { 
        padding: 9px 12px; 
        font-size: 0.8rem; 
        flex: 1 1 calc(50% - 8px);
        text-align: center; 
        min-height: 44px;
    }
    .market-filters { justify-content: space-between; gap: 8px; }
    
    /* === Responsive tables === */
    .table-responsive { 
        overflow-x: auto; 
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }
    .trade-table { min-width: 500px; font-size: 0.85rem; }
    .trade-table th, .trade-table td { padding: 8px 6px; }
    
    /* === Headings within result panel === */
    #analysis-output h2 { font-size: 1.35rem; }
    #analysis-output h3 { font-size: 1.05rem; }
    #analysis-output p, #analysis-output li { font-size: 0.95rem; }
    
    /* === Top nav for phone === */
    #top-nav-container {
        top: 10px !important;
        inset-inline: 10px !important;
        max-width: calc(100% - 20px);
        padding: 5px;
        gap: 5px;
        border-radius: 14px;
    }
    #top-nav-container .btn,
    #top-nav-container button,
    #top-nav-container a {
        font-size: 0.75rem !important;
        padding: 6px 9px !important;
        min-height: 44px;
        height: auto;
        gap: 5px;
    }
    /* Hide button text labels on small screens, keep only icons where present */
    #top-nav-container .plan-nav-btn {
        font-size: 0.7rem !important;
        padding: 6px 8px !important;
    }
    
    /* === Touch targets minimum 44x44 (Apple HIG) === */
    button, .btn, a.btn, .icon-btn {
        min-height: 44px;
    }
    .icon-btn,
    button[aria-label] {
        min-width: 44px;
    }
    
    /* === Modals on mobile: full width with safe padding === */
    .modal-box, .plans-modal-box {
        width: calc(100% - 20px) !important;
        max-width: calc(100% - 20px) !important;
        margin: 10px !important;
        max-height: 92vh;
        overflow-y: auto;
        box-sizing: border-box;
    }
}

/* ============================================ */
/* === SMALL PHONE (≤ 380px) — fine tuning === */
/* ============================================ */
@media (max-width: 380px) {
    body { padding: 65px 10px 24px 10px; }
    
    .main-header h1 { font-size: 1.45rem; }
    .main-header p { font-size: 0.88rem; }
    .app-main-logo { height: 38px; }
    
    .companion-card { padding: 16px 14px; gap: 14px; }
    .companion-card h2 { font-size: 1rem; }
    .companion-card p { font-size: 0.78rem; }
    .companion-card .card-icon { width: 42px; height: 42px; font-size: 1.4rem; }
    
    #controls-container, #market-controls-container, #result-container {
        padding: 14px 12px;
    }
    
    #top-nav-container {
        top: 8px !important;
        padding: 4px;
        gap: 4px;
    }
    #top-nav-container .btn,
    #top-nav-container button,
    #top-nav-container a {
        font-size: 0.7rem !important;
        padding: 5px 7px !important;
        min-height: 44px;
        height: auto;
    }
}

/* --- 13. Backtest Results Section (Clean & Corporate) --- */
.backtest-section {
    margin-top: calc(var(--spacing-unit) * 5);
    padding: calc(var(--spacing-unit) * 3.5);
    background: var(--primary-card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-large);
    animation: fadeIn 0.6s ease-out forwards;
    box-shadow: var(--card-shadow);
}

.backtest-header {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: calc(var(--spacing-unit) * 3);
    color: var(--text-primary); /* Fix: Dark text for light mode */
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 1.5);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: calc(var(--spacing-unit) * 1.5);
}
.backtest-header i {
    color: var(--accent-color);
    font-size: 1.1em;
}

/* The tested sample sits directly under the heading: a return figure without the
   window it was measured over is not interpretable. */
.backtest-scope-note {
    margin: calc(var(--spacing-unit) * -1) 0 calc(var(--spacing-unit) * 2.5);
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.65;
}
.backtest-scope-note[hidden] {
    display: none;
}

.backtest-loader-msg {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: var(--spacing-unit);
    animation: pulse-text 1.5s infinite ease-in-out;
}

.backtest-success-msg {
    color: var(--buy-color); /* Green indicating success */
    font-size: 0.95rem;
    margin-bottom: calc(var(--spacing-unit) * 2.5);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--spacing-unit);
}

/* Metric Grid System */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: calc(var(--spacing-unit) * 2.5);
}

.metric-card {
    background-color: var(--secondary-card-bg);
    padding: calc(var(--spacing-unit) * 2);
    border-radius: var(--border-radius-medium);
    border-inline-start: 2px solid var(--accent-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: transform var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.metric-card:hover {
    transform: translateY(-3px);
    background-color: #2c313a; /* Slightly lighter hover */
    box-shadow: 0 5px 12px rgba(0,0,0,0.2);
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: calc(var(--spacing-unit) * 0.75);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.metric-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums; /* Monospaced numbers for better alignment */
}

@keyframes pulse-text {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* RTL Support for Backtest */
/* --- Price Hunter Specific Styles --- */
#price-hunter-output {
    margin-top: 30px;
    animation: fadeIn 0.5s ease-out;
    /* Initial and mode-switch visibility is controlled by the shared .hidden
       class.  A permanent display:none here would keep successfully rendered
       quote results hidden even after the application removes that class. */
}

.ph-title {
    text-align: center;
    color: var(--accent-color);
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    font-size: 1.8rem;
}

/* Cards Container */
.arb-cards-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 40px;
}

.arb-card {
    background: var(--secondary-card-bg);
    padding: 25px;
    border-radius: 16px;
    flex: 1;
    min-width: 260px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border: 1px solid transparent;
    transition: transform 0.3s;
}
.arb-card:hover { transform: translateY(-5px); }

.arb-card.buy { border-color: var(--buy-color); background: rgba(47, 181, 116, 0.05); }
.arb-card.sell { border-color: var(--sell-color); background: rgba(248, 81, 73, 0.05); }

.arb-card h3 { margin: 0 0 15px; font-size: 1.2rem; font-weight: 600; }
.arb-card.buy h3 { color: var(--status-success-text); }
.arb-card.sell h3 { color: var(--status-error-text); }

.arb-price { font-size: 2rem; font-weight: 800; color: var(--text-primary); margin-bottom: 5px; }
.arb-price .value-unavailable,
.ph-price-box .value-unavailable {
    color: var(--text-secondary);
    font-size: .875rem;
    font-weight: 650;
}
.arb-exchange { color: var(--text-secondary); margin-bottom: 20px; font-size: 0.95rem; }
.arb-exchange strong { color: var(--text-primary); text-transform: capitalize; }

.arb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 25px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    color: #fff;
    transition: opacity 0.2s;
}
.arb-btn:hover { opacity: 0.9; }
.arb-btn.is-unavailable {
    border: 1px solid var(--border-color);
    background: var(--surface-subtle);
    box-shadow: none;
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: .82;
}
.arb-btn.is-unavailable:hover { opacity: .82; }
.buy-btn { background: var(--action-success); box-shadow: 0 4px 10px rgba(47, 181, 116, 0.3); }
.sell-btn { background: var(--action-danger); box-shadow: 0 4px 10px rgba(248, 81, 73, 0.3); }

/* Gap Circle */
.arb-gap-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
}
.arb-gap-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--primary-card-bg);
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
}
.gap-label {
    color: var(--status-success-text);
    font-size: 0.8rem;
    font-weight: 600;
}
.gap-value { font-size: 1.4rem; font-weight: 800; }

/* Status Card (Error State) */
.arb-status-card {
    text-align: center;
    padding: 30px;
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--sell-color);
    border-radius: 12px;
    margin-bottom: 30px;
}
.arb-status-card h3 { color: var(--sell-color); margin-top: 0; }

/* List Styles */
.ph-list-container {
    background: var(--primary-card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}
.ph-list-title { margin-top: 0; color: var(--text-secondary); font-weight: 500; margin-bottom: 15px; }
.ph-list-header {
    display: flex;
    justify-content: space-between;
    padding: 0 15px 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
}
.ph-list-scroll {
    max-height: 600px;
    overflow-y: auto;
    padding-top: 10px;
}
.ph-list-scroll:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
.ph-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--secondary-card-bg);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid transparent;
    transition: background 0.2s;
}
.ph-row:hover { background: #2a3038; }
.ph-row.error { background: rgba(255, 0, 0, 0.05); opacity: 0.7; }

.ph-name { display: flex; align-items: center; gap: 10px; font-weight: 600; text-transform: capitalize; min-width: 120px; }
.ph-prices { display: flex; gap: 20px; justify-content: flex-end; flex-grow: 1; }
.ph-price-box { display: flex; flex-direction: column; align-items: flex-end; font-size: 0.95rem; }
.ph-price-box span { font-size: 0.75rem; color: var(--text-secondary); }
.ph-msg { color: var(--sell-color); font-size: 0.9rem; font-weight: 500; }

.best-buy-highlight strong { color: var(--status-success-text); text-decoration: underline; }
.best-sell-highlight strong { color: var(--status-error-text); text-decoration: underline; }

/* Responsive */
@media (max-width: 768px) {
    .arb-cards-container { flex-direction: column; }
    .arb-gap-wrapper { order: -1; margin-bottom: 20px; }
    .ph-prices { gap: 10px; }
    .ph-price-box { font-size: 0.85rem; }
}
/* Chart & Table Container Styles - Dynamic */
.chart-container-box {
    margin-top: 25px;
    margin-bottom: 25px;
    background: var(--primary-card-bg);
    border-radius: 16px;
    padding: 20px;
    height: 350px;
    border: 1px solid var(--border-color);
    position: relative;
    box-shadow: var(--card-shadow);
}

.pnl-pos { color: var(--buy-color); font-weight: bold; }
.pnl-neg { color: var(--sell-color); font-weight: bold; }
.pnl-unavailable { color: var(--text-secondary); }

.trade-table { text-align: start; }

.trade-tag {
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: inline-block;
    min-width: 60px;
    text-align: center;
}
.trade-tag.long {
    background-color: rgba(47, 181, 116, 0.15); 
    color: #2fb574; 
    border: 1px solid rgba(47, 181, 116, 0.3);
    box-shadow: 0 0 5px rgba(47, 181, 116, 0.2);
}

.trade-tag.short {
    background-color: rgba(248, 81, 73, 0.15);
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.3);
    box-shadow: 0 0 5px rgba(248, 81, 73, 0.2);
}
.trade-tag.unavailable { color: var(--text-secondary); border: 1px dashed var(--border-color); }

.reason-text {
    font-weight: 500;
    font-size: 0.9rem;
}

.reason-stop { color: #f85149; }
.reason-trend { color: #f7b731; }
.reason-profit { color: #2fb574; }
.reason-neutral { color: #8b949e; }
.reason-unavailable { color: var(--text-secondary); }
/* --- Sentinel Security Shield Styles --- */
.security-shield-card {
    background: var(--primary-card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    border-inline-start: 2px solid;
}

/* Modifiers */
.security-shield-card.safe { border-inline-start-color: #2fb574; background: linear-gradient(90deg, rgba(47, 181, 116, 0.1), transparent); }
.security-shield-card.caution { border-inline-start-color: #f7b731; background: linear-gradient(90deg, rgba(247, 183, 49, 0.1), transparent); }
.security-shield-card.scam { border-inline-start-color: #f85149; background: linear-gradient(90deg, rgba(248, 81, 73, 0.15), transparent); animation: pulse-red 2s infinite; }
.security-shield-card.unknown { border-inline-start-color: var(--text-secondary); background: var(--secondary-card-bg); }
.security-method-note { margin: 10px 0 0; color: var(--text-secondary); font-size: .72rem; line-height: 1.5; }

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(248, 81, 73, 0); }
    100% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0); }
}

.shield-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.shield-icon-box {
    font-size: 2rem;
}
.safe .shield-icon-box i { color: #2fb574; }
.caution .shield-icon-box i { color: #f7b731; }
.scam .shield-icon-box i { color: #f85149; }

.shield-info h4 {
    margin: 0;
    font-size: 0.9rem;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.shield-score {
    font-size: 1.4rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
}

.shield-badge {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.security-warnings {
    list-style: none;
    padding: 0;
    margin: 0;
}

.security-warnings li {
    color: #f85149;
    font-size: 0.9rem;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.security-clean {
    color: #2fb574;
    margin: 0;
    font-weight: 500;
}

/* --- Global Modal Styles (Admin & Plans) --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    box-sizing: border-box;
    padding:
        max(10px, env(safe-area-inset-top))
        max(10px, env(safe-area-inset-right))
        max(10px, env(safe-area-inset-bottom))
        max(10px, env(safe-area-inset-left));
    background: var(--overlay-bg);
    backdrop-filter: blur(5px);
    z-index: var(--layer-dialog);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    animation: fadeIn 0.3s ease-out;
}

.modal-box {
    position: relative;
    z-index: 1;
    min-width: 0;
    background: var(--surface-elevated);
    color: var(--text-primary);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    width: 90%;
    max-width: min(900px, 100%);
    max-height: min(90dvh, 100%);
    display: flex;
    flex-direction: column;
    box-shadow: var(--card-shadow);
    box-sizing: border-box;
    overflow: hidden;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-confirm-box {
    width: min(calc(100vw - 32px), 32rem);
    max-width: 32rem;
}
.admin-confirm-body {
    padding: 22px 25px 8px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.admin-confirm-body p { margin: 0; overflow-wrap: anywhere; }
.admin-confirm-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 25px 22px;
}
.admin-confirm-actions button {
    min-width: 110px;
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--secondary-card-bg);
    color: var(--text-primary);
    cursor: pointer;
    font: inherit;
    font-weight: 750;
}
.admin-confirm-actions .admin-confirm-submit {
    border-color: var(--accent-color);
    background: var(--accent-color);
    color: var(--ds-white);
}
.admin-confirm-actions .admin-confirm-submit.is-danger {
    border-color: var(--status-error);
    background: var(--status-error);
    color: #fff;
}

.close-modal-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
    min-width: 44px;
    min-height: 44px;
    display: inline-grid;
    place-items: center;
}
.close-modal-btn:hover { color: #f85149; }

.modal-body {
    padding: 25px;
    min-width: 0;
    overflow: hidden auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* --- Admin Table Styles (Fixed Readability) --- */
.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

.table-container:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 3px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    table-layout: auto;
    min-width: 600px;
}

.admin-table th, .admin-table td {
    padding: 15px;
    text-align: start;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    background-color: transparent;
}

.admin-table th {
    background: var(--secondary-card-bg);
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    border-top: 1px solid var(--border-color);
}

.admin-table tr:hover td {
    background-color: var(--accent-subtle-bg);
}

#admin-users-table-body td {
    color: var(--text-primary) !important;
    font-weight: 500;
}

.admin-users-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 0 4px;
}

#admin-users-page-status {
    min-width: 5rem;
    text-align: center;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* --- Admin Panel UI Fixes --- */
.plan-select {
    padding: 8px 12px;
    border-radius: 6px;
    background-color: var(--secondary-card-bg) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    outline: none;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.plan-select:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
}

.update-plan-btn {
    background-color: #3b82f6 !important; /* آبی پررنگ */
    color: #ffffff !important; /* آیکون سفید */
    border: none !important;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
    margin-inline-start: 8px;
}

.update-plan-btn:hover { 
    background-color: #2563eb !important; 
    transform: translateY(-1px);
}

.ban-user-btn {
    min-height: 44px;
    font-weight: 600 !important;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
}
.ban-user-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* --- Order Book & OBI Card Styles --- */
#order-book-card {
    padding: 16px;
    background: var(--secondary-card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-medium);
    margin-bottom: 24px;
    color: #fff;
    box-shadow: var(--card-shadow);
    animation: fadeIn 0.5s ease-out;
}

.obi-progress-wrapper {
    height: 20px;
    width: 100%;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    overflow: hidden;
    display: flex;
    margin-bottom: 15px;
    position: relative;
}

/* خط جداکننده وسط */
.obi-progress-wrapper::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    inset-block: 0;
    width: 2px;
    margin-inline: auto;
    background: rgba(0, 0, 0, 0.5);
    transform: translateX(-50%);
    z-index: 2;
}

.obi-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #2fb574, #4cd137); /* گرادینت سبز */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #000;
    font-weight: bold;
    overflow: hidden;
    white-space: nowrap;
}

.obi-progress-bar.sell {
    background: linear-gradient(90deg, #e84118, #f85149); /* گرادینت قرمز */
    margin-inline-start: auto;
}

.walls-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.wall-info {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.2);
    font-weight: 500;
    border: 1px solid transparent;
}

.wall-info.buy-wall {
    border-color: rgba(47, 181, 116, 0.3);
    color: #2fb574;
}

.wall-info.sell-wall {
    border-color: rgba(248, 81, 73, 0.3);
    color: #f85149;
}
/* --- Elite Whale Radar UI --- */
.whale-radar-section {
    background: var(--primary-card-bg);
    padding: 20px;
    border-radius: var(--border-radius-large);
    margin-top: 18px;
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
}

.whale-header {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.whale-badge {
    font-size: 1rem;
    padding: 8px 20px;
    border-radius: 30px;
    background: var(--secondary-card-bg);
    font-weight: 700;
    display: inline-block;
    color: var(--text-primary);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
}

.whale-table {
    width: 100%;
    font-size: 0.95rem;
    border-collapse: collapse;
    margin-top: 6px;
}

.whale-table td, .whale-table th {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    text-align: start;
}

.whale-table th { 
    opacity: 0.6; 
    font-weight: 500;
    width: 40%;
}

.whale-table td {
    font-weight: 600;
    text-align: end;
    color: var(--text-primary);
}

.whale-table tr:last-child td, .whale-table tr:last-child th {
    border-bottom: none;
}

/* انیمیشن ملایم ورود */
.whale-radar-section:not(.hidden) {
    animation: fadeIn 0.5s ease-out;
}
/* --- Market Health Mini Widgets --- */
.market-health-row {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    margin-bottom: 20px;
    animation: fadeIn 0.5s ease-out;
}

.health-card {
    background: var(--secondary-card-bg);
    border: 1px solid var(--border-color);
    padding: 15px;
    width: 50%;
    border-radius: var(--border-radius-medium);
    text-align: center;
    color: var(--text-primary);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.health-card h4 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Velocity Meter Styles */
.velocity-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.velocity-bar {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    position: relative;
}

#velocity-fill {
    height: 100%;
    width: 0%;
    /* گرادینت از آبی (کم) به قرمز (زیاد/انفجاری) */
    background: linear-gradient(90deg, #3498db, #2fb574, #f1c40f, #f85149);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

#velocity-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Liquidity Traffic Light Styles */
.liquidity-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.traffic-light {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #444;
    border: 2px solid #222;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
}

.health-label {
    font-weight: 700;
    font-size: 0.95rem;
}

/* Responsive fixes */
@media (max-width: 600px) {
    .market-health-row {
        flex-direction: column;
        gap: 10px;
    }
    .health-card {
        width: 100%;
    }
}

/* Dynamic States (Golden Glow Logic) */
.whale-profit-true {
    border: 1px solid var(--status-warning) !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.15), inset 0 0 30px rgba(255, 215, 0, 0.05) !important;
}
.whale-profit-true .whale-badge {
    background: linear-gradient(135deg, var(--status-warning), #b45309);
    color: #000;
    text-shadow: none;
    box-shadow: 0 0 10px var(--status-warning);
}

.whale-profit-false {
    border: 1px solid var(--border-color);
    opacity: 0.9;
}

/* === Order Flow & OBI Card === */
#order-flow-obi-container {
    margin-top: 25px;
    animation: fadeIn 0.6s ease-out;
}

.obi-card {
    background: var(--primary-card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
    margin-top: 25px;
}

/* افکت نوری بالای کارت */
.obi-card::before {
    content: '';
    position: absolute;
    inset-block-start: 0; inset-inline: 0; height: 3px;
    background: linear-gradient(90deg, var(--buy-color), var(--sell-color));
    opacity: 0.7;
}

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

.obi-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}
.obi-header h3 i { color: #f1c40f; }

.obi-score-badge {
    font-size: 0.9rem;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    font-weight: 600;
}


.pressure-fill {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.pressure-buy {
    background: linear-gradient(90deg, #2fb574, #269261);
    color: #fff;
    box-shadow: 0 0 10px rgba(47, 181, 116, 0.3);
}

.pressure-sell {
    background: linear-gradient(90deg, #c0392b, #f85149);
    color: #fff;
    box-shadow: 0 0 10px rgba(248, 81, 73, 0.3);
}

.pressure-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-weight: 500;
}

/* دیوارهای قیمتی */
.walls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.wall-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid transparent;
    transition: transform 0.2s;
}
.wall-card:hover { transform: translateY(-3px); }

.wall-card.buy-wall { border-color: rgba(47, 181, 116, 0.3); }
.wall-card.sell-wall { border-color: rgba(248, 81, 73, 0.3); }

.wall-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.wall-price {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.wall-note {
    font-size: 0.75rem;
    color: #8b949e;
    margin-top: 5px;
}
/* --- AI Narrative Box (Glassmorphic) --- */
.ai-narrative-card {
    background: rgba(255, 255, 255, 0.03); /* شفافیت بسیار کم */
    backdrop-filter: blur(16px); /* مات کردن پس‌زمینه */
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(88, 166, 255, 0.2); /* حاشیه نازک و روشن */
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 35px;
    box-shadow: 0 0 20px rgba(88, 166, 255, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.05); /* Soft Glow */
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.ai-narrative-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent, rgba(88, 166, 255, 0.05), transparent);
    pointer-events: none;
}

.narrative-icon {
    font-size: 2rem;
    color: var(--accent-color);
    background: rgba(88, 166, 255, 0.1);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    box-shadow: 0 0 10px rgba(88, 166, 255, 0.2);
    flex-shrink: 0;
}

.narrative-content {
    flex-grow: 1;
}

.narrative-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.narrative-text {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-primary); /* Fix: Dark text for light mode */
    font-weight: 600;
    text-shadow: none; /* Remove shadow for cleaner look on white */
    min-height: 1.6em;
}

/* افکت مکان‌نما (Cursor) هنگام تایپ */
.typing-cursor::after {
    content: '▋';
    display: inline-block;
    vertical-align: baseline;
    color: var(--accent-color);
    animation: blink-cursor 1s step-end infinite;
    margin-inline-start: 2px;
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* هایلایت کلمات کلیدی در متن */
.highlight-cyan {
    color: var(--accent-color);
    font-weight: 700;
    text-shadow: 0 0 5px rgba(88, 166, 255, 0.4);
}

/* ریسپانسیو */
@media (max-width: 600px) {
    .ai-narrative-card {
        flex-direction: column;
        gap: 15px;
        padding: 20px;
    }
    .narrative-icon {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
}
/* --- Institutional SMC Dashboard Styles --- */
.smc-card {
    background: var(--primary-card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 35px;
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
}

/* نوار نئونی بالای کارت */
.smc-card::before {
    content: '';
    position: absolute;
    inset-block-start: 0; inset-inline: 0; height: 3px;
    background: linear-gradient(90deg, #ffd700, #58a6ff);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.smc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.smc-header h3 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--text-primary); /* استفاده از متغیر رنگ اصلی */
    display: flex;
    align-items: center;
    gap: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.smc-structure-badge {
    font-size: 0.9rem;
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
}
.smc-structure-badge.bullish { color: #2fb574; border-color: rgba(47, 181, 116, 0.3); text-shadow: 0 0 5px rgba(47, 181, 116, 0.4); }
.smc-structure-badge.bearish { color: #f85149; border-color: rgba(248, 81, 73, 0.3); text-shadow: 0 0 5px rgba(248, 81, 73, 0.4); }
.smc-structure-badge.unavailable { color: var(--text-secondary); border-color: var(--border-color); box-shadow: none; }

/* FVG & OB Sections */
.smc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.smc-column h4 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
    padding-bottom: 8px;
}

/* FVG Items */
.fvg-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-size: 0.95rem;
    background: rgba(255,255,255,0.02);
    border-inline-start: 2px solid transparent;
    transition: transform 0.2s;
}
.fvg-item:hover { transform: translateX(5px); background: rgba(255,255,255,0.04); }

.fvg-item.bullish {
    border-inline-start-color: #00ff88;
    background: linear-gradient(90deg, rgba(0, 255, 136, 0.05), transparent);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.1); /* Glitter effect */
}
.fvg-item.bearish {
    border-inline-start-color: #ff0044;
    background: linear-gradient(90deg, rgba(255, 0, 68, 0.05), transparent);
}

.fvg-range { font-family: monospace; color: #c9d1d9; font-weight: 600; }
.fvg-type { font-size: 0.8rem; font-weight: 700; }
.fvg-bull-text { color: #00ff88; }
.fvg-bear-text { color: #ff0044; }

/* OB Table (Compact) */
.ob-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.ob-table td {
    padding: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: #c9d1d9;
}
.ob-table tr:last-child td { border-bottom: none; }
.ob-bull { color: #2fb574; font-weight: 600; }
.ob-bear { color: #f85149; font-weight: 600; }

.smc-insight {
    margin-top: 20px;
    padding: 12px;
    background: rgba(88, 166, 255, 0.1);
    border-inline-start: 2px solid var(--interactive-default);
    border-radius: 6px;
    font-size: 0.95rem;
    color: #e6edf3;
    font-style: italic;
}

@media (max-width: 700px) {
    .smc-grid { grid-template-columns: 1fr; }
}

/* --- Strategy parameter benchmark card --- */

/* Divider & Arrow */
.at-divider {
    display: flex;
    justify-content: center;
    position: relative;
}
.at-arrow {
    font-size: 1.2rem;
    color: var(--interactive-default);
    animation: slide-right 1.5s infinite ease-in-out;
}

@keyframes pulse-border {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}
@keyframes slide-right {
    0%, 100% { transform: translateX(0); opacity: 0.5; }
    50% { transform: translateX(5px); opacity: 1; }
}

/* --- Strategy parameter benchmark connector --- */

/* "VS" divider connecting line — unique to this layout pass, not in earlier block */
.at-divider::before {
    content: '';
    position: absolute;
    width: 2px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--border-color), transparent);
    z-index: 1;
}

#auto-tuner-container, 
#advanced-auto-tuner-container {
    transition: opacity 0.8s ease-in-out;
}
/* --- Strategy parameter benchmark styles --- */
.auto-tuner-card {
    background: var(--primary-card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-top: 25px; /* فاصله از بالا */
    margin-bottom: 25px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.6s ease-out;
}

.at-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
}

.at-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #c9d1d9;
    display: flex;
    align-items: center;
    gap: 8px;
}
.at-title i { color: #58a6ff; }

.at-badge {
    background: linear-gradient(90deg, #2fb574, #269261);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 800;
    box-shadow: 0 0 10px rgba(47, 181, 116, 0.4);
}
.at-badge.negative {
    background: #30363d;
    color: #8b949e;
    box-shadow: none;
}

.at-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 15px;
}

.at-col {
    padding: 15px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.at-col.default {
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed #444c56;
}

.at-col.optimized {
    background: rgba(47, 181, 116, 0.05);
    border: 1px solid rgba(47, 181, 116, 0.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    position: relative;
}

.at-col.optimized::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(47, 181, 116, 0.1);
    animation: pulse-border 2s infinite;
    pointer-events: none;
}

.at-col-header {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #8b949e;
    margin-bottom: 5px;
    font-weight: 600;
}
.optimized .at-col-header { color: var(--status-success); }

.at-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}
.at-stat-row span { color: #8b949e; }
.at-stat-row strong { color: #e6edf3; }
.auto-tuner-card .at-stat-row strong.metric-unavailable { color: var(--text-secondary) !important; }

.neon-text {
    color: #2fb574 !important;
    text-shadow: 0 0 8px rgba(47, 181, 116, 0.4);
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .at-grid { grid-template-columns: 1fr; gap: 15px; }
    .at-divider { transform: rotate(90deg); margin: 5px 0; }
    .at-arrow { animation: none; margin: 5px auto; display: block; }
}
/* Force display for tuner when active */
.auto-tuner-card:not(.hidden), 
#auto-tuner-container:not(.hidden), 
#advanced-auto-tuner-container:not(.hidden) {
    display: block !important;
    animation: fadeIn 0.6s ease-out;
}

/* --- Chronos Fractal Engine (Ghost Line) Styles --- */
.fractal-card {
    background: var(--primary-card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 35px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.6s ease-out;
}

/* Neon Top Border (Purple/Cyan Gradient) */
.fractal-card::before {
    content: '';
    position: absolute;
    inset-block-start: 0; inset-inline: 0; height: 3px;
    background: linear-gradient(90deg, #bc13fe, #00f2ff); 
    box-shadow: 0 0 15px rgba(188, 19, 254, 0.5);
}

.fractal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
}

.fractal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}
.fractal-header h3 i { color: #00f2ff; /* Cyan Icon */ }

.fractal-accuracy {
    font-family: 'Courier New', monospace; /* Quant feel */
    color: #bc13fe; /* Neon Purple */
    font-weight: bold;
    font-size: 1rem;
    text-shadow: 0 0 8px rgba(188, 19, 254, 0.4);
    background: rgba(188, 19, 254, 0.05);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(188, 19, 254, 0.2);
}

.fractal-chart-container {
    position: relative;
    height: 320px; /* Fixed height for consistency */
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 10px;
}

.fractal-overlay-info {
    position: absolute;
    top: 15px;
    inset-inline-start: 15px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(0,0,0,0.5);
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
}

.fractal-insight {
    margin-top: 15px;
    text-align: center;
    color: #c9d1d9;
    font-size: 1rem;
    font-style: italic;
    background: rgba(255, 255, 255, 0.02);
    padding: 10px;
    border-radius: 8px;
}
.fractal-insight strong {
    color: #bc13fe; /* Purple highlight */
}
#fractalChartCanvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* --- Sniper Scope Logic Styles --- */

/* حالت فعال: قرمز و هشدار دهنده */
.sniper-status.locked {
    color: #ff4c4c;
    text-shadow: 0 0 10px rgba(255, 76, 76, 0.8);
    font-weight: 800;
    letter-spacing: 1px;
    animation: none;
}

/* حالت غیرفعال: خاکستری و ساده */
.sniper-status.neutral {
    color: #8b949e;
    text-shadow: none;
    font-weight: 500;
    font-size: 1rem !important; /* کمی کوچکتر برای پیام نبود دیتا */
    letter-spacing: 0;
    animation: none;
}

/* مخفی کردن رادار */
.hidden-canvas {
    display: none !important;
    visibility: hidden !important;
}

/* --- New Plan Badges for Admin and Sidebar --- */
.plan-explorer {
    background: var(--secondary-card-bg) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
}

.plan-trader {
    background: rgba(245, 158, 11, 0.1) !important;
    color: #f59e0b !important;
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
}

.plan-pro-analyst {
    background: var(--accent-subtle-bg) !important;
    color: var(--accent-color) !important;
    border: 1px solid rgba(0, 242, 255, 0.3) !important;
}

.plan-whale-hunter {
    background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%) !important;
    color: #000000 !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}
/* --- Authentication Pages (Login / Register) - Premium AI Style --- */

body.auth-page {
    display: block;
    min-height: 100dvh;
    padding: 0;
    overflow-x: hidden;
}

/* انیمیشن برای پس‌زمینه */
@keyframes meshFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.auth-wrapper {
    min-height: 100vh;
    min-height: 100dvh; /* dynamic viewport for mobile browsers */
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    width: 100%;
    box-sizing: border-box;
}

/* === Auth responsive: phone === */
@media (max-width: 600px) {
    .auth-wrapper {
        padding: 16px 14px;
        align-items: flex-start;
        padding-top: 30px;
        padding-bottom: 30px;
    }
    .auth-card {
        padding: 32px 22px !important;
        border-radius: 22px !important;
        max-width: 100%;
    }
    .auth-logo {
        font-size: 1.7rem !important;
    }
    .auth-subtitle {
        font-size: 0.9rem !important;
        margin-bottom: 24px !important;
    }
    .auth-input {
        padding: 14px 14px !important;
        font-size: 16px !important; /* prevent iOS zoom */
        border-radius: 12px !important;
    }
    .auth-label {
        font-size: 0.82rem !important;
    }
    .auth-btn {
        padding: 15px !important;
        font-size: 1rem !important;
        border-radius: 14px !important;
    }
    .auth-checkbox-group {
        font-size: 0.85rem;
        gap: 10px;
        margin-bottom: 22px;
    }
    .auth-checkbox {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }
    .auth-footer {
        font-size: 0.9rem;
        margin-top: 22px;
    }
    
    /* Reduce blur intensity for performance on phones */
    .liquid-bg .orb {
        filter: blur(70px) !important;
        opacity: 0.45 !important;
    }
    .liquid-bg .orb-1 { width: 90vw !important; height: 90vw !important; }
    .liquid-bg .orb-2 { width: 80vw !important; height: 80vw !important; }
    .liquid-bg .orb-3 { width: 60vw !important; height: 60vw !important; }
    
    /* OTP section on small screens */
    .otp-section {
        padding: 20px 16px !important;
        border-radius: 14px !important;
    }
    .otp-input {
        font-size: 1.3rem !important;
        letter-spacing: 4px !important;
    }
    
    /* TOS modal in register */
    .tos-content {
        width: 95% !important;
        max-height: 88vh !important;
    }
    .tos-header { padding: 16px !important; }
    .tos-header h2 { font-size: 1rem !important; }
    .tos-body { padding: 16px !important; font-size: 0.85rem !important; }
    .tos-body h3 { font-size: 0.95rem !important; }
}

@media (max-width: 380px) {
    .auth-card {
        padding: 26px 18px !important;
    }
    .auth-logo {
        font-size: 1.5rem !important;
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* کارت شیشه‌ای و مدرن */
.auth-card {
    background: var(--primary-card-bg);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 45px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--card-shadow);
    text-align: center;
    animation: fadeIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    z-index: 10;
}

/* لوگو با افکت جذاب */
.auth-logo {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 10px;
    letter-spacing: -1px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.auth-logo i {
    color: var(--interactive-default);
    filter: drop-shadow(0 4px 6px rgba(59, 130, 246, 0.3));
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 40px;
    font-weight: 500;
    opacity: 0.9;
}

/* اینپوت‌ها با استایل فین‌تک */
.auth-input {
    width: 100%;
    padding: 16px 18px;
    background: var(--secondary-card-bg);
    border: 2px solid transparent; 
    background-clip: padding-box;
    border-radius: 16px;
    color: var(--text-primary);
    font-family: var(--font-family-base);
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.auth-input:focus {
    outline: none;
    background: var(--primary-card-bg);
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px var(--accent-subtle-bg);
    transform: translateY(-1px);
}

/* دکمه با گرادینت و سایه */
.auth-btn {
    width: 100%;
    padding: 18px;
    background: var(--action-primary);
    border: none;
    color: var(--action-on-primary);
    font-weight: 700;
    font-size: 1.05rem;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.4);
    letter-spacing: 0.5px;
    margin-top: 10px;
}

.auth-btn:hover {
    background: var(--action-primary-hover);
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 15px 30px -5px rgba(37, 99, 235, 0.5);
}

/* گروه‌های فرم */
.auth-group {
    margin-bottom: 24px;
    text-align: start;
}

.auth-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
}

/* چک‌باکس */
.auth-checkbox-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: start;
}

.auth-checkbox {
    accent-color: var(--accent-color);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* لینک‌ها */
.auth-footer {
    margin-top: 30px;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.auth-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.auth-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* NOTE: Duplicate .auth-logo / .auth-subtitle / .auth-input / .auth-btn / .auth-group / .auth-label / .auth-checkbox-group / .auth-checkbox / .auth-footer blocks were removed — the premium versions defined earlier are the source of truth. */

/* Flash Messages */
.flash-container {
    margin-bottom: 20px;
}

.flash-msg {
    padding: 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.flash-msg.error {
    background: var(--status-error-surface);
    border: 1px solid var(--status-error-border);
    color: var(--status-error-text);
}

.flash-msg.success {
    background: var(--status-success-surface);
    border: 1px solid var(--status-success-border);
    color: var(--status-success-text);
}
/* --- Pricing Plans Modal Styles --- */
.plans-modal-box {
    max-width: 1100px;
    background: var(--bg-color);
    color: var(--text-primary);
}

.plans-modal-box .modal-header {
    border-bottom: 1px solid var(--border-color);
}

.plans-modal-box .modal-header h2 {
    color: var(--text-primary);
}

.plans-body {
    padding: 30px;
}

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

.pricing-card {
    background: var(--primary-card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-top: 15px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.pricing-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    border-color: #58a6ff;
    z-index: 5;
}

.plan-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.plan-price {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}
.plan-price span {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: normal;
}

.plan-price bdi { white-space: nowrap; }
.plan-price .plan-price-amount {
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    font-variant-numeric: tabular-nums;
}
.plan-monthly-limit { font-variant-numeric: tabular-nums; }

.plan-features li {
    margin-bottom: 15px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.plan-features li i.fa-check { color: #2fb574; }
.plan-features li i[style*="color: #58a6ff;"] { color: #3b82f6 !important; }
.plan-features li i[style*="color: #ffd700;"] { color: #d97706 !important; }

.plan-action-btn {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.plan-action-btn.current {
    background: var(--secondary-card-bg);
    color: var(--text-secondary);
    cursor: default;
    border: 1px solid var(--border-color);
}

.plan-action-btn.upgrade {
    background: #eff6ff;
    color: #3b82f6;
    border: 1px solid #bfdbfe;
}
.plan-action-btn.upgrade:hover {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

/* Rank-two (silver) popular plan */
.silver-plan { 
    border: 2px solid #3b82f6; 
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.15);
    transform: scale(1.05);
    z-index: 10;
}
.silver-plan .plan-name { color: #3b82f6; text-shadow: none; }
.silver-plan:hover { transform: scale(1.08) translateY(-5px); box-shadow: 0 15px 35px rgba(59, 130, 246, 0.2); }
.silver-plan .plan-action-btn.upgrade { background: #3b82f6; color: #fff; border: none; }

/* Highest-rank (gold) plan - dark mode default */
.gold-plan { 
    background: #000000;
    border-color: #f59e0b; 
    color: #ffffff !important;
}
.gold-plan .plan-name { color: #d97706; text-shadow: none; }
.gold-plan .plan-price { border-bottom-color: #fde68a; color: #ffffff; }
.gold-plan .plan-features li { color: #ffffff !important; }
.gold-plan .plan-features li i { color: #f59e0b; }
.gold-plan .feature-locked { color: #6b7280 !important; }
.gold-plan .read-more-toggle { color: #d97706; }
.gold-plan .premium-btn {
    background: linear-gradient(90deg, #ffd700, #b8860b);
    color: #000;
    border: none;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}
.gold-plan .premium-btn:hover {
    background: linear-gradient(90deg, #ffe033, #daa520);
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
}

/* Highest-rank (gold) plan - light mode override */
[data-theme="light"] .gold-plan {
    background: var(--surface-primary);
    color: var(--text-strong) !important;
}
[data-theme="light"] .gold-plan .plan-price {
    color: var(--text-strong);
}
[data-theme="light"] .gold-plan .plan-features li {
    color: var(--text-default) !important;
}
[data-theme="light"] .gold-plan .feature-locked {
    color: var(--text-disabled) !important;
}

.popular-badge {
    position: absolute;
    top: -15px; /* کمی بالاتر بردیم تا خوانا شود */
    inset-inline: 0;
    width: max-content;
    margin-inline: auto;
    background: #58a6ff;
    color: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.5);
    white-space: nowrap; /* جلوگیری از شکستن خط متن */
    z-index: 15;
}

/* ریسپانسیو و بهینه‌سازی موبایل برای پلن‌ها */
@media (max-width: 900px) {
    .silver-plan { 
        transform: scale(1); /* غیرفعال کردن زوم در تبلت و موبایل */
    }
    .silver-plan:hover { transform: translateY(-5px); }
    .plans-grid { 
        gap: 35px; /* فاصله بیشتر بین کارت‌ها وقتی زیر هم قرار می‌گیرند */
    }
}

@media (max-width: 768px) {
    .plans-grid { grid-template-columns: 1fr; }
    .pricing-card { 
        padding: 20px; 
        margin-top: 20px; /* فضای کافی برای بج در موبایل */
    }
}
/* --- Crypto Checkout Styles --- */
.checkout-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-semantic);
    padding-bottom: 15px;
}
.checkout-header h3 { margin: 0; color: var(--text-primary); font-size: 1.3rem; }
.back-to-plans-btn {
    background: var(--surface-subtle);
    border: 1px solid var(--border-semantic);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.back-to-plans-btn:hover { background: var(--accent-subtle-bg); color: var(--text-primary); }

.checkout-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--status-warning-text);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 25px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.payment-details-box {
    display: flex;
    gap: 30px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    align-items: center;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.qr-code-container {
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    width: 150px;
    height: 150px;
    flex-shrink: 0;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
}
.qr-code-container img { width: 100%; height: 100%; }

.payment-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 15px; width: 100%; box-sizing: border-box; overflow: hidden; }

.pay-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
    font-size: 1rem;
    flex-wrap: wrap; 
    gap: 5px;
}
.pay-row:last-child { border-bottom: none; padding-bottom: 0; }
.pay-row span { color: #64748b; font-weight: 500;}
.pay-row strong { color: #0f172a; word-break: break-word; } 

.pay-row.highlight { background: rgba(16, 185, 129, 0.05); padding: 10px; border-radius: 6px; border: 1px solid rgba(16, 185, 129, 0.2); }

.copy-btn {
    background: transparent; border: none; color: #3b82f6; cursor: pointer; margin-inline-start: 10px; font-size: 1.1rem; transition: color 0.2s;
}
.copy-btn:hover { color: #2563eb; }

.address-row { flex-direction: column; align-items: flex-start; gap: 8px; }
.address-input-group {
    display: flex; width: 100%; gap: 10px; flex-wrap: wrap;
}
.address-input-group input {
    flex-grow: 1; 
    background: #ffffff; 
    border: 1px solid #cbd5e1; 
    color: var(--status-success-text);
    font-family: monospace; 
    font-size: 0.85rem; 
    font-weight: bold;
    padding: 10px; 
    border-radius: 6px; 
    text-align: center;
    width: 100%; 
    min-width: 0; 
}
.copy-btn.primary {
    background: #f1f5f9; border: 1px solid #cbd5e1; color: #334155; padding: 10px 15px; border-radius: 6px; font-size: 0.9rem; white-space: nowrap; font-weight: 600;
}
.copy-btn.primary:hover { background: #3b82f6; color: #fff; border-color: #3b82f6; }

.verification-box {
    background: #f8fafc;
    border: 1px solid #3b82f6;
    padding: 25px;
    border-radius: 12px;
    text-align: start;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.1);
}
.verification-box h4 { margin-top: 0; color: #0f172a; margin-bottom: 10px; }
.verification-box p { color: #64748b; font-size: 0.9rem; margin-bottom: 15px; }

/* --- Success Animation Styles (Glassmorphic) --- */
.success-glass-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.05), inset 0 0 0 2px rgba(255,255,255,1);
    animation: slideUpFadeIn 0.36s var(--ease-standard) forwards;
}

.success-glass-container h2 {
    color: #0f172a;
    font-size: 1.8rem;
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 800;
}

.success-glass-container p {
    color: #64748b;
    font-size: 1.1rem;
    font-weight: 500;
}

/* SVG Checkmark Animation */
.success-checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: block;
    stroke-width: 4;
    stroke: #2fb574;
    stroke-miterlimit: 10;
    box-shadow: inset 0px 0px 0px #2fb574;
    animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}

.success-checkmark__circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 4;
    stroke-miterlimit: 10;
    stroke: #2fb574;
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.success-checkmark__check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

@keyframes stroke {
    100% { stroke-dashoffset: 0; }
}
@keyframes scale {
    0%, 100% { transform: none; }
    50% { transform: scale3d(1.1, 1.1, 1); }
}
@keyframes fill {
    100% { box-shadow: inset 0px 0px 0px 40px rgba(47, 181, 116, 0.1); }
}
@keyframes slideUpFadeIn {
    0% { opacity: 0; transform: translateY(30px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ریسپانسیو قدرتمند برای صفحه پرداخت در موبایل */
@media (max-width: 600px) {
    .payment-details-box { 
        flex-direction: column; 
        text-align: center;
        padding: 15px;
    }
    .qr-code-container { margin: 0 auto 10px auto; }
    .pay-row { 
        flex-direction: column; 
        align-items: center; 
        text-align: center; 
    }
    .pay-row.address-row { align-items: center; }
    .address-input-group { flex-direction: column; }
    .address-input-group .copy-btn.primary { width: 100%; } /* دکمه کپی کل عرض را بگیرد */
    #checkout-amount { font-size: 1.8rem; display: block; margin-top: 5px; }
}
/* --- Hamburger Menu & Sidebar Styles --- */
.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
#theme-toggle {
    min-width: 44px;
    min-height: 44px;
}
.icon-btn:hover {
    background: rgba(0,0,0,0.05);
}

/* --- Sidebar Menu Styles --- */
#sidebar-menu {
    position: fixed;
    inset-block-start: 0;
    inset-inline-end: -350px;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    background: var(--primary-card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: -5px 0 25px rgba(0,0,0,0.5);
    z-index: var(--layer-sidebar);
    transition: inset-inline-end 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-inline-start: 1px solid var(--border-color);
    box-sizing: border-box;
}
#sidebar-menu.active { inset-inline-end: 0; }

body.sidebar-open {
    position: fixed;
    inset-inline: 0;
    top: var(--sidebar-scroll-offset, 0);
    width: 100%;
    overflow-y: scroll;
}

#sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(3px);
    z-index: var(--layer-sidebar-scrim);
    animation: fadeIn 0.3s;
}

.sidebar-header {
    padding: 25px;
    background: var(--secondary-card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.user-info { display: flex; align-items: center; gap: 15px; }
.user-avatar {
    width: 45px; height: 45px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}
.sidebar-username { margin: 0; color: var(--text-primary); font-size: 1rem; font-weight: 600; }
.plan-badge-mini { font-size: 0.7rem; padding: 2px 6px; border-radius: 4px; font-weight: 700; background: var(--accent-subtle-bg); color: var(--accent-color); border: 1px solid var(--accent-color); }

#close-sidebar-btn { background: transparent; border: none; font-size: 1.2rem; color: var(--text-secondary); cursor: pointer; transition: color 0.2s; }
#close-sidebar-btn:hover { color: var(--sell-color); }

.sidebar-content { flex: 1; overflow-y: auto; padding: 20px; }
.menu-section { margin-bottom: 30px; }
.menu-section h5 { margin: 0 0 15px 0; color: var(--text-secondary); text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px; border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }

.input-group { margin-bottom: 15px; }
.input-group label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 5px; }
.input-group input { width: 100%; padding: 10px; background: var(--secondary-card-bg); border: 1px solid var(--border-color); border-radius: 8px; font-size: 0.9rem; color: var(--text-primary); transition: all 0.2s; }
.input-group input:focus { border-color: var(--accent-color); outline: none; box-shadow: var(--input-focus-shadow); }
.save-settings-btn { width: 100%; padding: 10px; background: var(--action-primary); color: var(--action-on-primary); border: none; border-radius: 8px; cursor: pointer; font-weight: 600; transition: background 0.2s; }
.save-settings-btn:hover { background: var(--action-primary-hover); }

.sidebar-footer { padding: 20px; border-top: 1px solid var(--border-color); }
.sidebar-logout { display: block; width: 100%; text-align: center; padding: 12px; background: rgba(248, 81, 73, 0.1); color: var(--status-error-text); text-decoration: none; border-radius: 8px; font: inherit; font-weight: 600; border: 1px solid rgba(248, 81, 73, 0.2); transition: all 0.2s; cursor: pointer; }
.sidebar-logout:hover { background: var(--action-danger); color: #fff; }

/* --- Toast Notifications (Beautiful Alerts) --- */
.notification-container {
    position: fixed;
    top: 20px;
    inset-inline-end: 20px;
    z-index: var(--layer-toast);
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: calc(100vw - 40px);
}
.dialog-notification-container {
    position: fixed;
    pointer-events: none;
}
.dialog-notification-container .toast {
    pointer-events: auto;
}
.dialog-notification-container.dialog-notification-flow {
    position: static;
    inset: auto;
    flex: 0 1 auto;
    min-height: 0;
    max-height: min(20dvh, 160px);
    max-width: none;
    padding: 10px 18px;
    overflow: hidden auto;
    overscroll-behavior: contain;
    pointer-events: auto;
    border-bottom: 1px solid var(--border-color);
}
.dialog-notification-flow:empty { display: none; }
.dialog-notification-flow .toast { flex: 0 0 auto; min-width: 0; width: 100%; box-shadow: none; }

.toast {
    --toast-offset: 100%;
    background: var(--primary-card-bg);
    color: var(--text-primary);
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: min(300px, calc(100vw - 40px));
    max-width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-inline-start-width: 2px;
    animation: slideInToast 0.22s var(--ease-standard);
    font-weight: 600;
    font-size: 0.95rem;
}
.toast-message { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.toast.success { border-inline-start-color: #2fb574; }
.toast.success > i { color: #2fb574; font-size: 1.2rem; }
.toast.error { border-inline-start-color: #f85149; }
.toast.error > i { color: #f85149; font-size: 1.2rem; }
.toast-dismiss {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    margin-block: -10px;
    margin-inline-end: -12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}
.toast-dismiss:hover { background: var(--accent-subtle-bg); color: var(--text-primary); }
.toast-dismiss:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.toast-dismiss i { color: currentColor; font-size: 1rem; }
.toast.toast-exiting { animation: fadeOutToast 0.4s ease forwards; }

@keyframes slideInToast {
    from { transform: translateX(var(--toast-offset)); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOutToast {
    to { transform: translateX(var(--toast-offset)); opacity: 0; }
}

/* ========================================= */
/* === SHEPHERD.JS CUSTOM GLASSMORPHISM  === */
/* ========================================= */
.shepherd-element {
    background: var(--primary-card-bg) !important;
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-color) !important;
    border-radius: 20px !important;
    box-shadow: var(--card-shadow) !important;
    font-family: var(--font-family-base) !important;
    max-width: 400px !important;
    z-index: var(--layer-tour-tooltip) !important;
}

.shepherd-modal-overlay-container {
    z-index: var(--layer-tour-overlay) !important;
}

.shepherd-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1rem 1.5rem !important;
}

.shepherd-title {
    font-weight: 800 !important;
    color: var(--accent-color) !important;
    font-size: 1.15rem !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

.shepherd-cancel-icon {
    color: var(--text-secondary) !important;
    transition: color 0.2s !important;
}
.shepherd-cancel-icon:hover { color: var(--sell-color) !important; }

.shepherd-text {
    color: var(--text-primary) !important;
    font-size: 0.95rem !important;
    line-height: 1.7 !important;
    padding: 1.5rem !important;
    font-weight: 500;
}

.shepherd-footer {
    padding: 0 1.5rem 1.5rem 1.5rem !important;
}

.shepherd-button {
    border-radius: 10px !important;
    font-weight: 700 !important;
    padding: 10px 20px !important;
    transition: all 0.3s ease !important;
    font-size: 0.9rem !important;
}

.shepherd-button-primary {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover)) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 4px 10px rgba(0, 242, 255, 0.2) !important;
}

.shepherd-button-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 242, 255, 0.4) !important;
}

.shepherd-button-secondary {
    background: var(--secondary-card-bg) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
}

.shepherd-button-secondary:hover {
    background: var(--border-color-light) !important;
    color: var(--text-primary) !important;
}

/* پیکان (فلش) راهنما */
.shepherd-arrow::before {
    background: var(--primary-card-bg) !important;
    border: 1px solid var(--border-color) !important;
}

/* افکت درخشش ملایم برای المانی که در حال آموزش است */
.shepherd-target-animating {
    position: relative;
    z-index: var(--layer-tour-target) !important;
    box-shadow: 0 0 0 4px var(--accent-subtle-bg) !important;
    border-radius: inherit;
    transition: box-shadow 0.3s ease;
}

/* --- Support System Styles --- */
.ticket-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 15px;
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.ticket-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
}
.ticket-subject { font-weight: 700; color: #0f172a; font-size: 1rem; }
.ticket-status { font-size: 0.8rem; padding: 3px 10px; border-radius: 20px; font-weight: 600; text-transform: uppercase; }
.status-waiting { background: #fff7ed; color: #f59e0b; border: 1px solid #f59e0b; }
.status-answered { background: #f0fdf4; color: #2fb574; border: 1px solid #2fb574; }

.ticket-msg-box {
    background: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    color: #334155;
    font-size: 0.95rem;
    margin-bottom: 10px;
    line-height: 1.5;
}
.ticket-img-preview {
    max-width: 150px;
    max-height: 150px;
    border-radius: 8px;
    margin-top: 12px;
    cursor: pointer;
    border: 2px solid #e2e8f0;
    transition: transform 0.2s;
}
.ticket-img-preview:hover { transform: scale(1.05); }

.admin-reply-box {
    background: #f0f9ff;
    border-inline-start: 2px solid var(--accent-color);
    padding: 15px;
    border-start-start-radius: 0;
    border-start-end-radius: 12px;
    border-end-end-radius: 12px;
    border-end-start-radius: 0;
    color: #0c4a6e;
    font-size: 0.95rem;
    margin-top: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

/* File Upload Button Styling */
.hidden-file-input { display: none; }
.file-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: #ffffff;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    color: #64748b;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    width: 100%;
    justify-content: center;
}
.file-upload-label:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: var(--accent-subtle-bg);
}
.file-upload-label i { font-size: 1.2rem; }

/* Admin Chat Styles - Enhanced & Full Width */

/* The bubbles rely on `align-self`, which only takes effect inside a flex
   container. Without this the admin thread rendered as plain stacked blocks and
   support replies never aligned to the opposite side. */
#admin-tickets-view .analysis-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}
#admin-tickets-view [data-admin-ticket].has-unread {
    border-inline-start: 2px solid var(--accent-color);
}
#admin-tickets-view .analysis-card > h3 {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 6px;
    font-size: 1rem;
}

.chat-bubble {
    padding: 16px 20px;
    border-radius: 18px;
    /* min-width must not exceed the container on a phone, or every bubble
       overflows horizontally. */
    max-width: min(90%, 720px);
    min-width: min(300px, 100%);
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    line-height: 1.6;
    font-size: .95rem;
    overflow-wrap: anywhere;
}

.chat-user {
    background: var(--secondary-card-bg);
    align-self: flex-start;
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
    margin-inline-end: auto;
    backdrop-filter: blur(10px);
}

.chat-admin-reply {
    background: linear-gradient(135deg, var(--accent-subtle-bg), transparent);
    align-self: flex-end;
    border: 1px solid var(--accent-color);
    border-bottom-right-radius: 4px;
    margin-top: 15px;
    margin-inline-start: auto;
    color: var(--text-primary);
    backdrop-filter: blur(10px);
}

.chat-meta {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Reply Input Area */
.reply-input-area {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    align-items: center;
    /* Themed rather than hardcoded white, which rendered as a glaring panel in
       dark mode until an !important override further down patched it. */
    background: var(--secondary-card-bg);
    padding: 10px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    width: 100%; /* Ensure full width inside the bubble */
}

.reply-input-area input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font: inherit;
    font-size: .92rem;
    color: var(--text-primary);
}
.reply-input-area input:focus { box-shadow: none; }

.reply-btn-small {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--action-primary);
    color: var(--action-on-primary);
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    font-size: .85rem;
    transition: background 0.2s, transform 0.2s;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}
.reply-btn-small:hover { background: var(--action-primary-hover); transform: translateY(-1px); }

@media (max-width: 560px) {
    .reply-input-area { flex-wrap: wrap; }
    .reply-input-area input { flex-basis: 100%; }
    .reply-btn-small { width: 100%; justify-content: center; }
}
/* ========================================= */
/* === GLASSMORPHISM PREMIUM MODAL === */
/* ========================================= */
.glass-modal-box {
    background: rgba(13, 17, 23, 0.4);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(88, 166, 255, 0.3);
    border-radius: 24px;
    width: 90%;
    max-width: 480px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 0 50px rgba(59, 130, 246, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

/* افکت نور پس زمینه درون مودال */
.glass-modal-box::before {
    content: '';
    position: absolute;
    inset-block-start: -50%; inset-inline: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.15) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.glass-modal-content {
    position: relative;
    z-index: 1;
}

.glass-icon-wrapper {
    width: 70px; height: 70px;
    margin: 0 auto 20px;
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(88, 166, 255, 0.3);
}

.glow-icon {
    font-size: 2rem;
    color: #58a6ff;
    text-shadow: 0 0 15px #58a6ff;
}

.glass-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 15px;
    letter-spacing: -0.5px;
}

.glass-desc {
    font-size: 1rem;
    color: #c9d1d9;
    line-height: 1.6;
    margin-bottom: 30px;
}

.glass-action-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.glass-upgrade-btn {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
    transition: all 0.3s;
}
.glass-upgrade-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(37, 99, 235, 0.6);
}

.glass-close-btn {
    background: transparent;
    color: #8b949e;
    border: none;
    padding: 10px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.2s;
}
.glass-close-btn:hover { color: #fff; text-decoration: underline; }

/* دکمه‌های قفل شده درون متن سیگنال */
.premium-lock-btn {
    background: rgba(248, 81, 73, 0.1);
    border: 1px dashed rgba(248, 81, 73, 0.5);
    color: #f85149;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
    font-weight: 600;
}
.premium-lock-btn:hover {
    background: rgba(248, 81, 73, 0.2);
    border-style: solid;
    transform: scale(1.02);
}

/* استایل دکمه Read More در پلن‌ها */
.read-more-toggle {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: center;
    color: #58a6ff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 5px;
    margin-bottom: 20px;
    transition: color 0.2s;
    font-family: inherit;
}
.read-more-toggle:hover { color: var(--text-primary); }
.feature-locked { opacity: 0.6; color: #8b949e; }
.feature-locked i { color: #f85149 !important; }

/* ========================================================================== */
/* Activity History + Support Workspace                                       */
/* ========================================================================== */
.sidebar-btn,
.sidebar-history-btn,
.sidebar-support-btn {
    width: 100%;
    min-height: 46px;
    padding: 11px 13px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: color-mix(in srgb, var(--secondary-card-bg) 88%, var(--accent-color) 12%);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    transition: border-color .2s ease, transform .2s ease, background .2s ease;
}
.sidebar-btn:hover,
.sidebar-history-btn:hover,
.sidebar-support-btn:hover { border-color: var(--accent-color); transform: translateY(-1px); }
.sidebar-btn > span:first-child,
.sidebar-history-btn > span:first-child,
.sidebar-support-btn > span:first-child { display: inline-flex; align-items: center; gap: 9px; }
.sidebar-count-badge,
#ticket-count-badge {
    min-width: 24px;
    height: 24px;
    padding-inline: 7px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    background: rgba(88, 166, 255, .16);
    color: var(--accent-color);
    font-size: .75rem;
    font-weight: 800;
}

.workspace-modal-box {
    width: min(96vw, 1280px);
    max-width: 1280px;
    height: min(90vh, 880px);
    max-height: 880px;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: color-mix(in srgb, var(--primary-card-bg) 96%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-color) 74%, var(--accent-color) 26%);
    box-shadow: 0 26px 90px rgba(0, 0, 0, .42);
}
.workspace-modal-header {
    min-height: 82px;
    padding: 17px 22px;
    flex: 0 0 auto;
    background: linear-gradient(110deg, rgba(88,166,255,.09), transparent 44%, rgba(0,242,255,.045));
}
.workspace-modal-header h2 { margin: 3px 0 0; color: var(--text-primary); font-size: clamp(1.15rem, 2vw, 1.5rem); }
.workspace-modal-header h2 i { color: var(--accent-color); margin-inline-end: 8px; }
.modal-eyebrow,
.conversation-kicker {
    display: block;
    color: var(--accent-color);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .16em;
}

.history-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--border-color);
    background: var(--secondary-card-bg);
}
.history-search {
    flex: 1;
    min-width: 180px;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding-inline: 13px;
    border: 1px solid var(--border-color);
    border-radius: 11px;
    background: var(--input-bg, var(--primary-card-bg));
    color: var(--text-secondary);
}
.history-search input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
}
.history-tool-btn {
    min-height: 44px;
    padding-inline: 13px;
    border: 1px solid var(--border-color);
    border-radius: 11px;
    background: var(--primary-card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}
.history-tool-btn[aria-pressed="true"] { color: #f5c451; border-color: rgba(245,196,81,.55); background: rgba(245,196,81,.08); }
.history-tool-btn.danger { color: var(--sell-color, #f85149); }

.history-filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 11px 18px;
    border-bottom: 1px solid var(--border-color);
    scrollbar-width: thin;
}
.history-filter-chip {
    white-space: nowrap;
    min-height: 44px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 7px 11px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font: inherit;
    font-size: .79rem;
    font-weight: 700;
}
.history-filter-chip span { margin-inline-start: 5px; }
.history-filter-chip.active { background: rgba(88,166,255,.13); border-color: rgba(88,166,255,.6); color: var(--text-primary); }

.history-workspace {
    min-height: 0;
    flex: 1;
    display: grid;
    grid-template-columns: minmax(300px, .82fr) minmax(420px, 1.6fr);
}
.history-list-pane {
    min-height: 0;
    overflow-y: auto;
    border-inline-end: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--secondary-card-bg) 74%, transparent);
}
.history-list { padding: 12px; display: grid; gap: 9px; }
.history-card {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 14px;
    padding: 13px;
    text-align: start;
    background: var(--primary-card-bg);
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: inset 0 0 0 1px var(--border-color-light, var(--border-color));
}
.history-card:hover,
.history-card.active { border-color: rgba(88,166,255,.65); background: rgba(88,166,255,.075); }
.history-card-top,
.history-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.history-section-badge,
.ticket-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(88,166,255,.12);
    color: var(--accent-color);
    font-size: var(--font-size-xs);
    font-weight: 800;
}
.ticket-status-pill.status-waiting_support { color: #d99821; background: rgba(217,152,33,.12); }
.ticket-status-pill.status-waiting_user { color: #2fb574; background: rgba(47,181,116,.12); }
.ticket-status-pill.status-closed { color: var(--text-secondary); background: rgba(128,139,156,.12); }
.ticket-reply-composer.hidden { display: none !important; }
.history-favorite-btn {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}
.history-favorite-btn.active { color: #f5c451; }
.history-card-open {
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    padding: 0;
    text-align: start;
    cursor: pointer;
}
.history-card-open:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 4px;
    border-radius: 6px;
}
.history-card-title { display: block; margin: 10px 0 5px; font-size: .94rem; font-weight: 700; line-height: 1.35; }
.history-card-preview { margin: 0 0 9px; color: var(--text-secondary); font-size: .78rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.history-card-meta { color: var(--text-secondary); font-size: var(--font-size-xs); }
.history-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #f5c451; box-shadow: 0 0 0 3px rgba(245,196,81,.1); }
.history-status-dot.completed { background: #2fb574; }
.history-status-dot.failed { background: #f85149; }
.history-load-more { display: block; margin: 4px auto 16px; padding: 9px 16px; border: 1px solid var(--border-color); border-radius: 9px; background: transparent; color: var(--text-primary); cursor: pointer; }

.history-detail-pane {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    padding: clamp(18px, 3vw, 30px);
    background: radial-gradient(circle at 85% 10%, rgba(88,166,255,.065), transparent 35%);
}
.workspace-empty-state { min-height: 100%; display: grid; align-content: center; justify-items: center; text-align: center; padding: 28px; color: var(--text-secondary); }
.workspace-empty-state h3 { color: var(--text-primary); margin: 14px 0 6px; }
.workspace-empty-state p { max-width: 470px; margin: 0; line-height: 1.65; }
.workspace-empty-icon { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 20px; color: var(--accent-color); background: rgba(88,166,255,.1); border: 1px solid rgba(88,166,255,.25); font-size: 1.45rem; }
.history-detail-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.history-detail-header h3 { margin: 7px 0 6px; color: var(--text-primary); font-size: clamp(1.1rem, 2.2vw, 1.55rem); }
.history-detail-actions { display: flex; gap: 7px; }
.history-icon-action { width: 44px; height: 44px; border: 1px solid var(--border-color); border-radius: 10px; background: var(--secondary-card-bg); color: var(--text-secondary); cursor: pointer; }
.history-icon-action.danger { color: var(--sell-color, #f85149); }
.history-metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.history-metric { padding: 13px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--secondary-card-bg); }
.history-metric span { display: block; color: var(--text-secondary); font-size: var(--font-size-xs); margin-bottom: 5px; }
.history-metric strong { color: var(--text-primary); font-size: .91rem; overflow-wrap: anywhere; }
.history-result-summary { position: relative; overflow: hidden; padding: 18px; border: 1px solid rgba(0,242,255,.22); border-radius: 15px; background: linear-gradient(135deg, rgba(0,242,255,.09), rgba(139,92,246,.07)); }
.history-result-summary::after { content: ''; position: absolute; width: 150px; height: 150px; inset-inline-end: -65px; bottom: -95px; border-radius: 50%; background: rgba(0,242,255,.09); filter: blur(4px); pointer-events: none; }
.history-result-kicker { display: inline-flex; align-items: center; gap: 7px; color: var(--accent-color); font-size: var(--font-size-xs); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.history-result-summary h4 { margin: 8px 0 6px; color: var(--text-primary); font-size: 1.08rem; }
.history-result-summary p { position: relative; z-index: 1; margin: 0; max-width: 760px; color: var(--text-secondary); line-height: 1.65; overflow-wrap: anywhere; }
.history-provider-pill { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 7px; margin-top: 13px; padding: 6px 9px; border: 1px solid var(--border-color); border-radius: 999px; color: var(--text-secondary); background: var(--secondary-card-bg); font-size: var(--font-size-xs); }
.history-json-block { margin-top: 14px; border: 1px solid var(--border-color); border-radius: 13px; overflow: hidden; }
.history-json-block summary { padding: 12px 14px; background: var(--secondary-card-bg); color: var(--text-primary); cursor: pointer; font-weight: 700; }
.history-json-block pre { max-height: 360px; overflow: auto; margin: 0; padding: 14px; color: var(--text-secondary); background: rgba(0,0,0,.12); font: .76rem/1.55 'JetBrains Mono', Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ===================================================================
   SUPPORT CENTER
   =================================================================== */
.support-workspace { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(300px, 370px) minmax(0, 1fr); }

.support-network-status {
    display: flex; align-items: center; justify-content: center; gap: 9px;
    padding: 9px 16px;
    border-bottom: 1px solid rgba(245,158,11,.45);
    background: rgba(245,158,11,.12); color: var(--text-primary);
    font-size: .78rem; font-weight: 650; line-height: 1.45;
}
.support-network-status i { color: #f59e0b; }

.support-ticket-sidebar {
    min-width: 0; min-height: 0;
    display: flex; flex-direction: column; gap: 12px;
    overflow-x: hidden; overflow-y: auto;
    padding: 16px 14px;
    border-inline-end: 1px solid var(--border-color);
    background: var(--secondary-card-bg);
}

.new-ticket-btn,
.new-ticket-inline-btn {
    width: 100%; min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    border: 0; border-radius: 12px;
    background: linear-gradient(135deg, #0759b8, #0369a1);
    color: #fff; cursor: pointer; font: inherit; font-weight: 800;
    box-shadow: 0 8px 24px rgba(40,120,227,.24);
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.new-ticket-btn:hover,
.new-ticket-inline-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(40,120,227,.34); filter: brightness(1.05); }
.new-ticket-btn:active, .new-ticket-inline-btn:active { transform: translateY(0); }
.new-ticket-inline-btn { width: auto; margin-top: 6px; padding-inline: 20px; }

.support-search-label {
    display: block;
    margin-block-end: -3px;
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 750;
}
.support-search { position: relative; display: flex; align-items: center; }
.support-search i {
    position: absolute; inset-inline-start: 12px;
    color: var(--text-secondary); font-size: .82rem; pointer-events: none;
}
.support-search input {
    width: 100%; min-height: 44px;
    padding: 8px 12px; padding-inline-start: 34px;
    border: 1px solid var(--border-color); border-radius: 11px;
    background: var(--primary-card-bg); color: var(--text-primary);
    font: inherit; font-size: var(--font-size-sm);
}
.support-search input::-webkit-search-cancel-button { filter: grayscale(1) opacity(.6); }

.support-list-filter-group,
.admin-support-filter-group {
    min-inline-size: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.support-list-filters {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px;
}
.support-list-filters label { min-width: 0; display: grid; gap: 4px; }
.support-list-filters label > span {
    color: var(--text-secondary); font-size: var(--font-size-xs); font-weight: 750;
}
.support-list-filters select {
    width: 100%; min-width: 0; min-height: 44px; padding: 6px 8px;
    border: 1px solid var(--border-color); border-radius: 9px;
    background: var(--primary-card-bg); color: var(--text-primary);
    font: inherit; font-size: var(--font-size-sm);
}

.support-list-heading {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin: 4px 3px 0;
    color: var(--text-secondary);
    font-size: var(--font-size-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
}
.support-heading-meta { display: inline-flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; }
#support-open-count { font-weight: 600; font-size: var(--font-size-xs); opacity: .85; }
#ticket-count-badge {
    min-width: 22px; padding: 2px 7px;
    border-radius: 999px;
    background: var(--accent-subtle-bg); color: var(--accent-color);
    text-align: center; font-size: var(--font-size-xs); font-weight: 800;
}

.support-ticket-list { min-width: 0; display: grid; gap: 9px; align-content: start; }

.support-ticket-item {
    position: relative;
    min-width: 0; max-width: 100%; width: 100%;
    display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 11px; align-items: start;
    padding: 13px 12px;
    border: 1px solid var(--border-color); border-radius: 14px;
    background: var(--primary-card-bg); color: var(--text-primary);
    cursor: pointer; text-align: start; font: inherit;
    transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.support-ticket-item:hover { border-color: rgba(88,166,255,.55); transform: translateY(-1px); }
.support-ticket-item.active {
    border-color: var(--accent-color);
    background: var(--accent-subtle-bg);
    box-shadow: inset 3px 0 0 var(--accent-color);
}

.sti-icon {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: 11px;
    background: var(--accent-subtle-bg); color: var(--accent-color);
    font-size: .95rem;
}
.support-ticket-item.status-closed .sti-icon { background: rgba(128,139,156,.14); color: var(--text-secondary); }
.support-ticket-item.status-waiting_user .sti-icon { background: rgba(47,181,116,.14); color: #2fb574; }

.sti-body { min-width: 0; display: grid; gap: 5px; }
.sti-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-width: 0; }
.sti-subject { min-width: 0; font-size: .9rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sti-top time { flex: 0 0 116px; color: var(--text-secondary); font-size: var(--font-size-xs); line-height: 1.35; text-align: end; overflow-wrap: anywhere; }
.sti-preview {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; color: var(--text-secondary); font-size: .76rem; line-height: 1.45;
}
.sti-bottom { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.sti-count { display: inline-flex; align-items: center; gap: 5px; color: var(--text-secondary); font-size: var(--font-size-xs); }
.ticket-priority {
    display: inline-flex; align-items: center; min-height: 22px; padding: 2px 7px;
    border: 1px solid var(--border-color); border-radius: 999px;
    color: var(--text-secondary); background: var(--secondary-card-bg);
    font-size: var(--font-size-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
}
.ticket-priority.priority-urgent { border-color: rgba(248,113,113,.58); color: #fca5a5; background: rgba(239,68,68,.1); }
.ticket-priority.priority-high { border-color: rgba(251,191,36,.58); color: #fbbf24; background: rgba(245,158,11,.1); }
.ticket-priority.priority-low { color: var(--text-secondary); opacity: .82; }
[data-theme="light"] .ticket-priority.priority-urgent { color: var(--status-error-text); }
[data-theme="light"] .ticket-priority.priority-high { color: var(--status-warning-text); }
.support-unread-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
    min-height: 22px;
    padding: 2px 7px;
    border: 1px solid var(--status-info-border);
    border-radius: 999px;
    background: var(--status-info-surface);
    color: var(--status-info-text);
    font-size: var(--font-size-xs);
    font-weight: 800;
    line-height: 1.2;
}
.sti-dot {
    position: static;
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.support-list-empty {
    display: grid; justify-items: center; gap: 10px;
    padding: 34px 18px;
    color: var(--text-secondary); text-align: center;
}
.support-list-empty i { font-size: 1.6rem; opacity: .55; }
.support-list-empty p { margin: 0; font-size: var(--font-size-sm); line-height: 1.55; }
.support-list-empty-cta {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
    padding: 7px 16px; border: 1px solid var(--interactive-text); border-radius: 999px;
    background: transparent; color: var(--interactive-text); cursor: pointer; font: inherit; font-weight: 700; font-size: var(--font-size-sm);
}

.support-conversation-pane { min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.create-ticket-panel,
.ticket-conversation-panel { min-height: 0; height: 100%; padding: clamp(17px, 3vw, 28px); overflow-y: auto; }
.ticket-conversation-panel { display: flex; flex-direction: column; padding-bottom: 14px; }

/* --- Empty state / quick categories --- */
.support-hero .support-quick-grid {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
    width: min(100%, 430px); margin-top: 22px;
}
.support-quick-card {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px;
    min-height: 84px; padding: 14px 10px;
    border: 1px solid var(--border-color); border-radius: 14px;
    background: var(--secondary-card-bg); color: var(--text-primary);
    cursor: pointer; font: inherit; font-size: .8rem; font-weight: 600;
    transition: border-color .18s ease, transform .18s ease, background .18s ease;
}
.support-quick-card i { font-size: 1.15rem; color: var(--accent-color); }
.support-quick-card:hover { border-color: var(--accent-color); background: var(--accent-subtle-bg); transform: translateY(-2px); }

/* --- New ticket form --- */
.create-ticket-panel form { max-width: 740px; margin: 18px auto 0; }
.create-ticket-panel select,
.create-ticket-panel textarea,
.ticket-reply-composer textarea {
    width: 100%;
    border: 1px solid var(--border-color); border-radius: 11px;
    background: var(--input-bg, var(--secondary-card-bg)); color: var(--text-primary);
    font: inherit;
    transition: border-color .16s ease, box-shadow .16s ease;
}
.create-ticket-panel select:focus,
.create-ticket-panel textarea:focus,
.ticket-reply-composer textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-subtle-bg);
    outline: none;
}
.create-ticket-panel select { min-height: 45px; padding: 9px 12px; }
.create-ticket-panel textarea { padding: 12px; resize: vertical; line-height: 1.6; }
.field-hint { color: var(--text-secondary); font-size: var(--font-size-xs); font-weight: 500; }
.support-file-heading { display: block; margin-bottom: 5px; color: var(--text-secondary); font-size: .85rem; }
.support-submit-btn { width: 100%; min-height: 46px; margin-top: 9px; }

/* --- Conversation header --- */
.conversation-heading {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
    padding-bottom: 14px; border-bottom: 1px solid var(--border-color);
}
.conversation-heading h3 { margin: 6px 0 4px; color: var(--text-primary); font-size: 1.12rem; }
.conversation-kicker,
.conversation-meta { color: var(--text-secondary); font-size: var(--font-size-xs); }
.conversation-kicker { font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: var(--font-size-xs); }
.conversation-actions { display: flex; gap: 8px; flex-shrink: 0; }
.support-back-btn,
.support-ghost-btn {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 44px; padding: 7px 12px;
    border: 1px solid var(--border-color); border-radius: 10px;
    background: var(--secondary-card-bg); color: var(--text-secondary);
    cursor: pointer; font: inherit; font-size: var(--font-size-sm); font-weight: 700;
    transition: border-color .16s ease, color .16s ease;
}
.support-back-btn:hover,
.support-ghost-btn:hover { border-color: var(--accent-color); color: var(--accent-color); }

/* --- Message timeline --- */
.ticket-message-timeline {
    flex: 1; min-height: 240px;
    display: flex; flex-direction: column; gap: 14px;
    padding: 22px 4px 18px;
    overflow-y: auto;
}
.ticket-message-timeline:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: -3px;
    border-radius: 10px;
}
.timeline-day { display: flex; align-items: center; gap: 12px; margin: 6px 0 2px; }
.timeline-day::before, .timeline-day::after { content: ''; flex: 1; height: 1px; background: var(--border-color); }
.timeline-day span { color: var(--text-secondary); font-size: var(--font-size-xs); font-weight: 700; letter-spacing: .04em; }

.support-message {
    max-width: min(80%, 700px);
    display: flex; align-items: flex-end; gap: 9px;
    align-self: flex-start;
    animation: fadeIn .28s ease-out;
}
.support-message.user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
    flex-shrink: 0;
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--secondary-card-bg); border: 1px solid var(--border-color);
    color: var(--text-secondary); font-size: var(--font-size-xs);
}
.support-message.user .msg-avatar { background: var(--accent-subtle-bg); border-color: rgba(88,166,255,.4); color: var(--accent-color); }

.msg-bubble {
    min-width: 0;
    padding: 11px 14px;
    border: 1px solid var(--border-color); border-radius: 16px 16px 16px 5px;
    background: var(--secondary-card-bg); color: var(--text-primary);
    overflow-wrap: anywhere;
}
.support-message.user .msg-bubble {
    border-radius: 16px 16px 5px 16px;
    background: rgba(40,120,227,.12); border-color: rgba(88,166,255,.32);
}
.msg-author { display: block; margin-bottom: 4px; color: var(--text-secondary); font-size: var(--font-size-xs); font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.msg-bubble p { margin: 0; white-space: pre-wrap; line-height: 1.6; font-size: .88rem; }
.msg-bubble time { display: block; margin-top: 7px; color: var(--text-secondary); font-size: var(--font-size-xs); }
.msg-attachment { display: block; width: 100%; margin-top: 10px; padding: 0; border: 0; background: transparent; color: inherit; cursor: zoom-in; text-align: start; }
.msg-attachment img {
    display: block; width: min(100%, 340px); max-height: 250px; object-fit: cover;
    border-radius: 10px; border: 1px solid var(--border-color);
    transition: transform .2s ease;
}
.msg-attachment:hover img { transform: scale(1.02); }
.message-delivery-state {
    display: flex; align-items: center; gap: 6px; margin-top: 8px;
    color: var(--text-secondary); font-size: var(--font-size-xs); font-weight: 700;
}
.message-delivery-state.failed { color: #ef4444; }
.message-delivery-state.cancelled { color: var(--status-warning-text); }
.message-delivery-state button {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
    padding: 3px 8px; border: 1px solid currentColor; border-radius: 999px;
    background: transparent; color: inherit; cursor: pointer; font: inherit;
}
.support-message.is-sending { opacity: .76; }
.support-message.is-failed .msg-bubble { border-color: rgba(239,68,68,.45); }
.support-message.is-cancelled .msg-bubble { border-color: var(--status-warning-border); }

/* --- Reply composer --- */
.ticket-reply-composer {
    position: sticky; bottom: 0; flex-shrink: 0;
    display: grid; gap: 8px;
    padding: 11px;
    border: 1px solid var(--border-color); border-radius: 16px;
    background: color-mix(in srgb, var(--primary-card-bg) 94%, transparent);
    box-shadow: 0 -12px 30px rgba(0,0,0,.12);
    backdrop-filter: blur(15px);
}
.composer-visible-label {
    display: block;
    color: var(--text-primary);
    font-size: .76rem;
    font-weight: 750;
    line-height: 1.35;
}
.ticket-reply-main { display: grid; grid-template-columns: minmax(0, 1fr) 44px 48px; gap: 8px; align-items: end; }
.ticket-reply-composer textarea { min-height: 46px; max-height: 140px; padding: 12px; resize: vertical; }
.composer-attachment,
.ticket-reply-composer button {
    height: 46px;
    display: grid; place-items: center;
    border: 1px solid var(--border-color); border-radius: 12px;
    background: var(--secondary-card-bg); color: var(--text-secondary);
    cursor: pointer;
    transition: border-color .16s ease, color .16s ease, filter .16s ease;
}
.composer-attachment:hover { border-color: var(--accent-color); color: var(--accent-color); }
.composer-attachment.has-file { border-color: #2fb574; color: #2fb574; }
.ticket-reply-composer button { border: 0; background: var(--action-primary); color: var(--action-on-primary); }
.ticket-reply-composer button:hover { filter: brightness(1.08); }
.ticket-reply-composer button:disabled { opacity: .6; cursor: not-allowed; }
.accessible-file-input { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.accessible-file-input:focus + .file-upload-label,
.composer-file:focus + .composer-attachment {
    outline: 2px solid var(--focus-ring);
    outline-offset: 3px;
}
.file-upload-label { background: var(--secondary-card-bg) !important; color: var(--text-primary) !important; }

.support-attachment-preview {
    min-width: 0; display: grid; grid-template-columns: 58px minmax(0, 1fr) 36px; gap: 10px; align-items: center;
    margin-top: 9px; padding: 8px;
    border: 1px solid var(--border-color); border-radius: 12px;
    background: var(--secondary-card-bg);
}
.attachment-thumbnail-button {
    width: 58px; height: 48px; padding: 0; overflow: hidden;
    border: 1px solid var(--border-color); border-radius: 9px;
    background: var(--primary-card-bg); cursor: zoom-in;
}
.attachment-thumbnail-button img { width: 100%; height: 100%; display: block; object-fit: cover; }
.attachment-file-meta { min-width: 0; display: grid; gap: 3px; }
.attachment-file-meta strong { overflow: hidden; color: var(--text-primary); font-size: var(--font-size-sm); text-overflow: ellipsis; white-space: nowrap; }
.attachment-file-meta small { color: var(--text-secondary); font-size: var(--font-size-xs); }
.attachment-remove {
    width: 44px; height: 44px; display: grid; place-items: center;
    border: 1px solid var(--border-color); border-radius: 9px;
    background: transparent; color: var(--text-secondary); cursor: pointer;
}
.attachment-remove:hover { border-color: #ef4444; color: #ef4444; }
.support-upload-state {
    display: grid; grid-template-columns: minmax(90px, 1fr) minmax(0, 1.5fr) auto; gap: 9px; align-items: center;
    margin-top: 8px; color: var(--text-secondary); font-size: var(--font-size-xs);
}
.support-upload-state progress { width: 100%; height: 8px; accent-color: var(--accent-color); }
.support-retry-btn {
    min-height: 44px; padding: 5px 10px;
    border: 1px solid var(--accent-color); border-radius: 9px;
    background: transparent; color: var(--accent-color); cursor: pointer; font: inherit; font-weight: 750;
}
.support-error-state { color: var(--text-secondary); }
.support-error-state h3 { color: var(--text-primary); }

.support-lightbox { z-index: var(--layer-lightbox); padding: clamp(12px, 3vw, 32px); }
.support-lightbox-box {
    width: min(96vw, 1100px); height: min(92dvh, 900px); max-width: 1100px;
    display: flex; flex-direction: column; overflow: hidden;
}
.support-lightbox-box figure {
    min-height: 0; flex: 1; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 10px;
    margin: 0; padding: 14px; background: #080b12;
}
.support-lightbox-box img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.support-lightbox-box figcaption { color: #e5e7eb; text-align: center; font-size: .78rem; overflow-wrap: anywhere; }

/* Fix unreadable legacy reply surfaces. */
.reply-input-area { background: var(--secondary-card-bg) !important; }
.reply-input-area input { background: var(--primary-card-bg) !important; color: var(--text-primary) !important; }

.signal-risk-model {
    margin-top: 14px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-medium);
    background: var(--secondary-card-bg);
}
.signal-risk-model h4 { margin: 0 0 10px; color: var(--text-primary); }
.locked-feature-button { width: 100%; font: inherit; color: inherit; }
.signal-risk-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.signal-risk-grid > div { min-width: 0; padding: 9px; border-radius: 9px; background: var(--primary-card-bg); }
.signal-risk-grid span { display: block; margin-bottom: 3px; color: var(--text-secondary); font-size: .68rem; }
.signal-risk-grid strong { display: block; color: var(--text-primary); font-size: .82rem; overflow-wrap: anywhere; }
.risk-model-note,
.ph-caveat { margin: 10px 0 0; color: var(--text-secondary); font-size: .72rem; line-height: 1.55; }
.ph-caveat { padding: 10px 12px; border-inline-start: 2px solid var(--hold-color); background: rgba(245, 158, 11, .08); }
.glance-item[data-key*='unavailable'] i { color: var(--text-secondary); }

@media (max-width: 560px) {
    .signal-risk-grid { grid-template-columns: 1fr 1fr; }
}

:where(button, input, select, textarea, [role="button"]):focus-visible { outline: 2px solid var(--accent-color); outline-offset: 3px; }

/* The bubble tail now lives on .msg-bubble; these older rules targeted the flex
   wrapper, which no longer carries a border-radius. RTL handling sits next to the
   .msg-bubble rules above. */

@media (max-width: 820px) {
    .workspace-modal-box { width: 100vw; height: 100dvh; max-height: none; border-radius: 0; }
    .history-toolbar { flex-wrap: wrap; }
    .history-search { flex-basis: 100%; }
    .history-tool-btn { flex: 1; }
    .history-workspace { display: block; position: relative; }
    .history-list-pane { height: 100%; border-inline-end: 0; }
    .history-detail-pane { display: none; height: 100%; }
    .history-workspace.detail-open .history-list-pane { display: none; }
    .history-workspace.detail-open .history-detail-pane { display: block; }
    .history-metric-grid { grid-template-columns: 1fr 1fr; }
    .support-workspace { display: block; position: relative; }
    .support-ticket-sidebar { height: 100%; border-inline-end: 0; }
    .support-conversation-pane { display: none; height: 100%; }
    .support-workspace.conversation-open .support-ticket-sidebar { display: none; }
    .support-workspace.conversation-open .support-conversation-pane { display: flex; }
    .support-message { max-width: 88%; }
    .support-hero .support-quick-grid { width: 100%; }
    .support-network-status { justify-content: flex-start; padding-inline: 13px; }
    /* The back control is the only way out of a conversation on a phone, so it
       must never be pushed off-screen by a long ticket subject. */
    .conversation-heading { flex-wrap: wrap; }
    .conversation-heading > div:first-child { flex: 1 1 100%; order: 2; }
    .conversation-actions { flex: 0 0 auto; order: 1; margin-inline-start: auto; }
}

@media (max-width: 430px) {
    .workspace-modal-header { min-height: 70px; padding: 13px 15px; }
    .history-filter-chips { padding-inline: 12px; }
    .history-detail-pane,
    .create-ticket-panel,
    .ticket-conversation-panel { padding: 15px; }
    .history-metric-grid { gap: 7px; }
    .conversation-actions { flex-direction: row; gap: 6px; }
    .support-message { max-width: 94%; }
    .support-hero .support-quick-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .support-quick-card { min-height: 74px; font-size: .74rem; }
    .ticket-reply-main { grid-template-columns: minmax(0, 1fr) 42px 44px; }
    .ticket-reply-composer { padding: 9px; }
    .support-upload-state { grid-template-columns: 1fr auto; }
    .support-upload-state progress { grid-column: 1 / -1; }
    .msg-avatar { width: 26px; height: 26px; font-size: .64rem; }
}
/* Keyboard users can bypass repeated navigation without changing the visual shell. */
.skip-link {
    position: fixed;
    inset-inline-start: 1rem;
    top: 0.5rem;
    z-index: var(--layer-toast);
    padding: 0.7rem 1rem;
    border-radius: 0.6rem;
    background: #ffffff;
    color: #111827;
    font-weight: 800;
    transform: translateY(-160%);
    transition: transform 120ms ease;
}

.skip-link:focus {
    transform: translateY(0);
}

[data-theme="light"] .auto-tuner-card .at-title,
[data-theme="light"] .auto-tuner-card .at-stat-row strong {
    color: var(--text-strong);
}

[data-theme="light"] .auto-tuner-card .at-col-header,
[data-theme="light"] .auto-tuner-card .at-stat-row span,
[data-theme="light"] .auto-tuner-card .at-badge.negative {
    color: var(--text-muted);
}

#sniper-scope-card {
    margin-block: 0 1.8rem;
    overflow: hidden;
}

#sniper-scope-card .sniper-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

#sniper-scope-card .sniper-header h3 {
    margin: 0;
    color: var(--text-primary);
}

#sniper-scope-card .radar-container {
    position: relative;
    min-height: 18rem;
    display: grid;
    place-items: center;
    background: radial-gradient(circle, rgba(0, 255, 136, 0.04), transparent 70%);
}

#sniper-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#sniper-scope-card .radar-overlay {
    position: relative;
    z-index: 2;
    text-align: center;
    pointer-events: none;
}

#sniper-probability {
    font-size: clamp(2rem, 6vw, 2.8rem);
    font-weight: 800;
    color: var(--text-secondary);
}

.sniper-caption {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.data-provenance-card dl {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0.75rem;
    margin: 0;
}

.data-provenance-card dl > div {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.7rem;
    background: var(--secondary-card-bg);
}

.data-provenance-card dt {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.data-provenance-card dd {
    margin: 0.25rem 0 0;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.data-provenance-card .provenance-disclosure {
    margin: -0.25rem 0 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

@media (max-width: 360px) {
    .data-provenance-card dl {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ===================================================================
   HARDENED SHARED CONTROLS, DIALOGS AND GLOBAL CATALOGUE
   =================================================================== */
button.companion-card {
    width: 100%;
    color: var(--text-primary);
    font: inherit;
    appearance: none;
}

.global-combobox {
    position: relative;
    min-width: 0;
}

.global-symbol-results {
    position: absolute;
    z-index: var(--layer-dropdown);
    inset-block-start: calc(100% + 6px);
    inset-inline: 0;
    max-height: min(19rem, 48vh);
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border-semantic);
    border-radius: 12px;
    background: var(--surface-elevated);
    box-shadow: 0 16px 38px rgba(0, 0, 0, .32);
}

.global-symbol-option {
    display: grid;
    gap: 2px;
    min-height: 48px;
    padding: 9px 11px;
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
}

.global-symbol-option strong {
    font-size: .86rem;
}

.global-symbol-option span {
    color: var(--text-secondary);
    font-size: .72rem;
}

.global-symbol-option:hover,
.global-symbol-option.active,
.global-symbol-option[aria-selected="true"] {
    background: var(--accent-subtle-bg);
    outline: 2px solid var(--focus-ring);
    outline-offset: -2px;
}

.field-status {
    min-height: 1.25rem;
    margin-block-start: 5px;
    color: var(--text-secondary);
    font-size: .72rem;
    line-height: 1.45;
}

.inline-retry {
    min-height: 44px;
    margin-inline-start: 4px;
    padding-inline: 10px;
    border: 1px solid var(--border-semantic);
    border-radius: 7px;
    background: var(--surface-subtle);
    color: var(--text-primary);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.back-to-plans-btn,
.plan-action-btn,
.auth-btn,
#global-submit-btn {
    min-height: 44px;
}

body.modal-open {
    position: fixed;
    inset-inline: 0;
    top: var(--dialog-scroll-offset, 0);
    width: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

[data-dialog-inert="true"] {
    pointer-events: none;
    user-select: none;
}

/* Checkout inherits the active theme instead of forcing a light surface. */
.checkout-body,
.checkout-content {
    min-width: 0;
    max-width: 100%;
    color: var(--text-primary);
}

.checkout-header h3,
.verification-box h4,
.success-glass-container h2 {
    color: var(--text-primary);
}

#crypto-checkout-view .payment-details-box,
.verification-box,
.success-glass-container {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    background: var(--surface-subtle);
    border-color: var(--border-semantic);
    color: var(--text-primary);
}

#crypto-checkout-view .payment-details-box {
    padding: clamp(18px, 4vw, 40px) !important;
}

.verification-box p,
.success-glass-container p,
.pay-row span {
    color: var(--text-secondary);
}

.pay-row {
    border-color: var(--border-semantic);
}

.pay-row strong {
    color: var(--text-primary);
}

.admin-support-modal-box {
    width: min(1200px, 100%);
    height: min(90dvh, 900px);
    max-width: 1200px;
}

.admin-support-toolbar {
    display: grid;
    grid-template-columns: repeat(4, minmax(130px, 1fr));
    gap: 9px;
    align-items: end;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-color);
}

.admin-support-toolbar label { min-width: 0; display: grid; gap: 4px; }
.admin-support-toolbar label > span { color: var(--text-secondary); font-size: var(--font-size-xs); font-weight: 750; }
.admin-support-search-label { grid-column: span 2; }
.admin-support-toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.admin-support-toolbar :is(input, select, button) {
    min-width: 0;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid var(--border-semantic);
    border-radius: 9px;
    background: var(--surface-subtle);
    color: var(--text-primary);
    font: inherit;
}

.admin-support-auth-state {
    display: grid; grid-template-columns: minmax(220px, 1fr) minmax(300px, 1.25fr);
    align-items: end; gap: 14px;
    padding: 10px 18px; border-bottom: 1px solid rgba(239,68,68,.42);
    background: rgba(239,68,68,.1); color: var(--text-primary); font-size: .78rem;
}
.admin-support-auth-copy { min-width: 0; display: grid; gap: 3px; line-height: 1.4; }
.admin-support-auth-copy strong { color: var(--status-error-text); }
#admin-support-reauth-status { min-height: 1.1em; color: var(--text-secondary); }
.admin-support-reauth-form {
    min-width: 0; display: grid; grid-template-columns: minmax(150px, 1fr) auto auto;
    gap: 8px; align-items: end;
}
.admin-support-reauth-form label { min-width: 0; display: grid; gap: 3px; }
.admin-support-reauth-form label > span { color: var(--text-secondary); font-size: var(--font-size-xs); font-weight: 750; }
.admin-support-reauth-form :is(input, button) {
    min-width: 0; min-height: 44px; padding: 7px 10px;
    border: 1px solid var(--border-semantic); border-radius: 9px;
    background: var(--surface-subtle); color: var(--text-primary); font: inherit;
}
.admin-support-reauth-form button {
    border-color: var(--status-error-text); color: var(--status-error-text); font-weight: 800; cursor: pointer;
}
.admin-support-reauth-form button:disabled { cursor: wait; opacity: .65; }
.admin-support-reauth-form #admin-support-reauth-retry {
    border-color: var(--accent-color); color: var(--accent-color);
}

.admin-support-totals {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    min-height: var(--control-height);
    padding: 8px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    background: var(--surface-subtle);
    font-size: var(--font-size-xs);
}

.admin-support-totals span {
    padding: 4px 8px;
    border: 1px solid var(--border-semantic);
    border-radius: var(--radius-pill);
    background: var(--surface-elevated);
}

.admin-support-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: var(--surface);
}

.admin-tickets-view {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    overflow: hidden;
}

.admin-ticket-master,
.admin-ticket-detail {
    min-width: 0;
    min-height: 0;
}

.admin-ticket-master {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-inline-end: 1px solid var(--border-color);
    background: var(--surface-subtle);
}

.admin-ticket-list {
    min-height: 0;
    flex: 1;
    display: grid;
    align-content: start;
    gap: 8px;
    overflow: hidden auto;
    padding: 12px;
    overscroll-behavior: contain;
}

.admin-ticket-list-item {
    width: 100%;
    min-width: 0;
    min-height: 104px;
    display: grid;
    gap: 5px;
    padding: 12px;
    border: 1px solid var(--border-semantic);
    border-inline-start: 2px solid transparent;
    border-radius: var(--border-radius-medium);
    background: var(--surface-elevated);
    color: var(--text-primary);
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.admin-ticket-list-item:hover,
.admin-ticket-list-item.active {
    border-color: var(--focus-ring);
    background: var(--accent-subtle-bg);
}

.admin-ticket-list-item.has-unread { border-inline-start-color: var(--status-info); }
.admin-ticket-list-top,
.admin-ticket-list-meta { display: flex; align-items: center; gap: 7px; min-width: 0; }
.admin-ticket-list-top { justify-content: space-between; }
.admin-ticket-list-top strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-ticket-list-ref,
.admin-ticket-list-preview,
.admin-ticket-list-user { min-width: 0; color: var(--text-secondary); font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-ticket-list-meta { flex-wrap: wrap; }
.admin-ticket-list-meta time { margin-inline-start: auto; color: var(--text-secondary); font-size: var(--font-size-xs); }

.admin-ticket-detail {
    overflow: hidden auto;
    padding: clamp(12px, 2vw, 22px);
    overscroll-behavior: contain;
    background: var(--surface);
}

.admin-support-ticket-card {
    min-width: 0; display: grid; gap: 12px; padding: clamp(14px, 2vw, 21px);
    border: 1px solid var(--border-color); border-radius: 16px;
    background: var(--primary-card-bg);
}
.admin-ticket-back {
    display: none;
    min-height: var(--control-height);
    align-items: center;
    gap: 8px;
    padding-inline: 12px;
    border: 1px solid var(--border-semantic);
    border-radius: 9px;
    background: var(--surface-subtle);
    color: var(--text-primary);
    font: inherit;
    font-weight: 750;
}
.admin-support-ticket-card[aria-busy="true"] { opacity: .78; }
.admin-ticket-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.admin-ticket-heading > div { min-width: 0; }
.admin-ticket-heading h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 6px 0; color: var(--text-primary); font-size: 1.02rem; overflow-wrap: anywhere; }
.admin-ticket-control-grid {
    display: grid; grid-template-columns: repeat(3, minmax(130px, 1fr)) auto; gap: 9px; align-items: end;
    padding: 11px; border: 1px solid var(--border-color); border-radius: 12px;
    background: var(--secondary-card-bg);
}
.admin-ticket-control-grid label { min-width: 0; display: grid; gap: 4px; }
.admin-ticket-control-grid label > span { color: var(--text-secondary); font-size: var(--font-size-xs); font-weight: 750; }
.admin-ticket-control-grid select {
    width: 100%; min-width: 0; min-height: 44px; padding: 7px 9px;
    border: 1px solid var(--border-color); border-radius: 9px;
    background: var(--primary-card-bg); color: var(--text-primary); font: inherit; font-size: var(--font-size-sm);
}
.admin-ticket-control-grid .support-ghost-btn { min-height: 44px; justify-content: center; }

.admin-ticket-sla {
    display: grid; grid-template-columns: minmax(130px, .8fr) repeat(3, minmax(0, 1fr)); gap: 8px; align-items: center;
    padding: 9px 11px; border: 1px solid var(--border-color); border-inline-start-width: 2px; border-radius: 10px;
    color: var(--text-secondary); background: var(--secondary-card-bg); font-size: var(--font-size-xs);
}
.admin-ticket-sla strong { color: var(--text-primary); }
.admin-ticket-sla.sla-breached { border-inline-start-color: var(--status-error); background: rgba(239,68,68,.08); }
.admin-ticket-sla.sla-due_soon { border-inline-start-color: var(--status-warning); background: rgba(245,158,11,.08); }
.admin-ticket-sla.sla-on_track, .admin-ticket-sla.sla-met { border-inline-start-color: var(--status-success); }
.admin-ticket-section-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.admin-ticket-section-actions .support-load-more { margin: 0; }

.admin-ticket-messages {
    min-height: 120px; max-height: 420px; display: flex; flex-direction: column; gap: 10px;
    overflow-y: auto; padding: 13px; border: 1px solid var(--border-color); border-radius: 13px;
    background: var(--secondary-card-bg);
}
.admin-ticket-messages .chat-bubble { padding: 11px 13px; font-size: var(--font-size-sm); box-shadow: none; }
.chat-internal-note {
    max-width: 100%; align-self: stretch;
    border: 1px dashed rgba(139,92,246,.65); border-radius: 11px;
    background: rgba(139,92,246,.09); color: var(--text-primary);
}
.chat-internal-note .chat-meta { color: #8b5cf6; justify-content: flex-start; gap: 4px; }

.admin-ticket-composer {
    /* Keep long forms in the scroll flow so ticket actions remain reachable. */
    position: static;
    display: grid; gap: 9px; padding: 11px;
    border: 1px solid var(--border-color); border-radius: 13px;
    background: var(--surface-elevated);
    box-shadow: none;
}
.admin-composer-topline { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.admin-composer-topline label { display: grid; gap: 4px; }
.admin-composer-topline label > span { color: var(--text-secondary); font-size: var(--font-size-xs); font-weight: 750; }
.admin-composer-topline select {
    min-height: 44px; padding: 6px 9px; border: 1px solid var(--border-color); border-radius: 9px;
    background: var(--primary-card-bg); color: var(--text-primary); font: inherit;
}
.admin-composer-privacy { color: var(--text-secondary); font-size: var(--font-size-xs); }
.admin-ticket-composer textarea {
    width: 100%; min-height: 76px; padding: 10px 11px; resize: vertical;
    border: 1px solid var(--border-color); border-radius: 10px;
    background: var(--primary-card-bg); color: var(--text-primary); font: inherit; line-height: 1.5;
}
.admin-composer-actions { display: flex; align-items: center; gap: 9px; }
.admin-composer-actions .composer-attachment { flex: 0 0 44px; height: 44px; }
.admin-composer-actions .composer-meta { flex: 1; margin: 0; }
.admin-ticket-composer > .support-attachment-preview { margin-top: 0; }
.admin-ticket-composer > .support-upload-state { margin-top: 0; }

.admin-ticket-audit {
    padding: 12px; border: 1px solid var(--border-color); border-radius: 13px;
    background: var(--secondary-card-bg);
}
.admin-ticket-audit [data-admin-audit-list] { display: grid; gap: 0; }
.admin-audit-event { position: relative; display: grid; grid-template-columns: 15px minmax(0, 1fr); gap: 9px; min-width: 0; }
.admin-audit-event:not(:last-child)::before { content: ''; position: absolute; inset-inline-start: 6px; top: 15px; bottom: -2px; width: 1px; background: var(--border-color); }
.admin-audit-marker { position: relative; z-index: 1; width: 13px; height: 13px; margin-top: 4px; border: 3px solid var(--accent-color); border-radius: 50%; background: var(--primary-card-bg); }
.admin-audit-event > div { min-width: 0; display: grid; gap: 5px; padding-bottom: 14px; }
.admin-audit-event strong { color: var(--text-primary); font-size: var(--font-size-sm); text-transform: capitalize; }
.admin-audit-event > div > span { color: var(--text-secondary); font-size: var(--font-size-xs); }
.admin-audit-change { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.admin-audit-change del, .admin-audit-change ins { padding: 2px 6px; border-radius: 6px; text-decoration: none; overflow-wrap: anywhere; }
.admin-audit-change del { color: var(--status-error-text); background: rgba(239,68,68,.09); }
.admin-audit-change ins { color: var(--status-success-text); background: rgba(47,181,116,.09); }

.support-load-more {
    align-self: center;
    min-height: 44px;
    margin: 8px auto;
    padding: 8px 14px;
    border: 1px solid var(--border-semantic);
    border-radius: 9px;
    background: var(--surface-subtle);
    color: var(--text-primary);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.composer-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-block-start: 5px;
    color: var(--text-secondary);
    font-size: .7rem;
}

.ticket-reply-composer .composer-meta {
    grid-column: 1 / -1;
    margin: 0 3px;
}

@media (max-width: 820px) {
    .workspace-modal-box {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        border-radius: 0;
    }

    .admin-support-toolbar {
        grid-template-columns: 1fr 1fr;
    }

    .admin-tickets-view { display: block; position: relative; }
    .admin-ticket-master,
    .admin-ticket-detail { width: 100%; height: 100%; }
    .admin-ticket-master { border-inline-end: 0; }
    .admin-ticket-detail { display: none; }
    .admin-tickets-view.detail-open .admin-ticket-master { display: none; }
    .admin-tickets-view.detail-open .admin-ticket-detail { display: block; }
    .admin-ticket-back {
        position: sticky;
        inset-block-start: 0;
        z-index: var(--layer-sticky);
        display: inline-flex;
        width: fit-content;
    }

    .admin-support-search-label { grid-column: 1 / -1; }
    .admin-support-toolbar-actions { grid-column: 1 / -1; }
    .admin-ticket-control-grid { grid-template-columns: 1fr 1fr; }
    .admin-ticket-control-grid .support-ghost-btn { width: 100%; }
    .admin-ticket-sla { grid-template-columns: 1fr 1fr; }
}

.support-workspace [dir="auto"],
.admin-support-body [dir="auto"] {
    unicode-bidi: plaintext;
    text-align: start;
}

.admin-ticket-invariant-warning {
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--danger-color, #dc2626) 45%, transparent);
    border-radius: var(--radius-sm, 8px);
    background: color-mix(in srgb, var(--danger-color, #dc2626) 10%, var(--surface));
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

@media (max-width: 600px) {
    .modal-overlay {
        padding: 0;
        align-items: stretch;
    }

    .modal-box,
    .plans-modal-box,
    .admin-support-modal-box {
        width: 100vw !important;
        max-width: 100vw !important;
        min-height: 100dvh;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0 !important;
        border-radius: 0;
    }

    .admin-confirm-box {
        width: calc(100vw - 24px) !important;
        max-width: 32rem !important;
        min-height: 0;
        height: auto;
        max-height: calc(100dvh - 24px);
        margin: auto !important;
        border-radius: 16px;
    }

    .plans-body,
    .checkout-body,
    .modal-body {
        padding: 16px;
    }

    .global-symbol-results {
        position: fixed;
        inset-inline: 12px;
        inset-block-start: auto;
        bottom: max(12px, env(safe-area-inset-bottom));
        max-height: 42dvh;
    }

    .global-availability-status {
        align-items: stretch;
        flex-direction: column;
        gap: 4px;
    }

    .admin-support-auth-state { grid-template-columns: 1fr; align-items: stretch; }
    .admin-support-reauth-form { grid-template-columns: 1fr; }
    .admin-support-toolbar { grid-template-columns: 1fr; padding: 10px 12px; max-height: 36dvh; overflow-y: auto; overscroll-behavior: contain; }
    .admin-support-search-label,
    .admin-support-toolbar-actions { grid-column: auto; }
    .admin-ticket-heading { align-items: flex-start; flex-direction: column; }
    .admin-ticket-control-grid { grid-template-columns: 1fr; }
    .admin-ticket-sla { grid-template-columns: 1fr; }
    .admin-ticket-section-actions { align-items: stretch; flex-direction: column; }
    .admin-ticket-section-actions > * { width: 100%; justify-content: center; }
    .admin-ticket-detail { padding: 10px; }
    .admin-support-ticket-card { border-radius: 12px; padding: 12px; }
    .admin-composer-topline { align-items: stretch; flex-direction: column; }
    .admin-composer-actions { align-items: stretch; flex-wrap: wrap; }
    .admin-composer-actions .composer-meta { flex-basis: calc(100% - 54px); }
    .admin-composer-actions .reply-btn-small { flex-basis: 100%; }
    .chat-bubble { min-width: 0; max-width: 96%; }
    .support-lightbox-box figure { padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .orb,

    #global-controls-container,
    #controls-container,
    #market-controls-container,
    #result-container,
    .backtest-section,
    #price-hunter-output,
    .modal,
    #order-book-card,
    .whale-radar-section:not(.hidden),
    .market-health-row,
    #order-flow-obi-container,
    .auto-tuner-card,
    #auto-tuner-container:not(.hidden),
    #advanced-auto-tuner-container:not(.hidden),
    .fractal-card,
    .auth-card,
    .success-glass-container,
    #sidebar-overlay,
    .toast,
    .toast.toast-exiting,
    .support-message,
    .security-shield-card.scam,
    .backtest-loader-msg,
    .alloc-progress-fill::after,
    .typing-cursor::after,
    .at-arrow,
    .at-col.optimized::after {
        animation: none !important;
    }

    .success-checkmark,
    .success-checkmark__circle,
    .success-checkmark__check {
        animation: none !important;
        stroke-dashoffset: 0;
    }

    :where(.modal, .modal-box, #sidebar-menu, #sidebar-overlay, .toast) {
        transition-duration: var(--duration-fast) !important;
    }
}

@media (forced-colors: active) {
    :where(button, input, select, textarea, a, [role="option"], .modal-box) {
        forced-color-adjust: auto;
        border: 1px solid ButtonText;
    }

    :where(button, input, select, textarea, a, [role="option"]):focus-visible {
        outline: 3px solid Highlight;
    }

    .support-unread-chip {
        border-color: CanvasText;
        color: CanvasText;
    }

    .liquid-bg,
    .orb {
        display: none;
    }
}
