:root {
    /* Color Palette matching Algo Bot */
    --sidebar-bg: linear-gradient(180deg, #110326 0%, #1e0545 35%, #2a0760 70%, #170238 100%);
    --sidebar-active: rgba(255, 255, 255, 0.16);
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-text: #e2d9f3;
    --sidebar-text-muted: #a796c9;

    --bg-main: #f8fafc;
    --panel-bg: #ffffff;
    --border-color: #e2e8f0;
    --border-subtle: #f1f5f9;

    --accent-purple: #3b0764;
    --accent-purple-light: #581c87;
    --accent-purple-gradient: linear-gradient(90deg, #3b0764 0%, #1e1b4b 100%);
    --accent-blue: #2563eb;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    /* Trade Status Colors */
    --profit: #16a34a;
    --profit-bg: #dcfce7;
    --loss: #dc2626;
    --loss-bg: #fee2e2;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --info-bg: #e0f2fe;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Roboto Mono', monospace;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

/* Utilities */
.flex { display: flex; }
.flex-column { display: flex; flex-direction: column; }
.flex-1 { flex: 1; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.w-100 { width: 100%; }
.mono { font-family: var(--font-mono); }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.text-profit { color: var(--profit) !important; font-weight: 600; }
.text-loss { color: var(--loss) !important; font-weight: 600; }
.text-muted { color: var(--text-muted); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.5rem 1rem;
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.85rem;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    outline: none;
    text-decoration: none;
}
.btn-primary {
    background: var(--accent-purple);
    color: #ffffff;
}
.btn-primary:hover {
    background: var(--accent-purple-light);
    box-shadow: 0 4px 12px rgba(59, 7, 100, 0.25);
}
.btn-gradient {
    background: var(--accent-purple-gradient);
    color: #ffffff;
    font-weight: 600;
}
.btn-gradient:hover {
    opacity: 0.95;
    box-shadow: 0 4px 14px rgba(30, 27, 75, 0.3);
}
.btn-secondary {
    background: #ffffff;
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: var(--text-primary);
}
.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.35rem 0.5rem;
}
.btn-ghost:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}
.btn-sm {
    font-size: 0.82rem;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
}
.btn-xs {
    font-size: 0.72rem;
    padding: 0.18rem 0.45rem;
    border-radius: 4px;
}
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon-green {
    background: #dcfce7;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}
.btn-icon-green:hover { background: #bbf7d0; }
.btn-icon-red {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}
.btn-icon-red:hover { background: #fecaca; }

/* Form Controls */
.input-group { margin-bottom: 1rem; width: 100%; }
.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    line-height: 1.5;
    transition: all 0.15s;
    box-sizing: border-box;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent-purple-light);
    box-shadow: 0 0 0 3px rgba(88, 28, 135, 0.12);
    outline: none;
}

/* Explicit full-width and matching styling for Group form inputs */
#group-form-name,
#group-form-desc {
    width: 100% !important;
    height: 42px;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: var(--text-primary);
    background: #ffffff;
    box-sizing: border-box;
}

/* Badges & Chips */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-blue { background: #eff6ff; color: #2563eb; border: 1px solid #dbeafe; }
.badge-purple { background: #faf5ff; color: #7e22ce; border: 1px solid #f3e8ff; }
.badge-green { background: var(--profit-bg); color: var(--profit); border: 1px solid #bbf7d0; }
.badge-red { background: var(--loss-bg); color: var(--loss); border: 1px solid #fecaca; }
.badge-orange { background: var(--warning-bg); color: var(--warning); border: 1px solid #fde68a; }

.param-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.73rem;
    padding: 0.2rem 0.5rem;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
}
.param-chip strong { color: var(--text-primary); }
.param-chip.delta-buy { background: #fef2f2; color: #ef4444; border-color: #fee2e2; }
.param-chip.delta-sell { background: #f0fdf4; color: #16a34a; border-color: #dcfce7; }

/* Switch Toggle */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #cbd5e1;
    transition: 0.2s;
    border-radius: 22px;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider {
    background-color: #10b981;
}
.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ========================================================
   Sidebar (Deep Purple Gradient)
   ======================================================== */
.sidebar {
    width: 250px;
    min-width: 250px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    color: #ffffff;
    user-select: none;
    position: relative;
    z-index: 20;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.12);
}

.sidebar-header {
    padding: 1.75rem 1.25rem 1.25rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mobile-sidebar-close {
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
    line-height: 1;
}
.mobile-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 998;
}
.sidebar-backdrop.active {
    display: block;
}

/* Sci-fi Futuristic Logo */
.brand-logo-container {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}
.brand-logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: #ffffff;
    text-shadow: 0 0 15px rgba(168, 85, 247, 0.4);
    display: flex;
    align-items: center;
    gap: 6px;
}
.brand-badge-ai {
    font-size: 0.68rem;
    font-weight: 800;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid #38bdf8;
    padding: 1px 6px;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.85rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.7rem 1rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--sidebar-text-muted);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
    text-align: left;
}
.nav-item:hover {
    color: #ffffff;
    background: var(--sidebar-hover);
}
.nav-item.active {
    color: #ffffff;
    background: var(--sidebar-active);
    font-weight: 600;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.2);
}
.nav-item .nav-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
}
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
    padding: 1rem 0.85rem 0.5rem 0.85rem;
}
.logout-btn-pill {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.65rem 1rem;
    background: rgba(220, 38, 38, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #fca5a5;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.logout-btn-pill:hover {
    background: rgba(220, 38, 38, 0.25);
    color: #ffffff;
    border-color: #ef4444;
}

.sidebar-credit {
    padding: 0.75rem 1rem;
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ========================================================
   Main Content Area
   ======================================================== */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-main);
}

/* Top Navbar */
.top-navbar {
    height: 64px;
    min-height: 64px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}
.navbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0.35rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
}
.mobile-menu-btn:hover {
    background: #f1f5f9;
}
.user-greeting {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.navbar-center-ticker {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.ticker-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    background: #f1f5f9;
}
.ticker-pill.green { background: #dcfce7; color: #15803d; }
.ticker-pill.red { background: #fee2e2; color: #b91c1c; }

.navbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.user-avatar-glow {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #38bdf8 0%, #a855f7 100%);
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.user-avatar-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #1e1b4b;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

/* Scrollable View Area */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
}
.view-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ========================================================
   1. Dashboard Overview Cards Grid (dash.png)
   ======================================================== */
.stats-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}

.dash-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
}

.cursor-pointer {
    cursor: pointer;
}

/* Dashboard Section Navigation Action Buttons */
.dash-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-purple, #3b0764);
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease-in-out;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.dash-nav-btn:hover {
    background: #f8fafc;
    border-color: var(--accent-purple, #3b0764);
    color: var(--accent-purple, #3b0764);
    box-shadow: 0 2px 6px rgba(59, 7, 100, 0.1);
    transform: translateY(-1px);
}

.dash-nav-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}


.stat-card-modern {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.15rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card-modern:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.stat-icon-box {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.stat-details label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}
.stat-details .stat-number {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

/* ========================================================
   2. Strategies / Webhooks Grid (strategy.png)
   ======================================================== */
.strategies-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}


.strategy-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
    transition: box-shadow 0.2s, transform 0.15s;
}
.strategy-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.06);
}

.strategy-card-header {
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px dashed var(--border-color);
}
.strategy-card-header .title-area {
    flex: 1;
    min-width: 0;
    padding-right: 0.75rem;
}
.strategy-card-header .st-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.strategy-card-header .st-index {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.strategy-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.strategy-card-body {
    padding: 1.15rem 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.9rem;
}
.strategy-desc-text {
    font-size: 0.83rem;
    color: var(--text-secondary);
    line-height: 1.45;
    min-height: 2.4em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.strategy-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    background: #f8fafc;
    padding: 0.75rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.strategy-meta-col {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.strategy-meta-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.strategy-meta-val {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

/* Strategy Card Bottom Tabs */
.strategy-card-footer {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--border-color);
}
.st-footer-tab {
    padding: 0.65rem 0.25rem;
    text-align: center;
    background: #f8fafc;
    border: none;
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    border-right: 1px solid var(--border-color);
}
.st-footer-tab:last-child { border-right: none; }
.st-footer-tab:hover { background: #f1f5f9; color: var(--text-primary); }
.st-footer-tab.active-purple {
    background: #3b0764;
    color: #ffffff;
    font-weight: 600;
}
.st-footer-tab.active-purple:hover { background: #581c87; }

/* ========================================================
   3. Manage Broker (broker.png)
   ======================================================== */
.broker-container {
    max-width: 900px;
    margin: 0 auto;
}
.broker-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.expiring-countdown-card {
    background: #1e1b4b;
    color: #ffffff;
    border-radius: 10px;
    padding: 0.75rem 1.25rem;
    text-align: center;
    box-shadow: 0 4px 15px rgba(30, 27, 75, 0.2);
}
.expiring-countdown-card .label {
    font-size: 0.7rem;
    color: #a5b4fc;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.countdown-digits {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #38bdf8;
}

.broker-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}
.broker-header-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.broker-logo-box {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}
.broker-title-group h3 {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.broker-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
}
.broker-help-link {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    margin-top: 2px;
    display: inline-block;
}
.broker-help-link:hover { color: var(--accent-purple-light); }

/* ========================================================
   4. Trades & Performance View (trade.png)
   ======================================================== */
.trade-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}
.trade-summary-box {
    border-radius: 8px;
    padding: 1.25rem;
    border: 1px solid transparent;
}
.trade-summary-box.green { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.trade-summary-box.red { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.trade-summary-box.blue { background: #f0f9ff; border-color: #bae6fd; color: #075985; }
.trade-summary-box.yellow { background: #fefce8; border-color: #fef08a; color: #854d0e; }

.trade-summary-box .box-label {
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
}
.trade-summary-box .box-value {
    font-size: 1.35rem;
    font-weight: 800;
    font-family: var(--font-mono);
}
.trade-summary-box .box-percent {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    opacity: 0.8;
}

.trade-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.trade-filter-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.trade-filter-left select {
    width: 220px;
}
.trade-filter-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.date-filter-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.date-filter-item input[type="date"] {
    width: 140px;
    padding: 0.35rem 0.5rem;
    font-size: 0.82rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Modern Data Table */
.table-container {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.modern-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
    text-align: left;
}
.modern-table thead {
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}
.modern-table th {
    padding: 0.85rem 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    vertical-align: middle;
}
.modern-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    white-space: nowrap;
    vertical-align: middle;
}
.modern-table tbody tr:hover {
    background: #f8fafc;
}
.modern-table .mono {
    font-family: var(--font-mono);
}

/* Modals */
.modal,
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 1rem;
    box-sizing: border-box;
}
.modal-content {
    background: #ffffff;
    border-radius: 14px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    animation: modalPopIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalPopIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}
.modal-header {
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 10;
}
.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}
.modal-body {
    padding: 1.5rem;
}

/* Auth Center Screen */
.auth-container {
    height: 100vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #240a5e 0%, #110326 100%);
}
.auth-box-modern {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 430px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.auth-box-modern .brand-header {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-tabs-modern {
    display: flex;
    margin-bottom: 1.75rem;
    border-bottom: 2px solid #f1f5f9;
}
.auth-tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 0.65rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.auth-tab-btn.active {
    color: var(--accent-purple);
    border-bottom-color: var(--accent-purple);
    font-weight: 700;
}

/* ========================================================
   RESPONSIVE DESIGN (Desktops & Large Tablets < 1200px)
   ======================================================== */
@media (max-width: 1200px) {
    .stats-grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.15rem;
    }
    .strategies-grid-3 {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.15rem;
    }
}

/* ========================================================
   RESPONSIVE DESIGN (Tablets < 1024px)
   ======================================================== */
@media (max-width: 1024px) {
    .top-navbar {
        padding: 0 1.25rem;
    }
    .navbar-center-ticker {
        gap: 0.5rem;
    }
    .ticker-pill {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }
    .main-content {
        padding: 1.5rem;
    }
    .trade-summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* ========================================================
   RESPONSIVE DESIGN (Mobile Devices < 768px)
   ======================================================== */
@media (max-width: 768px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
    }

    .app-container {
        position: relative;
        height: 100vh;
        overflow: hidden;
    }

    /* Mobile Drawer Sidebar */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 275px;
        max-width: 82vw;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 35px rgba(0, 0, 0, 0.45);
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
    }
    .mobile-sidebar-close {
        display: flex;
    }
    .mobile-menu-btn {
        display: flex;
    }

    /* Top Navbar */
    .top-navbar {
        height: 58px;
        min-height: 58px;
        padding: 0 1rem;
    }
    .user-greeting {
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 160px;
    }
    .navbar-center-ticker {
        display: none; /* Hide ticker on mobile to prevent navbar crowding */
    }
    .navbar-right {
        gap: 0.5rem;
    }
    .btn-change-pwd {
        display: none; /* Available in Settings tab on mobile */
    }

    /* Main Content Area */
    .main-wrapper {
        width: 100vw;
        height: 100vh;
    }
    .main-content {
        padding: 1rem 0.85rem 2.5rem 0.85rem;
        -webkit-overflow-scrolling: touch;
    }

    .view-header {
        margin-bottom: 1.15rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .view-title {
        font-size: 1.2rem;
    }

    /* Dashboard Stats (Clean 2-Column on Mobile) */
    .stats-grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .stat-card-modern {
        padding: 0.85rem 0.75rem;
        gap: 0.75rem;
    }
    .stat-icon-box {
        width: 38px;
        height: 38px;
        font-size: 1.15rem;
        flex-shrink: 0;
    }
    .stat-details label {
        font-size: 0.7rem;
    }
    .stat-details .stat-number {
        font-size: 1.15rem;
    }

    /* Strategies Grid */
    .strategies-grid-3 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .strategy-card-header {
        padding: 0.85rem 1rem;
    }
    .strategy-card-body {
        padding: 1rem;
    }
    .strategy-meta-grid {
        padding: 0.65rem 0.75rem;
        gap: 0.35rem;
    }
    .strategy-meta-label {
        font-size: 0.62rem;
    }
    .strategy-meta-val {
        font-size: 0.82rem;
    }

    /* Manage Broker */
    .broker-container {
        width: 100%;
    }
    .broker-card {
        padding: 1.25rem 1rem;
    }
    .broker-top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.85rem;
        margin-bottom: 1.25rem;
    }
    .expiring-countdown-card {
        padding: 0.65rem 1rem;
    }
    .countdown-digits {
        font-size: 1rem;
        letter-spacing: 0.5px;
    }
    .broker-header-row {
        gap: 0.75rem;
        margin-bottom: 1.25rem;
        padding-bottom: 1rem;
    }
    .broker-logo-box {
        width: 42px;
        height: 42px;
    }

    /* Trades View */
    .trade-summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.65rem;
        margin-bottom: 1rem;
    }
    .trade-summary-box {
        padding: 0.85rem;
    }
    .trade-summary-box .box-label {
        font-size: 0.72rem;
        margin-bottom: 0.2rem;
    }
    .trade-summary-box .box-value {
        font-size: 1.15rem;
    }
    .trade-summary-box .box-percent {
        font-size: 0.68rem;
    }

    .trade-filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }
    .trade-filter-left {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    .trade-filter-left select {
        width: 100% !important;
    }
    .btn-export {
        width: 100%;
        padding: 0.55rem;
    }
    .trade-filter-right {
        width: 100%;
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
    }
    .date-filter-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }
    .date-filter-item input[type="date"] {
        width: 100% !important;
    }

    /* Table Container Touch Scroll */
    .table-container {
        border-radius: 8px;
        -webkit-overflow-scrolling: touch;
    }
    .modern-table th, .modern-table td {
        padding: 0.65rem 0.75rem;
        font-size: 0.78rem;
    }

    /* Settings Tab */
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Modals */
    .modal-content {
        width: calc(100% - 1.25rem);
        max-width: 100%;
        margin: 0.6rem;
        max-height: 92vh;
        border-radius: 12px;
    }
    .modal-header {
        padding: 1rem 1.15rem;
    }
    .modal-body {
        padding: 1.15rem;
    }
    .modal-body .flex.gap-2 {
        flex-wrap: wrap;
    }
    .modal-body .flex.gap-2 .input-group.flex-1 {
        min-width: 100%;
    }

    /* Signal Tab Responsive */
    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .view-header > div:last-child {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: flex-start;
    }
    .signal-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.65rem;
    }
    .signal-filter-row {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.5rem;
    }
    .filter-input-wrap {
        min-width: 100%;
        flex: 1 1 100%;
    }
    .filter-actions-wrap {
        grid-column: 1 / -1;
        margin-left: 0;
        width: 100%;
        display: flex;
        justify-content: stretch;
    }
    .filter-actions-wrap .btn {
        flex: 1;
        text-align: center;
        justify-content: center;
    }
    .signal-breakdowns-grid {
        grid-template-columns: 1fr;
    }
    .table-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .table-toolbar-right {
        width: 100%;
        justify-content: space-between;
    }

    /* Auth Screen */
    .auth-box-modern {
        padding: 1.75rem 1.25rem;
        margin: 1rem;
        max-width: calc(100% - 2rem);
        border-radius: 14px;
    }

    /* iOS Safari zoom prevention on focus */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    select {
        font-size: 16px;
    }
}

/* ========================================================
   RESPONSIVE DESIGN (Extra Small Devices < 480px)
   ======================================================== */
@media (max-width: 480px) {
    .main-content {
        padding: 0.75rem 0.5rem 2rem 0.5rem;
    }

    .stats-grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    .stat-card-modern {
        padding: 0.65rem 0.5rem;
        gap: 0.5rem;
    }
    .stat-icon-box {
        width: 32px;
        height: 32px;
        font-size: 0.95rem;
        border-radius: 6px;
    }
    .stat-details label {
        font-size: 0.65rem;
    }
    .stat-details .stat-number {
        font-size: 1.05rem;
    }

    /* Strategy Card Footer 2x2 grid */
    .strategy-card-footer {
        grid-template-columns: repeat(2, 1fr);
    }
    .st-footer-tab {
        border-bottom: 1px solid var(--border-color);
        padding: 0.65rem 0.25rem;
    }
    .st-footer-tab:nth-child(2) {
        border-right: none;
    }

    .countdown-digits {
        font-size: 0.85rem;
        letter-spacing: 0;
    }

    .trade-summary-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }
    .trade-summary-box {
        padding: 0.6rem 0.5rem;
    }
    .trade-summary-box .box-value {
        font-size: 1rem;
    }

    .trade-filter-right {
        flex-direction: column;
    }
    .date-filter-item {
        width: 100%;
    }
    .signal-kpi-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .signal-filter-row {
        grid-template-columns: 1fr;
    }
    .candle-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================================
   Trade Table Tracking & Target / SL Styles
   ======================================================== */
.badge-gray {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.tracking-pill-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    min-width: 170px;
}

.track-mini-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    white-space: nowrap;
}

.track-progress-bar {
    width: 100%;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
}

.track-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #0ea5e9;
    box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.7);
    animation: livePulse 1.6s infinite cubic-bezier(0.66, 0, 0, 1);
    vertical-align: middle;
    margin-left: 3px;
}

@keyframes livePulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(14, 165, 233, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(14, 165, 233, 0);
    }
}

/* Direction & Range Visual Widget */
.trade-visual-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 10px;
    min-width: 230px;
}

.visual-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 0.72rem;
}

.direction-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 700;
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
}
.direction-badge.dir-target {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}
.direction-badge.dir-sl {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.direction-badge.dir-neutral {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.hit-check-text {
    font-size: 0.68rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Range Bar: SL (left) -> Entry (center) -> Target (right) */
.range-track-container {
    position: relative;
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    margin: 6px 0 3px 0;
}

.range-track-sl-zone {
    position: absolute;
    left: 0;
    width: 50%;
    height: 100%;
    background: #fecaca;
    border-top-left-radius: 3px;
    border-bottom-left-radius: 3px;
}

.range-track-tgt-zone {
    position: absolute;
    left: 50%;
    width: 50%;
    height: 100%;
    background: #bbf7d0;
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
}

.range-track-center-marker {
    position: absolute;
    left: 50%;
    top: -2px;
    width: 2px;
    height: 10px;
    background: #475569;
    transform: translateX(-50%);
    z-index: 2;
}

.range-track-pointer {
    position: absolute;
    top: -4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    z-index: 3;
    transition: left 0.4s ease;
}

.range-track-pointer.pointer-profit {
    background: #16a34a;
    border: 2px solid #ffffff;
}

.range-track-pointer.pointer-loss {
    background: #dc2626;
    border: 2px solid #ffffff;
}

.range-track-pointer.pointer-entry {
    background: #0284c7;
    border: 2px solid #ffffff;
}

.range-track-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ========================================================
   SIGNAL MANAGEMENT & GROUP ARCHITECTURE STYLES
   ======================================================== */

.signal-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.signal-kpi-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius:10px;
    padding: 1rem 1.25rem;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s, box-shadow 0.15s;
}

.signal-kpi-card.cursor-pointer:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.signal-kpi-card .kpi-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
}

.signal-kpi-card .kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.signal-kpi-card .kpi-scope {
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 0.3rem;
}

.signal-filter-container {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.signal-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: flex-end;
}

.filter-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1 1 125px;
    min-width: 120px;
}

.filter-input-wrap label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.signal-search-input {
    width: 100%;
    min-width: 140px;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    box-sizing: border-box;
}

.signal-select {
    width: 100%;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.82rem;
    background: #ffffff;
    min-width: 110px;
    box-sizing: border-box;
    cursor: pointer;
}

.filter-actions-wrap {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-left: auto;
    flex-wrap: nowrap;
}

.sound-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: 1px solid transparent;
    user-select: none;
    line-height: 1.2;
}

.sound-toggle-btn.sound-on {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

.sound-toggle-btn.sound-on:hover {
    background: #d1fae5;
    border-color: #6ee7b7;
}

.sound-toggle-btn.sound-off {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #64748b;
}

.sound-toggle-btn.sound-off:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
    color: #475569;
}

.filter-chips-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-color);
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

.filter-chip-remove {
    cursor: pointer;
    font-weight: bold;
    color: #60a5fa;
}

.filter-chip-remove:hover {
    color: #1e3a8a;
}

.filter-builder-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-top: 1rem;
    box-sizing: border-box;
}

.filter-rules-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    margin-bottom: 0.75rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
}

.filter-rule-item {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) 36px;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
    min-width: 420px;
    box-sizing: border-box;
    white-space: nowrap;
}

.filter-rule-item .rule-field,
.filter-rule-item .rule-operator,
.filter-rule-item .rule-value {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    padding: 0 0.65rem !important;
    font-size: 0.82rem !important;
    line-height: normal !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
    background-color: #ffffff !important;
    color: var(--text-primary) !important;
    box-sizing: border-box !important;
    text-overflow: ellipsis;
    outline: none;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.filter-rule-item .rule-field:focus,
.filter-rule-item .rule-operator:focus,
.filter-rule-item .rule-value:focus {
    border-color: var(--accent-purple) !important;
    box-shadow: 0 0 0 2px rgba(59, 7, 100, 0.15);
}

.filter-rule-item .filter-rule-remove,
.filter-rule-item button {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    font-size: 0.95rem !important;
    line-height: 1 !important;
    border-radius: 6px !important;
    border: 1px solid transparent !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    background: transparent !important;
    color: var(--loss) !important;
    transition: all 0.15s ease-in-out !important;
    flex-shrink: 0 !important;
}

.filter-rule-item .filter-rule-remove:hover,
.filter-rule-item button:hover {
    background: var(--loss-bg) !important;
    border-color: #fca5a5 !important;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.table-toolbar-left, .table-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sortable-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.sortable-header:hover {
    background: #f1f5f9;
}

.sort-indicator {
    display: inline-block;
    margin-left: 0.25rem;
    font-size: 0.6rem;
    color: #94a3b8;
}

.sort-indicator.active {
    color: #0284c7;
    font-weight: bold;
}

.column-dropdown {
    position: relative;
    display: inline-block;
}

.column-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    min-width: 200px;
    max-height: 320px;
    overflow-y: auto;
    display: none;
}

.column-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    padding: 0.25rem 0;
    cursor: pointer;
}

.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
    padding: 0.25rem 0;
}

.breadcrumb-back-btn, .breadcrumb-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    outline: none;
}

.breadcrumb-back-btn:hover, .breadcrumb-link:hover {
    background: #f8fafc;
    border-color: var(--accent-purple, #3b0764);
    color: var(--accent-purple, #3b0764);
    transform: translateX(-3px);
    box-shadow: 0 3px 8px rgba(59, 7, 100, 0.1);
    text-decoration: none;
}

.breadcrumb-back-btn svg {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.breadcrumb-back-btn:hover svg {
    transform: translateX(-2px);
}

.breadcrumb-separator {
    color: #94a3b8;
    font-weight: 400;
    user-select: none;
    font-size: 0.95rem;
}

.breadcrumb-current-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.breadcrumb-id-badge {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.badge-empty-candle {
    background: #f1f5f9;
    color: #64748b;
    border: 1px dashed #cbd5e1;
    font-size: 0.72rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-mono);
}

.candle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.candle-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.75rem;
}

.candle-card-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.candle-prop-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    padding: 0.15rem 0;
    font-family: var(--font-mono);
}

.raw-json-viewer {
    background: #0f172a;
    color: #e2e8f0;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    max-height: 380px;
    white-space: pre-wrap;
    word-break: break-all;
    position: relative;
}

.toast-feedback {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1e293b;
    color: #ffffff;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.85rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 9999;
    display: none;
    animation: fadeIn 0.2s ease-in-out;
}

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

/* ========================================================
   RESPONSIVE GRID & MODERN CARDS FOR GROUPS & WEBHOOKS
   ======================================================== */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

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

.group-card, .webhook-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.02);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
}

.group-card:hover, .webhook-card:hover {
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 4px 10px -3px rgba(15, 23, 42, 0.04);
}

.card-header-bar {
    padding: 1.1rem 1.25rem 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.card-identity-box {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
    min-width: 0;
}

.card-badge-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.card-item-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.card-body-content {
    padding: 1.1rem 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.card-item-desc {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.4em;
}

.card-tags-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.card-strategy-pill {
    background: #f1f5f9;
    color: #334155;
    font-size: 0.74rem;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.card-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
}

.card-metrics-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
}

.card-metric-cell {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.card-metric-cell.cell-wide {
    grid-column: 1 / -1;
    border-top: 1px dashed var(--border-color);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
}

.card-metric-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.card-metric-value {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-metric-timestamp {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-split-val {
    display: flex;
    gap: 0.3rem;
    align-items: center;
    font-size: 0.82rem;
}

.card-footer-actions {
    padding: 0.75rem 0.85rem;
    background: #fafafa;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
}

/* Group Card Footer: All 4 action buttons strictly in a single horizontal line */
.group-card .card-footer-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap !important;
    padding: 0.75rem 0.85rem;
}

.group-card .card-footer-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    height: 32px;
    padding: 0.3rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    border-radius: 6px;
    box-sizing: border-box;
}

.group-card .card-footer-actions .btn-secondary {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    transition: all 0.15s ease-in-out;
}

.group-card .card-footer-actions .btn-secondary:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Edit Group Button: clearly visible, sharp border, proper contrast */
.btn-edit-group {
    background: #ffffff !important;
    border: 1.5px solid #94a3b8 !important;
    color: #1e293b !important;
    font-weight: 600 !important;
    transition: all 0.15s ease-in-out;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-edit-group:hover {
    background: #f1f5f9 !important;
    border-color: #475569 !important;
    color: #0f172a !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.btn-edit-group:active {
    background: #e2e8f0 !important;
}

/* Webhook Card Footer */
.webhook-card .card-footer-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: nowrap !important;
    padding: 0.75rem 0.85rem;
}

.webhook-card .card-footer-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    height: 32px;
    padding: 0.35rem 0.4rem;
    font-size: 0.74rem;
    font-weight: 600;
    white-space: nowrap;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    border-radius: 6px;
    box-sizing: border-box;
}

.webhook-card .card-footer-actions .btn-secondary {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    transition: all 0.15s ease-in-out;
}

.webhook-card .card-footer-actions .btn-secondary:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

@media (max-width: 640px) {
    .group-card .card-footer-actions {
        gap: 0.25rem;
        padding: 0.65rem 0.5rem;
    }
    .group-card .card-footer-actions .btn {
        font-size: 0.68rem;
        padding: 0.25rem 0.15rem;
    }
}

.cards-empty-state {
    grid-column: 1 / -1;
    background: #ffffff;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 3.5rem 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.cards-empty-icon {
    font-size: 2.2rem;
    opacity: 0.7;
}

.cards-empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.cards-empty-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 420px;
}




