:root {
    --bg-dark: #09090b;
    --sidebar-bg: #111114;
    --card-bg: rgba(24, 24, 27, 0.7);
    --border: rgba(255, 255, 255, 0.08);
    --text-main: #fafafa;
    --text-dim: #a1a1aa;
    --accent-blue: #3b82f6;
    --bull: #22c55e;
    --bear: #ef4444;
    --glass: rgba(255, 255, 255, 0.02);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Loading Overlay */
#loadingOverlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(9, 9, 11, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    transition: opacity 0.4s ease;
}

#loadingOverlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-ring {
    width: 56px;
    height: 56px;
    border: 3px solid rgba(59, 130, 246, 0.15);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.3px;
}

.loader-sub {
    font-size: 13px;
    color: var(--text-dim);
    text-align: center;
    max-width: 260px;
    line-height: 1.6;
}

.loader-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent-blue);
    border-radius: 50%;
    margin: 0 3px;
    animation: blink 1.2s infinite;
}

.loader-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loader-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0%, 80%, 100% {
        opacity: 0.15
    }
    40% {
        opacity: 1
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-size: 15px;
    background-image:
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(34, 197, 94, 0.05) 0px, transparent 50%);
}

/* Sidebar */
.sidebar {
    width: 72px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    transition: width 0.3s ease;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100vh;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-blue) transparent;
}

.sidebar:hover {
    width: 240px;
    align-items: flex-start;
}

.logo {
    margin-bottom: 40px;
    padding: 0 24px;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo span {
    display: none;
    font-weight: 800;
    font-size: 20px;
}

.sidebar:hover .logo span {
    display: block;
}

.nav-list {
    list-style: none;
    width: 100%;
}

.nav-item {
    height: 56px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-dim);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    border-left: 3px solid transparent;
}

.nav-item span {
    display: none;
    white-space: nowrap;
    font-weight: 500;
}

.sidebar:hover .nav-item span {
    display: block;
}

.nav-item:hover,
.nav-item.active {
    color: var(--text-main);
    background: var(--glass);
    border-left-color: var(--accent-blue);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px 32px;
}

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

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.refresh-setting {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    cursor: pointer;
    outline: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.refresh-setting select {
    background: transparent;
    color: var(--text-main);
    border: none;
    outline: none;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    cursor: pointer;
}

.refresh-setting select option {
    background: var(--bg-dark);
}

.header h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 24px;
}

@media (min-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .full-width {
        grid-column: 1 / -1;
    }
}

.action-btn {
    cursor: pointer;
    color: var(--text-dim);
    transition: all 0.2s;
    opacity: 0.6;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    color: var(--accent-blue);
    opacity: 1;
    transform: scale(1.1);
}

.fav-btn {
    cursor: pointer;
    color: var(--text-dim);
    transition: var(--transition);
    width: 11px;
    height: 11px;
}

.fav-btn.active {
    color: var(--accent-blue);
}

.action-btn.send:hover {
    color: #0088cc;
}

.action-btn.copy:hover {
    color: #f59e0b;
}

@media (max-width: 992px) {
    body {
        flex-direction: column;
        overflow: auto !important;
        height: auto !important;
    }

    .sidebar {
        width: 100% !important;
        height: 65px !important;
        flex-direction: row !important;
        justify-content: space-around !important;
        align-items: center !important;
        padding: 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        border-right: none !important;
        border-top: 1px solid var(--border) !important;
        background: var(--sidebar-bg) !important;
        z-index: 9999 !important;
    }

    .sidebar:hover {
        width: 100% !important;
        align-items: center !important;
    }

    .sidebar .logo {
        display: none !important;
    }

    .nav-list {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-around !important;
        align-items: center !important;
        height: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .nav-item {
        padding: 0 !important;
        height: 100% !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 4px !important;
        flex: 1 !important;
        border-left: none !important;
        border-bottom: 3px solid transparent !important;
    }

    .nav-item.active i {
        color: var(--accent-blue) !important;
    }

    .nav-item span {
        display: none !important;
    }

    .main-content {
        padding: 8px 4px;
        margin-bottom: 60px;
        overflow: visible !important;
        height: auto !important;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .header-actions {
        width: 100%;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 6px;
        overflow-x: auto;
        padding-bottom: 4px; /* for scrollbar spacing */
        /* Hide scrollbar */
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .header-actions::-webkit-scrollbar {
        display: none;
    }

    .header-actions > * {
        flex: 0 0 auto;
    }

    /* Hide telegram toggle on mobile as requested */
    #telegramToggle {
        display: none !important;
    }

    .header-actions button,
    .header-actions .button,
    .header-actions .refresh-setting {
        justify-content: center;
        white-space: nowrap;
        padding: 6px 12px !important;
        font-size: 13px !important;
        height: 34px !important;
        min-height: 34px !important;
        border-radius: 8px !important;
    }

    .header-actions svg {
        width: 14px !important;
        height: 14px !important;
    }

    .search-box {
        width: auto;
        flex: 0 0 140px;
    }

    .search-box input {
        width: 100%;
        padding: 6px 12px 6px 32px !important;
        font-size: 13px !important;
        height: 34px !important;
    }

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

    .dashboard-grid {
        gap: 16px;
    }

    .trade-table-container {
        margin: 0 -16px;
        width: calc(100% + 32px);
        padding: 0 16px;
    }

    .trade-table th,
    .trade-table td {
        padding: 6px 4px;
        font-size: 10px;
    }

    .widget {
        padding: 12px;
        gap: 12px;
        border-radius: 12px;
    }

    .symbol-btn, .symbol-page-number {
       min-height: 28px !important;
    padding: 0 10px !important;
    font-size: 11px !important;
    border-radius: 6px !important;
    border: none;
    margin: 2px;
    }
#symbolMasterPage {
    display: none;
}
    .symbol-meta {
        padding: 4px 6px;
        font-size: 10px;
        display:   none;
    }

.sd-modal {
    padding: 5px !important;
    border-radius: 5px !important;
}
.sd-info-card {
    padding: 0px !important;
 }
 .sd-financials-table td {
    padding: 8px 5px !important;
    font-size: 10px !important;
 }
 .value {
    font-size: 25px !important;
 }
    .symbol-pager {
        gap: 4px;
        justify-content: space-between;
    }
    .signal-card-wrapper {
    justify-content: left !important;
    padding: 1px !important;
    width: 303px !important; 
    font-size: 14px !important;
}


.data-card{
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .signal-split {
        grid-template-columns: 1fr;
    }

    .symbol-controls {
        align-items: stretch;
        flex-direction: column;
    }

    .symbol-filter {
        min-width: 0;
    }
}

/* Widgets */
.widget {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.widget-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 16px;
    color: var(--text-main);
}

/* Sentiment Bar */
.sentiment-container {
    width: 100%;
    height: 6px;
    background: #27272a;
    border-radius: 10px;
    display: flex;
    overflow: hidden;
    margin: 4px 0;
}

.sentiment-up {
    background: var(--bull);
    height: 100%;
    transition: width 0.5s ease;
}

.sentiment-down {
    background: var(--bear);
    height: 100%;
    transition: width 0.5s ease;
}

.search-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box input {
    background: transparent;
    border: none;
    color: white;
    outline: none;
    font-size: 13px;
    width: 100px;
}

.symbol-footer {
    margin-top: 24px;
}

.symbol-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.symbol-filter {
    min-width: 260px;
    flex: 1;
}

.symbol-filter input {
    width: 100%;
}

.symbol-pager {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.symbol-btn {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    min-height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.symbol-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.symbol-meta {
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 700;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    white-space: nowrap;
}

/* Table Styles */
.trade-table-container {
    width: 100%;
    overflow-x: auto;
}

.trade-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.trade-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-dim);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.trade-table th:hover {
    color: var(--text-main);
}

.trade-table th.sort-asc::after {
    content: ' ▲';
    color: var(--accent-blue);
    font-size: 9px;
}

.trade-table th.sort-desc::after {
    content: ' ▼';
    color: var(--accent-blue);
    font-size: 9px;
}

.trade-table th.sort-asc,
.trade-table th.sort-desc {
    color: var(--text-main);
}

.trade-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 13px;
}

.row-buy {
    background: rgba(34, 197, 94, 0.05);
}

.row-sell {
    background: rgba(239, 68, 68, 0.05);
}

.signal-split {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.signal-box {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.signal-box.bullish {
    border-color: rgba(34, 197, 94, 0.22);
    background: rgba(34, 197, 94, 0.045);
}

.signal-box.bearish {
    border-color: rgba(239, 68, 68, 0.22);
    background: rgba(239, 68, 68, 0.045);
}

.signal-box-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.signal-box-head .up,
.signal-box-head .down {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.signal-count {
    color: var(--text-dim);
    font-size: 10px;
}

.stock-up {
    color: var(--bull);
}

.stock-down {
    color: var(--bear);
}

.stock-row-up {
    background: rgba(34, 197, 94, 0.055);
}

.stock-row-down {
    background: rgba(239, 68, 68, 0.055);
}

.symbol-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.signal-pill {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.pill-bull {
    background: rgba(34, 197, 94, 0.15);
    color: var(--bull);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.pill-bear {
    background: rgba(239, 68, 68, 0.15);
    color: var(--bear);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.fav-btn {
    color: var(--text-dim);
    cursor: pointer;
    transition: var(--transition);
}

.fav-btn.active {
    color: #3b82f6;
    fill: #3b82f6;
}

.percent-box {
    font-weight: 700;
    font-size: 12px;
}

.up {
    color: var(--bull);
}

.down {
    color: var(--bear);
}

.badge-live {
    background: #ef4444;
    color: white;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 900;
    text-transform: uppercase;
}

.price-val {
    font-weight: 600;
    color: var(--text-main);
}

.vol-val {
    color: var(--text-dim);
    font-size: 11px;
}

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-blue);
    border-radius: 10px;
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   PAGE LAYOUT WRAPPER
   ============================================ */
.page-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.page-subtitle {
    color: var(--text-dim);
    font-size: 13px;
    margin-top: 4px;
}

/* ============================================
   SCAN STATUS INDICATOR (Nifty50 / TradeFinder)
   ============================================ */
.scan-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 3px 10px;
    border-radius: 100px;
}

.scan-status .dot {
    width: 6px;
    height: 6px;
    background: var(--accent-blue);
    border-radius: 50%;
    animation: pulse 1s infinite;
}

.scan-status.done {
    color: var(--bull);
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.2);
}

.scan-status.done .dot {
    background: var(--bull);
    animation: none;
}

/* ============================================
   SYMBOL ICON (Starred Stocks)
   ============================================ */
.symbol-icon {
    width: 40px;
    height: 40px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: var(--accent-blue);
    flex-shrink: 0;
}

/* ============================================
   LOG VIEWER (Error Logs page)
   ============================================ */
.log-container {
    background: #000;
    border-radius: 12px;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.log-line {
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #d1d5db;
    margin-bottom: 4px;
    word-wrap: break-word;
    padding: 4px 8px;
    border-radius: 4px;
}

.log-line:hover { background: rgba(255, 255, 255, 0.05); }
.log-error { color: #ef4444; font-weight: 600; }
.log-critical { color: #f87171; background: rgba(239, 68, 68, 0.1); }
.log-warning { color: #f59e0b; }
.log-info { color: #3b82f6; }
.log-debug { color: #9ca0aa; }
.log-timestamp { color: #6b7280; margin-right: 12px; user-select: none; }

/* ============================================
   CACHE / STATS GRID (System Cache page)
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 12px;
}

.stat-card .label {
    display: block;
    color: var(--text-dim);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stat-card .value {
    font-size: 20px;
    font-weight: 700;
}

.file-name { font-weight: 600; color: var(--accent-blue); }
.file-size, .file-date { color: var(--text-dim); font-size: 13px; }

/* ============================================
   SYSTEM BUTTONS (Cache, Logs pages)
   ============================================ */
.btn {
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
}

.btn-primary { background: var(--accent-blue); color: white; }
.btn-danger { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.2); color: var(--bear); }
.btn-default { background: var(--card-bg); border: 1px solid var(--border); color: var(--text-main); }
.btn:hover { opacity: 0.85; transform: translateY(-1px); }

/* ============================================
   NIFTY50 / SIGNAL SPLIT (two-column crossover)
   ============================================ */
@media (min-width: 993px) {
    .signal-split {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================
   RESPONSIVE OVERRIDES FOR NEW LAYOUT
   ============================================ */
@media (max-width: 992px) {
    .page-header { padding: 16px; flex-direction: column; align-items: flex-start; }
    .page-title { font-size: 20px; }
    .stats-grid { grid-template-columns: 1fr; }
    .main-content { padding: 10px; margin-bottom: 65px; }
}

/* ============================================
   LOADING OVERLAY
   ============================================ */
#loadingOverlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(9, 9, 11, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    transition: opacity 0.4s ease;
}

#loadingOverlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-ring {
    width: 56px;
    height: 56px;
    border: 3px solid rgba(59, 130, 246, 0.15);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.3px;
}

.loader-sub {
    font-size: 13px;
    color: var(--text-dim);
    text-align: center;
    max-width: 260px;
    line-height: 1.6;
}

.loader-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent-blue);
    border-radius: 50%;
    margin: 0 3px;
    animation: blink 1.2s infinite;
}

.loader-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loader-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0%,
    80%,
    100% {
        opacity: 0.15
    }

    40% {
        opacity: 1
    }
}
@media (max-width:768px){

    .trade-table-container{
        overflow-x:auto !important;
        overflow-y:hidden !important;
        width:350px !important;
        display:block !important;
    }

    .trade-table{
        width:max-content !important;
        min-width:max-content !important;
    }

    .trade-table th,
    .trade-table td{
        white-space:nowrap !important;
        padding:12px 15px !important;
    }

}