/* =============================================================
   Stock Screener — global stylesheet
   Theme tokens live in :root; components are grouped by section.
   ============================================================= */

:root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-hover: rgba(255, 255, 255, 0.03);
    --border: #30363d;
    --text: #c9d1d9;
    --text-muted: #8b949e;
    --heading: #ffffff;
    --accent: #00d2ff;
    --accent-soft: rgba(0, 210, 255, 0.1);
    --accent-glow: rgba(0, 210, 255, 0.4);
    --positive: #3fb950;
    --negative: #f85149;
    --radius: 0.5rem;
    --radius-sm: 0.375rem;
    --sidebar-width: 13.75rem;
    --sidebar-width-collapsed: 5rem;
    --font-sans: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-size: 100%;
}

a { color: var(--accent); }

/* The [hidden] attribute must win over component display rules
   (e.g. .empty-state { display: flex }), otherwise hidden elements show. */
[hidden] { display: none !important; }

.muted { color: var(--text-muted); }
.muted.pad { padding: 1.25rem; }
.capitalize { text-transform: capitalize; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.positive-bg { background-color: var(--positive); }
.negative-bg { background-color: var(--negative); }

/* =========================================
   SIDEBAR
   ========================================= */
.sidebar {
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: 0.25rem 0 1.5rem rgba(0, 0, 0, 0.5);
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    z-index: 1000;
}

.sidebar .logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--heading);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 2.5rem;
}

.sidebar .logo i {
    color: var(--accent);
    text-shadow: 0 0 1rem rgba(0, 210, 255, 0.8);
}

.sidebar ul {
    list-style-type: none;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.sidebar ul a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-left: 3px solid transparent;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.sidebar ul a i {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: left;
    transition: all 0.3s ease;
}

.sidebar ul a span { transition: transform 0.3s ease; }

.sidebar ul a:hover,
.sidebar ul a.active {
    color: var(--heading);
    background: linear-gradient(90deg, var(--accent-soft) 0%, rgba(0, 210, 255, 0) 100%);
    border-left: 3px solid var(--accent);
}

.sidebar ul a:hover span,
.sidebar ul a:hover i { transform: translateX(0.35rem); }

.sidebar ul a:hover i,
.sidebar ul a.active i {
    color: var(--accent);
    text-shadow: 0 0 0.75rem rgba(0, 210, 255, 0.6);
}

.sidebar .bottom-section { margin-top: auto; width: 100%; }

.sidebar .divider {
    border: 0;
    height: 1px;
    background-color: var(--border);
    margin: 0 1.5rem 1rem 1.5rem;
}

.sidebar-note {
    color: var(--text-muted);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1.5rem;
}

/* =========================================
   MAIN CONTENT
   ========================================= */
.content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
}

.content-inner {
    padding: 2.5rem;
    animation: fadeUpIn 0.6s ease-out forwards;
}

@keyframes fadeUpIn {
    from { opacity: 0; transform: translateY(1rem); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.page-header h1 {
    font-size: 2rem;
    color: var(--heading);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
}

.breadcrumb { margin-bottom: 1.5rem; }

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s ease;
}

.breadcrumb a:hover { color: var(--accent); }

/* =========================================
   BUTTONS
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-primary:hover {
    background-color: var(--accent-soft);
    box-shadow: 0 0 0.5rem var(--accent-glow);
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    color: var(--heading);
    border-color: var(--text-muted);
}

.btn-ghost.active {
    color: var(--accent);
    border-color: var(--accent);
}

/* =========================================
   STAT CARDS (dashboard)
   ========================================= */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--heading);
}

.stat-sep { color: var(--text-muted); font-weight: 400; }

.stat-sub { font-size: 0.78rem; color: var(--text-muted); }

/* Health gauge inside a stat card */
.gauge-card { align-items: stretch; }

.gauge {
    position: relative;
    height: 5rem;
    margin-top: 0.25rem;
}

.gauge-center {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.1rem;
    text-align: center;
    font-size: 1.8rem;
    font-weight: 800;
}

/* Loading spinner */
.spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 0.3rem solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* =========================================
   GRID + WIDGETS
   ========================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
}

.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.widget {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.2);
}

.widget.standalone { margin-bottom: 2rem; }

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background-color: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius) var(--radius) 0 0;
}

.widget-header h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--heading);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.widget-body {
    padding: 1.25rem;
    flex-grow: 1;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.widget-body.no-pad { padding: 0; }

/* =========================================
   SECTOR PERFORMANCE BARS
   ========================================= */
.sector-bars { list-style: none; }

.sector-bars li {
    display: grid;
    grid-template-columns: 14rem 1fr 5rem;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
}

.sector-name { color: var(--text); font-size: 0.9rem; }
.sector-name em { color: var(--text-muted); font-style: normal; font-size: 0.8rem; }

.sector-track {
    height: 0.5rem;
    background-color: var(--bg);
    border-radius: 999px;
    overflow: hidden;
}

.sector-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    min-width: 2px;
}

.sector-value { text-align: right; font-weight: 600; font-size: 0.9rem; }

/* =========================================
   DATA TABLES
   ========================================= */
.table-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-scroll { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table th {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    background-color: rgba(255, 255, 255, 0.02);
    user-select: none;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table .num-col { text-align: right; }

.data-table tr.row-link { cursor: pointer; transition: background-color 0.15s ease; }
.data-table tr.row-link:hover { background-color: var(--surface-hover); }

.data-table .ticker {
    display: block;
    font-weight: 700;
    color: var(--heading);
}

.data-table .company-name {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table.compact th,
.data-table.compact td { padding: 0.6rem 1.25rem; }

.table-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2.5rem 1rem !important;
}

/* Sortable headers */
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--accent); }

th.sortable.sorted { color: var(--accent); }

th.sortable.sorted::after {
    content: " ▾";
    font-size: 0.7rem;
}

th.sortable.sorted[data-dir="asc"]::after { content: " ▴"; }

/* Watchlist stars */
.star-col { width: 2.5rem; }

.star-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.2s ease, transform 0.2s ease;
}

.star-btn:hover { color: var(--accent); transform: scale(1.15); }
.star-btn.active { color: #e3b341; }

/* Change badge + sector chip */
.change {
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.sector-chip {
    display: inline-block;
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.78rem;
    padding: 0.2rem 0.7rem;
}

/* Table footer: summary + pagination */
.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.9rem 1.25rem;
    border-top: 1px solid var(--border);
    background-color: rgba(255, 255, 255, 0.02);
}

.result-summary { color: var(--text-muted); font-size: 0.85rem; }

.pagination {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.pagination button {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    min-width: 2.1rem;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination button:hover:not(:disabled) {
    color: var(--accent);
    border-color: var(--accent);
}

.pagination button.active {
    background-color: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
    font-weight: 700;
}

.pagination button:disabled { opacity: 0.35; cursor: default; }

.pagination .ellipsis { color: var(--text-muted); padding: 0 0.25rem; }

/* =========================================
   FILTER BAR (screener)
   ========================================= */
.filter-bar {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 1.25rem;
    transition: all 0.3s ease;
}

.search-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0.5rem rgba(0, 210, 255, 0.2);
}

.search-bar i {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-right: 1rem;
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1rem;
    width: 100%;
    outline: none;
}

.filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}

.filter-field select {
    background-color: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
    min-width: 10rem;
}

.filter-field select:focus { border-color: var(--accent); }

/* =========================================
   STOCK DETAIL PAGE
   ========================================= */
.stock-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.stock-identity h1 {
    font-size: 1.75rem;
    color: var(--heading);
    margin-bottom: 0.4rem;
}

.ticker-tag {
    background-color: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 0.15rem 0.6rem;
    vertical-align: middle;
    margin-left: 0.5rem;
}

.stock-quote {
    display: flex;
    align-items: baseline;
    gap: 0.9rem;
    flex-wrap: wrap;
}

.quote-price {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--heading);
}

.quote-asof { color: var(--text-muted); font-size: 0.8rem; }

.stock-actions { display: flex; gap: 0.75rem; }

/* Range buttons above the price chart */
.range-buttons { display: flex; gap: 0.35rem; }

.range-buttons button {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.range-buttons button:hover { color: var(--accent); border-color: var(--accent); }

.range-buttons button.active {
    background-color: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
    font-weight: 700;
}

/* 52-week range indicator */
.range-52w { margin-top: 1.5rem; }

.range-52w-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.range-track {
    position: relative;
    height: 0.4rem;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--negative), #e3b341, var(--positive));
    opacity: 0.9;
}

.range-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 50%;
    background-color: var(--heading);
    border: 2px solid var(--bg);
    box-shadow: 0 0 0.4rem rgba(0, 0, 0, 0.6);
}

/* Company profile */
.business-summary {
    color: var(--text);
    line-height: 1.65;
    margin-bottom: 1.25rem;
}

.profile-facts {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 2rem;
}

.profile-facts li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.profile-facts a { text-decoration: none; }
.profile-facts a:hover { text-decoration: underline; }

/* News list */
.news-list { list-style: none; }

.news-list li {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.news-list li:last-child { border-bottom: none; }

.news-list a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: color 0.2s ease;
}

.news-list a:hover { color: var(--accent); }

.news-list small { color: var(--text-muted); font-size: 0.75rem; }

/* =========================================
   CHARTS + DATA LISTS (shared)
   ========================================= */
.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
}

.large-chart { height: 400px; }

.data-list { list-style: none; }

.data-list li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
    font-size: 0.92rem;
}

.data-list li:last-child { border-bottom: none; }

.data-list strong { color: var(--heading); text-align: right; }

/* =========================================
   PORTFOLIO ANALYTICS (seamless layout)
   ========================================= */
.kpi-group { display: flex; gap: 2.5rem; }

.kpi { display: flex; flex-direction: column; align-items: flex-end; }

.kpi-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.seamless-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 3rem 2rem;
}

.grid-section h2 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--heading);
    margin-bottom: 1.5rem;
}

.grid-section h3 {
    font-size: 1.1rem;
    color: var(--heading);
    margin-bottom: 1rem;
}

.section-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* =========================================
   EMPTY STATES
   ========================================= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
    padding: 5rem 1rem;
    color: var(--text-muted);
}

.empty-state i { font-size: 3rem; color: var(--border); }
.empty-state h2 { color: var(--heading); font-weight: 600; }

/* =========================================
   MODAL
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    padding: 1.5rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.5);
    transform: translateY(1rem);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-container { transform: translateY(0); }

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

.modal-header h3 { color: var(--heading); font-size: 1.25rem; }

#modalTickerDisplay { color: var(--accent); }

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-close:hover { color: var(--heading); }

.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label { color: var(--text-muted); font-size: 0.9rem; }

.form-group input {
    background-color: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus { border-color: var(--accent); }

::-webkit-calendar-picker-indicator { filter: invert(1); }

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
}

.input-with-icon input {
    width: 100%;
    padding-left: 2rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-cancel {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover { color: var(--heading); border-color: var(--text-muted); }

.btn-confirm {
    background-color: var(--accent);
    color: var(--bg);
    border: none;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-confirm:hover {
    background-color: #33dbff;
    box-shadow: 0 0 0.5rem var(--accent-glow);
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media screen and (max-width: 1024px) {
    .span-3, .span-4 { grid-column: span 6; }
    .span-8 { grid-column: span 12; }
    .seamless-grid .span-4,
    .seamless-grid .span-6 { grid-column: span 12; }
}

@media screen and (max-width: 768px) {
    .sidebar { width: var(--sidebar-width-collapsed); }

    .sidebar .logo span { display: none; }
    .sidebar .logo { margin-bottom: 2rem; }
    .sidebar .logo i { font-size: 1.5rem; margin: 0; }

    .sidebar ul a span { display: none; }

    .sidebar ul a {
        padding: 1rem 0;
        justify-content: center;
    }

    .sidebar ul a i {
        width: auto;
        text-align: center;
        font-size: 1.25rem;
    }

    .sidebar ul a:hover span,
    .sidebar ul a:hover i { transform: scale(1.1); }

    .sidebar-note span { display: none; }
    .sidebar-note { justify-content: center; padding: 0; }

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

    .content-inner { padding: 1.25rem; }

    .span-3, .span-4, .span-6, .span-8 { grid-column: span 12; }

    .page-header { align-items: flex-start; flex-direction: column; }
    .kpi-group { gap: 1.5rem; }
    .kpi { align-items: flex-start; }

    .sector-bars li { grid-template-columns: 8.5rem 1fr 4.5rem; gap: 0.6rem; }

    .filter-field { flex: 1 1 8rem; }
    .filter-field select { min-width: 0; width: 100%; }

    .stock-quote .quote-price { font-size: 1.8rem; }

    .table-footer { justify-content: center; }

    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
}

/* =========================================
   SIDEBAR USER BLOCK
   ========================================= */
.user-block {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0 1.25rem;
}

.user-avatar {
    flex-shrink: 0;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #3872ff);
    color: #06121a;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-meta { display: flex; flex-direction: column; overflow: hidden; }

.user-name {
    color: var(--heading);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role { color: var(--text-muted); font-size: 0.72rem; }

.logout-btn {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.logout-btn:hover { color: var(--negative); background-color: rgba(248, 81, 73, 0.08); }

@media screen and (max-width: 768px) {
    .user-meta, .logout-btn { display: none; }
    .user-block { justify-content: center; padding: 0; }
}

/* =========================================
   FLASH MESSAGES
   ========================================= */
.flash-stack {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.flash {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.8rem 1.1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 0.9rem;
    animation: fadeUpIn 0.4s ease-out;
}

.flash-error {
    background-color: rgba(248, 81, 73, 0.1);
    border-color: rgba(248, 81, 73, 0.4);
    color: #ffb1ab;
}

.flash-success {
    background-color: rgba(63, 185, 80, 0.1);
    border-color: rgba(63, 185, 80, 0.4);
    color: #a6e6ad;
}

/* =========================================
   AUTH PAGES (login / register)
   ========================================= */
.auth-body {
    min-height: 100vh;
    background:
        radial-gradient(60rem 60rem at 80% -10%, rgba(0, 210, 255, 0.08), transparent 60%),
        var(--bg);
}

.auth-shell {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    min-height: 100vh;
}

/* Brand panel */
.auth-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.75rem;
    background:
        linear-gradient(160deg, rgba(0, 210, 255, 0.14), rgba(56, 114, 255, 0.05) 45%, transparent),
        var(--surface);
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    color: var(--heading);
    text-decoration: none;
}

.auth-logo i { color: var(--accent); text-shadow: 0 0 1rem rgba(0, 210, 255, 0.8); }

.auth-brand-body { max-width: 30rem; }

.auth-brand-body h1 {
    font-size: 2.3rem;
    line-height: 1.2;
    color: var(--heading);
    margin-bottom: 1rem;
}

.auth-brand-body > p { color: var(--text-muted); font-size: 1rem; line-height: 1.6; }

.auth-features {
    list-style: none;
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-features li {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    color: var(--text);
    font-size: 0.95rem;
}

.auth-features i {
    color: var(--accent);
    width: 1.5rem;
    text-align: center;
    font-size: 1.05rem;
}

.auth-brand-foot { color: var(--text-muted); font-size: 0.8rem; }

/* Form panel */
.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
}

.auth-card { width: 100%; max-width: 24rem; }

.auth-title { font-size: 1.75rem; color: var(--heading); margin-bottom: 0.4rem; }
.auth-subtitle { color: var(--text-muted); margin-bottom: 2rem; }

.auth-form .form-group { margin-bottom: 1.1rem; }

.auth-form .input-with-icon input {
    width: 100%;
    background-color: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.8rem 0.8rem 0.8rem 2.4rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-form .input-with-icon input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.15);
}

.auth-form .input-with-icon i { left: 0.9rem; }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
    cursor: pointer;
}

.checkbox-row input { accent-color: var(--accent); width: 1rem; height: 1rem; }

.auth-submit {
    width: 100%;
    padding: 0.8rem;
    font-size: 0.95rem;
}

.auth-switch {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-switch a { font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* Two-column name row */
.form-row { display: flex; gap: 0.9rem; }
.form-row .form-group { flex: 1; }

/* Label + forgot-password link on one line */
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.forgot-link { font-size: 0.82rem; text-decoration: none; }
.forgot-link:hover { text-decoration: underline; }

/* CAPTCHA */
.captcha-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; }

.captcha-img {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--bg);
}

.captcha-refresh {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 2.4rem;
    height: 2.4rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.captcha-refresh:hover { color: var(--accent); border-color: var(--accent); }

/* "or" divider */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.auth-divider::before, .auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Google button */
.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.75rem;
    background: #ffffff;
    color: #1f2328;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
    transition: filter 0.2s ease;
}

.google-btn:hover { filter: brightness(0.94); }

/* Verification / info pages */
.auth-icon-badge {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 1.25rem;
}

.auth-note {
    display: flex;
    gap: 0.6rem;
    background: rgba(139, 148, 158, 0.08);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.auth-note i { color: var(--accent); margin-top: 0.15rem; }
.auth-note code { background: var(--bg); padding: 0.05rem 0.3rem; border-radius: 3px; }

@media screen and (max-width: 480px) {
    .form-row { flex-direction: column; gap: 0; }
}

/* =========================================
   AVATARS
   ========================================= */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), #3872ff);
    color: #06121a;
    font-weight: 800;
    text-transform: uppercase;
}

.avatar-sm { width: 2.1rem; height: 2.1rem; font-size: 0.85rem; }
.avatar-md { width: 2.8rem; height: 2.8rem; font-size: 1rem; }
.avatar-lg { width: 5rem; height: 5rem; font-size: 1.8rem; }

/* =========================================
   TOP BAR
   ========================================= */
.topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: 3.75rem;
    padding: 0 1.5rem;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.topbar-right { display: flex; align-items: center; gap: 0.5rem; }

.topbar-icon {
    position: relative;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.15rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.topbar-icon:hover:not(:disabled) { color: var(--accent); background: var(--surface-hover); }
.topbar-icon:disabled { opacity: 0.5; cursor: default; }

/* User menu */
.user-menu { position: relative; }

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.3rem 0.7rem 0.3rem 0.3rem;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-menu-trigger:hover { background: var(--surface); border-color: var(--border); }
.user-menu-name { font-size: 0.9rem; font-weight: 600; }
.user-menu-trigger .fa-chevron-down { font-size: 0.7rem; color: var(--text-muted); }

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 15rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.5);
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.4rem);
    transition: all 0.18s ease;
}

.user-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }

.user-dropdown-head {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.4rem;
}

.dropdown-identity { overflow: hidden; }
.dropdown-name { color: var(--heading); font-weight: 600; font-size: 0.92rem; }
.dropdown-email {
    color: var(--text-muted); font-size: 0.78rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s ease;
}

.user-dropdown a:hover { background: var(--surface-hover); }
.user-dropdown a i { width: 1.1rem; text-align: center; color: var(--text-muted); }
.user-dropdown a.danger { color: var(--negative); }
.user-dropdown a.danger i { color: var(--negative); }
.user-dropdown hr { border: 0; border-top: 1px solid var(--border); margin: 0.4rem 0; }

/* =========================================
   NOTIFICATIONS (bell + dropdown + list)
   ========================================= */
.notif-menu { position: relative; }

.notif-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.25rem;
    background: var(--negative);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1.05rem;
    text-align: center;
    border-radius: 999px;
    border: 2px solid var(--bg);
}

.topbar-icon.has-unread { color: var(--heading); }

.notif-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 22rem;
    max-width: calc(100vw - 2rem);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.4rem);
    transition: all 0.18s ease;
    z-index: 950;
}

.notif-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }

.notif-dropdown-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--heading);
    font-size: 0.92rem;
}

.notif-mark-all {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.8rem;
    cursor: pointer;
}
.notif-mark-all:hover { text-decoration: underline; }

.notif-list { max-height: 24rem; overflow-y: auto; }

.notif-viewall {
    display: block;
    text-align: center;
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
}
.notif-viewall:hover { background: var(--surface-hover); }

/* Notification item (shared by dropdown + full page) */
.notif-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    position: relative;
    transition: background 0.15s ease;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-hover); }
.notif-item.unread { background: rgba(0, 210, 255, 0.05); }
.notif-item.unread::before {
    content: "";
    position: absolute;
    left: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: var(--accent);
}

.notif-icon {
    flex-shrink: 0;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    background: var(--bg);
    color: var(--text-muted);
}
.notif-icon.cat-news { background: rgba(0, 210, 255, 0.12); color: var(--accent); }
.notif-icon.cat-watchlist { background: rgba(227, 179, 65, 0.14); color: var(--gold, #e3b341); }
.notif-icon.cat-support { background: rgba(141, 73, 255, 0.14); color: #a371f7; }
.notif-icon.cat-features { background: rgba(63, 185, 80, 0.14); color: var(--positive); }
.notif-icon.cat-system { background: rgba(139, 148, 158, 0.14); color: var(--text-muted); }

.notif-content { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; flex: 1; }
.notif-title { color: var(--heading); font-size: 0.88rem; font-weight: 600; }
.notif-body { color: var(--text-muted); font-size: 0.82rem; line-height: 1.45; }
.notif-time { color: var(--text-muted); font-size: 0.72rem; margin-top: 0.1rem; }

.notif-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem;
    border-radius: var(--radius-sm);
    opacity: 0.6;
    transition: all 0.15s ease;
}
.notif-dismiss:hover { color: var(--negative); opacity: 1; }

.notif-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); font-size: 0.88rem; }

/* Full-page list reuses .notif-item */
.notif-page-list .notif-item { padding: 1rem 1.25rem; }

/* Sidebar user block as a link */
.sidebar a.user-block { text-decoration: none; border: 0; }
.sidebar a.user-block:hover { background: none; }
.sidebar a.user-block:hover .user-name { color: var(--accent); }

/* =========================================
   SETTINGS / ACCOUNT PAGE
   ========================================= */
.settings-layout {
    display: grid;
    grid-template-columns: 13rem 1fr;
    gap: 2rem;
    align-items: start;
}

.settings-nav {
    position: sticky;
    top: 5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.settings-nav a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.settings-nav a:hover { background: var(--surface); color: var(--heading); }
.settings-nav a i { width: 1.1rem; text-align: center; }

.settings-main { display: flex; flex-direction: column; gap: 1.5rem; }

.settings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    scroll-margin-top: 5rem;
}

.settings-card h2 { color: var(--heading); font-size: 1.2rem; margin-bottom: 0.35rem; }
.settings-help { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.5rem; }

.settings-form .form-group { margin-bottom: 1.1rem; }

.settings-form label { display: block; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.4rem; }

.settings-form input[type="text"],
.settings-form input[type="email"],
.settings-form input[type="password"],
.settings-form select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.65rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.2s;
}

.settings-form textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.65rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: inherit;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s;
}

.settings-form input:focus, .settings-form select:focus,
.settings-form textarea:focus { border-color: var(--accent); }

.settings-actions { margin-top: 1.25rem; }

/* Avatar editor */
.avatar-editor { display: flex; align-items: center; gap: 1.25rem; margin-bottom: 1.5rem; }
.avatar-editor-controls { display: flex; flex-direction: column; gap: 0.5rem; }
.file-btn { cursor: pointer; }
.file-name { color: var(--text-muted); font-size: 0.8rem; }

.inline-form { margin-top: 0.75rem; }
.link-danger {
    background: none; border: none; color: var(--negative);
    font-size: 0.85rem; cursor: pointer; padding: 0; text-decoration: underline;
}

.inline-note {
    display: flex; gap: 0.6rem; align-items: center;
    background: var(--accent-soft); border: 1px solid var(--accent);
    color: var(--text); border-radius: var(--radius-sm);
    padding: 0.7rem 0.9rem; font-size: 0.85rem; margin-bottom: 1.25rem;
}
.inline-note i { color: var(--accent); }

/* Investing-style chips */
.chip-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}
.chip-check span:hover { border-color: var(--text-muted); color: var(--text); }
.chip-check input:checked + span {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}
.chip-check input:focus-visible + span { box-shadow: 0 0 0 2px var(--accent-glow); }

/* Toggle switches */
.toggle-list { list-style: none; }
.toggle-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--border);
}
.toggle-list li:last-child { border-bottom: none; }
.toggle-label { display: block; color: var(--text); font-size: 0.92rem; }
.toggle-help { display: block; color: var(--text-muted); font-size: 0.8rem; margin-top: 0.15rem; }

.switch { position: relative; display: inline-block; width: 2.6rem; height: 1.5rem; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease;
}
.slider::before {
    content: "";
    position: absolute;
    height: 1.1rem;
    width: 1.1rem;
    left: 0.2rem;
    bottom: 0.2rem;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(1.1rem); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 2px var(--accent-glow); }

@media screen and (max-width: 768px) {
    .settings-layout { grid-template-columns: 1fr; }
    .settings-nav {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        margin-bottom: 0.5rem;
    }
    .user-menu-name { display: none; }
    .topbar { padding: 0 1rem; }
}

/* =========================================
   ADMIN PANEL
   ========================================= */
.badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03rem;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    vertical-align: middle;
    margin-left: 0.35rem;
}

.badge-admin { background-color: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); }
.badge-you { background-color: rgba(139, 148, 158, 0.15); color: var(--text-muted); }
.badge-active { background-color: rgba(63, 185, 80, 0.15); color: var(--positive); }
.badge-inactive { background-color: rgba(248, 81, 73, 0.15); color: var(--negative); }
.badge-open { background-color: rgba(63, 185, 80, 0.15); color: var(--positive); }
.badge-closed { background-color: rgba(139, 148, 158, 0.15); color: var(--text-muted); }
.badge-lg { font-size: 0.8rem; padding: 0.3rem 0.8rem; }

/* =========================================
   SUPPORT / TICKETS
   ========================================= */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    max-width: 46rem;
}

.ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.ticket-header h1 { font-size: 1.6rem; color: var(--heading); margin-bottom: 0.35rem; }
.ticket-header-actions { display: flex; align-items: center; gap: 0.75rem; }

.ticket-thread {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 52rem;
}

/* Conversation bubbles */
.conversation { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 1.5rem; }

.msg { display: flex; gap: 0.75rem; max-width: 85%; }
.msg.user { align-self: flex-start; }
.msg.staff { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
    flex-shrink: 0;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    background: var(--border);
    color: var(--text);
}
.msg-avatar.staff { background: linear-gradient(135deg, var(--accent), #3872ff); color: #06121a; }

.msg-bubble {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
}
.msg.staff .msg-bubble { background: var(--accent-soft); border-color: rgba(0, 210, 255, 0.3); }

.msg-head { display: flex; gap: 0.75rem; align-items: baseline; margin-bottom: 0.35rem; }
.msg-author { font-weight: 600; color: var(--heading); font-size: 0.85rem; }
.msg-time { color: var(--text-muted); font-size: 0.72rem; }
.msg-body { color: var(--text); font-size: 0.9rem; line-height: 1.55; white-space: pre-wrap; }

.msg-attachment {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.6rem;
    padding: 0.35rem 0.7rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--accent);
}
.msg-attachment:hover { border-color: var(--accent); }

/* Reply form */
.reply-form {
    border-top: 1px solid var(--border);
    padding-top: 1.25rem;
}
.reply-form textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.92rem;
    outline: none;
    resize: vertical;
}
.reply-form textarea:focus { border-color: var(--accent); }
.reply-note { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.75rem; }
.reply-note i { color: var(--accent); }
.reply-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}
.reply-actions .btn-confirm { margin-left: auto; }

/* Admin inbox toolbar */
.inbox-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.filter-tabs { display: flex; gap: 0.35rem; }
.filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}
.filter-tab:hover { color: var(--heading); background: var(--surface); }
.filter-tab.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.tab-count {
    background: var(--bg);
    border-radius: 999px;
    padding: 0.05rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
}
.inbox-search { min-width: 16rem; flex: 1; max-width: 26rem; }
.inbox-search .search-bar { padding: 0.55rem 1rem; }

.company-name.awaiting { color: var(--positive); }
.company-name.awaiting i { font-size: 0.5rem; vertical-align: middle; }

@media screen and (max-width: 640px) {
    .msg { max-width: 100%; }
    .inbox-toolbar { flex-direction: column; align-items: stretch; }
}

.actions-col { width: 8rem; }

.admin-actions { display: flex; gap: 0.4rem; }
.admin-actions form { margin: 0; }

.icon-btn {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn.danger:hover { color: var(--negative); border-color: var(--negative); }
.icon-btn.active-pin { color: var(--accent); border-color: var(--accent); }

/* =========================================
   LEGAL PAGES (Terms) + auth legal footer
   ========================================= */
.legal-body { background: var(--bg); color: var(--text); min-height: 100vh; }

.legal-topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 2rem; border-bottom: 1px solid var(--border);
    background: rgba(13, 17, 23, 0.9); backdrop-filter: blur(8px);
}

.legal-wrap { max-width: 46rem; margin: 0 auto; padding: 3rem 1.5rem; line-height: 1.7; }
.legal-wrap h1 { font-size: 2.2rem; color: var(--heading); margin-bottom: 0.4rem; }
.legal-updated { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 2rem; }
.legal-wrap h2 { color: var(--heading); font-size: 1.2rem; margin: 2rem 0 0.6rem; }
.legal-wrap p { color: var(--text); margin-bottom: 1rem; }
.legal-wrap a { color: var(--accent); }

.legal-foot {
    text-align: center; color: var(--text-muted); font-size: 0.85rem;
    padding: 2rem 1.5rem; border-top: 1px solid var(--border);
}
.legal-foot a { color: var(--accent); text-decoration: none; }
.legal-foot a:hover { text-decoration: underline; }

.auth-legal {
    margin-top: 1.5rem; text-align: center;
    color: var(--text-muted); font-size: 0.8rem; line-height: 1.6;
}
.auth-legal a { color: var(--text-muted); text-decoration: underline; }
.auth-legal a:hover { color: var(--accent); }

/* =========================================
   ADMIN PANEL (separate layout)
   ========================================= */
.admin-sidebar .logo i { color: #a371f7; text-shadow: 0 0 1rem rgba(163, 113, 247, 0.7); }

.admin-sidebar ul a { position: relative; }

.nav-badge {
    margin-left: auto;
    background: var(--negative);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 1.2rem;
    text-align: center;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}
.sidebar-link i { width: 1.5rem; text-align: left; }
.sidebar-link:hover { color: var(--heading); background: var(--surface-hover); }
.sidebar-link.danger:hover { color: var(--negative); }

/* Activity feed */
.activity-list { list-style: none; }
.activity-list li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s ease;
}
.activity-list li:last-child a { border-bottom: none; }
.activity-list li a:hover { background: var(--surface-hover); }
.activity-icon {
    width: 1.9rem; height: 1.9rem; flex-shrink: 0;
    border-radius: 50%;
    background: var(--bg);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem;
}
.activity-text { flex: 1; font-size: 0.88rem; }
.activity-time { color: var(--text-muted); font-size: 0.75rem; }

/* System status */
.status-list { list-style: none; }
.status-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}
.status-list li:last-child { border-bottom: none; }
.status-dot {
    width: 0.6rem; height: 0.6rem; border-radius: 50%; flex-shrink: 0;
}
.status-dot.state-ok { background: var(--positive); box-shadow: 0 0 0.5rem var(--positive); }
.status-dot.state-warn { background: #e3b341; box-shadow: 0 0 0.5rem #e3b341; }
.status-dot.state-down { background: var(--negative); box-shadow: 0 0 0.5rem var(--negative); }
.status-name { flex: 1; font-size: 0.9rem; color: var(--text); }
.status-detail { color: var(--text-muted); font-size: 0.82rem; }

/* User detail */
.user-detail-header {
    display: flex; align-items: center; gap: 1.25rem;
    margin-bottom: 1.5rem; padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.user-detail-header h1 { font-size: 1.5rem; color: var(--heading); }
.user-detail-meta { display: flex; gap: 0.4rem; margin-top: 0.5rem; flex-wrap: wrap; }

.toggle-inline {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.6rem 0; color: var(--text); font-size: 0.9rem; cursor: pointer;
}
.toggle-inline input { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }

.action-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.action-grid form { margin: 0; }

.btn-danger {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: transparent; color: var(--negative);
    border: 1px solid var(--negative);
    padding: 0.5rem 1rem; border-radius: var(--radius-sm);
    font-size: 0.9rem; cursor: pointer; transition: all 0.2s ease;
}
.btn-danger:hover { background: rgba(248, 81, 73, 0.1); }

/* Integrations */
.integration-list { list-style: none; }
.integration-list li {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.85rem 0; border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}
.integration-list li:last-child { border-bottom: none; }
.integration-text { display: flex; flex-direction: column; gap: 0.2rem; }
.integration-name { color: var(--heading); font-size: 0.9rem; display: flex; align-items: center; gap: 0.5rem; }
.integration-detail { color: var(--text-muted); font-size: 0.78rem; }
.color-input { height: 2.6rem; padding: 0.2rem; cursor: pointer; }

/* News feed on user dashboard */
.news-feed { list-style: none; }
.news-feed li {
    display: flex; gap: 0.9rem; padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.news-feed li:last-child { border-bottom: none; }
.news-feed-icon {
    width: 2.3rem; height: 2.3rem; flex-shrink: 0; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent);
}
.news-feed-icon.cat-features { background: rgba(63, 185, 80, 0.14); color: var(--positive); }
.news-feed-content { flex: 1; }
.news-feed-head { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.news-feed-head .fa-thumbtack { color: var(--accent); font-size: 0.75rem; }
.news-feed-title { font-weight: 600; color: var(--heading); font-size: 0.95rem; }
.news-feed-date { color: var(--text-muted); font-size: 0.75rem; margin-left: auto; }
.news-feed-body { color: var(--text-muted); font-size: 0.87rem; line-height: 1.5; margin-top: 0.25rem; white-space: pre-wrap; }

@media screen and (max-width: 768px) {
    .nav-badge { display: none; }
    .sidebar-link span, .admin-sidebar .user-meta { display: none; }
    .sidebar-link { justify-content: center; padding: 0.7rem 0; }
}

/* =========================================
   CUSTOMIZABLE WIDGET DASHBOARD (Phase 6)
   ========================================= */
.dash-header { margin-bottom: 1rem; }
.dash-actions { display: flex; gap: 0.6rem; }

.grid-stack { margin: 0 -8px; }

/* Each grid item becomes a widget card */
.grid-stack-item-content {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.2);
}

.w-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    cursor: grab;
    flex-shrink: 0;
}
.w-head:active { cursor: grabbing; }
.w-title { font-size: 0.85rem; font-weight: 600; color: var(--heading); display: flex; align-items: center; gap: 0.5rem; }
.w-title i { color: var(--accent); font-size: 0.8rem; }
.w-remove {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 0.2rem 0.35rem; border-radius: var(--radius-sm); font-size: 0.85rem;
    transition: all 0.15s ease;
}
.w-remove:hover { color: var(--negative); background: rgba(248, 81, 73, 0.1); }

.w-body { flex: 1; overflow-y: auto; padding: 0.85rem; font-size: 0.85rem; }
.w-body-flush { padding: 0.6rem; }

/* Loading / empty / footnotes */
.w-loading { display: flex; align-items: center; justify-content: center; height: 100%; min-height: 4rem; }
.w-loading .spinner { width: 1.8rem; height: 1.8rem; border-width: 0.22rem; }
.w-empty { color: var(--text-muted); text-align: center; padding: 1.25rem 0.5rem; font-size: 0.82rem; }
.w-foot { color: var(--text-muted); font-size: 0.68rem; margin-top: 0.5rem; text-align: center; }
.w-subtitle { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04rem; color: var(--text-muted); margin: 0.4rem 0 0.2rem; }
.w-subtitle.positive { color: var(--positive); }
.w-subtitle.negative { color: var(--negative); }

/* Quote / list rows */
.w-list { list-style: none; }
.w-list li {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.4rem 0.25rem; border-bottom: 1px solid rgba(48, 54, 61, 0.5);
    cursor: pointer; border-radius: var(--radius-sm);
}
.w-list li:last-child { border-bottom: none; }
.w-list li:hover { background: var(--surface-hover); }
.w-ticker { font-weight: 700; color: var(--heading); min-width: 3.2rem; }
.w-name { color: var(--text-muted); font-size: 0.76rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-right { margin-left: auto; white-space: nowrap; font-size: 0.82rem; }
.w-sub { color: var(--text-muted); font-size: 0.78rem; }

/* News list */
.w-news { list-style: none; }
.w-news li { padding: 0.5rem 0; border-bottom: 1px solid rgba(48, 54, 61, 0.5); display: flex; flex-direction: column; gap: 0.2rem; }
.w-news li:last-child { border-bottom: none; }
.w-news a, .w-ann-title { color: var(--text); text-decoration: none; font-size: 0.82rem; line-height: 1.4; }
.w-news a:hover { color: var(--accent); }
.w-news small { color: var(--text-muted); font-size: 0.68rem; }
.w-ann-title { font-weight: 600; color: var(--heading); }
.w-ann-title .fa-thumbtack { color: var(--accent); font-size: 0.7rem; }

/* Stat blocks */
.w-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.w-stat-label { display: block; color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03rem; }
.w-stat-val { display: block; font-size: 1.1rem; font-weight: 700; color: var(--heading); margin-top: 0.15rem; }
.w-kv { list-style: none; }
.w-kv li { display: flex; justify-content: space-between; padding: 0.45rem 0; border-bottom: 1px solid rgba(48, 54, 61, 0.5); }
.w-kv li:last-child { border-bottom: none; }
.w-kv strong { color: var(--heading); }
.w-big { text-align: center; margin-bottom: 0.75rem; }
.w-big-val { display: block; font-size: 1.8rem; font-weight: 800; color: var(--heading); }
.w-big-sub { display: block; font-size: 0.8rem; margin-top: 0.15rem; }

/* Mini sector bars */
.w-bars { list-style: none; }
.w-bars li { display: grid; grid-template-columns: 5.5rem 1fr 3rem; align-items: center; gap: 0.5rem; padding: 0.28rem 0; }
.w-bar-name { font-size: 0.72rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-bar-track { height: 0.4rem; background: var(--bg); border-radius: 999px; overflow: hidden; }
.w-bar-fill { display: block; height: 100%; border-radius: 999px; }
.w-bar-fill.pos { background: var(--positive); }
.w-bar-fill.neg { background: var(--negative); }
.w-bar-val { font-size: 0.72rem; text-align: right; font-weight: 600; }

.w-gauge-label { text-align: center; font-weight: 700; font-size: 0.95rem; margin-top: 0.3rem; }

/* Productivity widgets */
.w-notes { width: 100%; height: 100%; min-height: 5rem; resize: none; border: none; background: transparent;
    color: var(--text); font-family: inherit; font-size: 0.85rem; outline: none; line-height: 1.5; }
.w-clock { text-align: center; display: flex; flex-direction: column; gap: 0.2rem; padding-top: 0.4rem; }
.w-clock-time { font-size: 1.9rem; font-weight: 800; color: var(--heading); letter-spacing: 0.03em; }
.w-clock-zone { color: var(--text-muted); font-size: 0.75rem; }
.w-clock-status { font-size: 0.78rem; font-weight: 600; margin-top: 0.3rem; }
.w-clock-status.open { color: var(--positive); }
.w-clock-status.closed { color: var(--text-muted); }
.w-fx { display: flex; flex-direction: column; gap: 0.55rem; }
.w-fx-amt, .w-fx select { background: var(--bg); border: 1px solid var(--border); color: var(--text);
    padding: 0.5rem; border-radius: var(--radius-sm); font-size: 0.9rem; outline: none; }
.w-fx-row { display: flex; align-items: center; gap: 0.4rem; }
.w-fx-row select { flex: 1; }
.w-fx-row i { color: var(--text-muted); }
.w-fx-out { text-align: center; font-size: 1.15rem; font-weight: 700; color: var(--accent); padding: 0.4rem; }
.w-links { list-style: none; }
.w-links li a { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.4rem; border-radius: var(--radius-sm);
    color: var(--text); text-decoration: none; font-size: 0.88rem; }
.w-links li a:hover { background: var(--surface-hover); color: var(--accent); }
.w-links li a i { width: 1.2rem; text-align: center; color: var(--text-muted); }

/* Gridstack drag/resize visuals */
.grid-stack-item.ui-draggable-dragging .grid-stack-item-content { box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.5); border-color: var(--accent); }
.grid-stack-placeholder > .placeholder-content { background: var(--accent-soft); border: 1px dashed var(--accent); border-radius: var(--radius); }
.grid-stack > .grid-stack-item > .ui-resizable-se { filter: none; }

/* Widget library modal */
.library-modal { max-width: 44rem; }
.library-search { margin-bottom: 1rem; }
.library-body { max-height: 60vh; overflow-y: auto; }
.library-group { margin-bottom: 1.25rem; }
.library-group h4 { color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05rem; margin-bottom: 0.6rem; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.6rem; }
.library-card {
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
    padding: 0.9rem 0.5rem; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s ease; text-align: center;
}
.library-card:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }
.library-icon { width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center; }
.library-card-title { font-size: 0.78rem; color: var(--text); }
