:root {
    --bg: #0b0e14;
    --surface: #121721;
    --surface-2: #171e2b;
    --border: #222c3c;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #f0883e;
    --up: #3fb950;
    --up-bg: rgba(63, 185, 80, 0.12);
    --down: #f85149;
    --down-bg: rgba(248, 81, 73, 0.12);
    --flat: #8b949e;
    --flat-bg: rgba(139, 148, 158, 0.12);
    --warn: #d29922;
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    line-height: 1.4;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 20px;
    background: rgba(11, 14, 20, 0.94);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.brand h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--accent);
}

.brand .subtitle {
    color: var(--muted);
    font-size: 12px;
}

.controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tf-group {
    display: inline-flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.tf-btn {
    padding: 5px 11px;
    color: var(--muted);
    text-decoration: none;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    border-right: 1px solid var(--border);
    transition: background 0.15s, color 0.15s;
}

.tf-btn:last-child { border-right: none; }
.tf-btn:hover { color: var(--text); background: var(--surface-2); }
.tf-btn.active { background: var(--accent); color: #0b0e14; }

.sync-meta {
    color: var(--muted);
    font-size: 11.5px;
    font-family: var(--mono);
}

.sync-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.sync-btn:hover { border-color: var(--accent); color: var(--accent); }
.sync-btn:disabled { opacity: 0.6; cursor: wait; }

.container {
    max-width: 1680px;
    margin: 0 auto;
    padding: 16px 20px 40px;
}

.layout-2col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
    align-items: start;
}

.col-main,
.col-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.side-tile-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tbl-compact th,
.tbl-compact td {
    padding: 6px 8px;
}

.tbl-compact .spark {
    width: 54px;
    height: 18px;
}

.policy-rate-row td {
    border-top: 1px dashed var(--border);
    background: rgba(240, 136, 62, 0.04);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

@media (max-width: 1180px) {
    .layout-2col { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
}

.widget {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    scroll-margin-top: 64px;
}

.widget-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.widget-head h2 {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text);
}

.widget-tag {
    font-size: 10.5px;
    font-family: var(--mono);
    color: var(--muted);
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.widget-body {
    padding: 10px 12px;
}

.tile-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 8px;
}

.tile {
    background: #0e131c;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tile-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.tile-link:hover {
    border-color: var(--accent);
    background: var(--surface-2);
}

.tile-link:hover .tile-name {
    color: var(--accent);
}

.tile-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}

.tile-name {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tile-sym {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
}

.tile-mid {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
}

.val {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.pct {
    font-family: var(--mono);
    font-size: 11.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.pct.up { color: var(--up); background: var(--up-bg); }
.pct.down { color: var(--down); background: var(--down-bg); }
.pct.flat { color: var(--flat); background: var(--flat-bg); }

.tbd-badge {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--warn);
    border: 1px dashed rgba(210, 153, 34, 0.5);
    border-radius: 4px;
    padding: 1px 5px;
}

.spark {
    display: block;
    width: 72px;
    height: 22px;
    flex-shrink: 0;
}

.tile-bot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
}

.sub-returns {
    display: flex;
    gap: 6px;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
}

.sub-returns .up { color: var(--up); }
.sub-returns .down { color: var(--down); }

.crypto-kr-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 6px;
    margin-top: 1px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(34, 44, 60, 0.65);
    font-family: var(--mono);
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
}

.crypto-kr-price {
    color: var(--text);
    font-weight: 600;
}

.crypto-kimp {
    font-weight: 700;
    padding: 0 5px;
    border-radius: 3px;
    white-space: nowrap;
}

.crypto-kimp.up { color: var(--up); background: var(--up-bg); }
.crypto-kimp.down { color: var(--down); background: var(--down-bg); }
.crypto-kimp.flat { color: var(--flat); background: var(--flat-bg); }

/* Compact data tables (Bonds, Real Estate, Equity Matrix) */
.tbl {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.tbl th, .tbl td {
    padding: 7px 10px;
    border-bottom: 1px solid rgba(34, 44, 60, 0.7);
    text-align: left;
    vertical-align: middle;
}

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

.tbl th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    background: #0e131c;
}

.tbl td.num, .tbl th.num {
    text-align: right;
    font-family: var(--mono);
}

.matrix-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.matrix-left {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.matrix-ticker {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
}

.matrix-price {
    font-family: var(--mono);
    font-size: 12.5px;
    font-weight: 600;
}

.matrix-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sector-label {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.empty-cell {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
}

.clickable-row {
    cursor: pointer;
    transition: background 0.15s;
}

.clickable-row:hover {
    background: var(--surface-2);
}

.row-link {
    color: inherit;
    text-decoration: none;
}

.clickable-row:hover .row-link,
.row-link:hover {
    color: var(--accent);
}

.matrix-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    margin: -4px -6px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.matrix-link:hover {
    background: var(--surface-2);
}

.matrix-link:hover .matrix-ticker {
    color: var(--accent);
}

/* Sector-grouped Top Stocks */
.sector-groups {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sector-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 12px 8px;
    align-items: start;
}

.sector-group {
    grid-column: span var(--sector-span, 7);
    min-width: 0;
}

.sector-tile-grid {
    display: grid;
    grid-template-columns: repeat(var(--sector-span, 7), minmax(0, 1fr));
    gap: 8px;
}

.sector-group-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(34, 44, 60, 0.75);
    min-width: 0;
}

.sector-group-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sector-group-count {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 6px;
    flex-shrink: 0;
}

@media (max-width: 1280px) {
    .sector-row {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .sector-group {
        grid-column: auto;
    }

    .sector-tile-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    }
}

.rank-num {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--accent);
    font-weight: 700;
}

.tile-name-link {
    text-decoration: none;
    color: var(--text);
}

.tile-top-right {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font-family: Georgia, serif;
    font-style: italic;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.info-btn:hover {
    border-color: var(--accent);
    color: #0b0e14;
    background: var(--accent);
}

.info-popover {
    position: fixed;
    z-index: 100;
    max-width: 300px;
    padding: 9px 11px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #161d29;
    color: var(--text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s;
}

.info-popover.visible {
    opacity: 1;
}

.info-popover-title {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.info-popover-body {
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--text);
}

.empty-state {
    color: var(--muted);
    font-size: 12px;
    padding: 12px 4px;
}

.empty-state code {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--text);
    background: var(--surface-2);
    padding: 2px 5px;
    border-radius: 4px;
}


/* ==================== INSTRUMENT CHART & LIVERMORE MODAL ==================== */
body.modal-open {
    overflow: hidden;
}

.inst-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(5, 8, 13, 0.78);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.inst-modal-backdrop.open {
    display: flex;
}

.inst-modal {
    width: min(1040px, 100%);
    height: min(84vh, 780px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.inst-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.inst-modal-title-group {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
    flex-wrap: wrap;
}

.inst-modal-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.inst-modal-sym {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--muted);
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.inst-modal-price {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
}

.inst-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.inst-modal-ext {
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
    font-size: 11.5px;
    font-weight: 600;
    transition: border-color 0.15s, color 0.15s;
}

.inst-modal-ext:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.inst-modal-close {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, color 0.15s;
}

.inst-modal-close:hover {
    border-color: var(--down);
    color: var(--text);
}

.inst-modal-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: #0f141e;
    flex-wrap: wrap;
}

.inst-tabs,
.inst-pill-group {
    display: inline-flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.inst-tab-btn,
.inst-pill-btn {
    padding: 5px 12px;
    border: none;
    border-right: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.inst-tab-btn:last-child,
.inst-pill-btn:last-child {
    border-right: none;
}

.inst-tab-btn:hover,
.inst-pill-btn:hover {
    color: var(--text);
    background: var(--surface-2);
}

.inst-tab-btn.active {
    background: var(--accent);
    color: #0b0e14;
}

.inst-pill-btn {
    font-family: var(--mono);
    font-size: 11.5px;
    padding: 4px 10px;
}

.inst-pill-btn.active {
    background: var(--surface-2);
    color: var(--accent);
}

.inst-pill-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.inst-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #0e131c;
    position: relative;
}

.inst-panel {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
}

.inst-panel.active {
    display: flex;
}

.inst-chart-stage {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    position: relative;
}

.inst-chart-stage .tradingview-widget-container,
.inst-chart-stage .tradingview-widget-container__widget {
    width: 100%;
    height: 100%;
}

.inst-loading,
.inst-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12.5px;
    padding: 20px;
    text-align: center;
}

.inst-error {
    color: var(--down);
}

/* ==================== LIVERMORE 6-COLUMN LEDGER ==================== */
.livermore-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-wrap: wrap;
}

.livermore-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 11.5px;
    font-family: var(--mono);
}

.livermore-state-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.03em;
    border: 1px solid var(--border);
}

.livermore-state-badge.state-upward_trend {
    color: var(--up);
    background: var(--up-bg);
    border-color: rgba(63, 185, 80, 0.35);
}

.livermore-state-badge.state-downward_trend {
    color: var(--down);
    background: var(--down-bg);
    border-color: rgba(248, 81, 73, 0.35);
}

.livermore-state-badge.state-natural_rally,
.livermore-state-badge.state-secondary_rally,
.livermore-state-badge.state-natural_reaction,
.livermore-state-badge.state-secondary_reaction {
    color: var(--text);
    background: var(--flat-bg);
}

.livermore-pivots {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.livermore-pivots b.pv-top {
    color: var(--text);
    border-bottom: 2px solid var(--down);
    padding-bottom: 1px;
}

.livermore-pivots b.pv-bottom {
    color: var(--text);
    border-bottom: 2px solid var(--up);
    padding-bottom: 1px;
}

.livermore-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.lv-threshold-controls {
    display: inline-flex;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.lv-threshold-select {
    background: transparent;
    color: var(--text);
    border: none;
    border-right: 1px solid var(--border);
    padding: 4px 8px;
    font-family: var(--mono);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

.lv-threshold-select option {
    background: var(--surface);
    color: var(--text);
}

.lv-auto-btn {
    padding: 4px 9px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.lv-auto-btn:hover {
    color: var(--text);
    background: var(--surface-2);
}

.lv-auto-btn.active {
    background: var(--surface-2);
    color: var(--accent);
}

.livermore-state-badge.state-pending {
    color: var(--muted);
    background: var(--flat-bg);
}

.livermore-tbl td.lv-pending-cell {
    text-align: center;
    color: var(--muted);
    font-size: 11px;
    font-style: italic;
}

.lv-signal-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin-left: 4px;
    border-radius: 50%;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
    cursor: help;
}

.lv-signal-dot.sig-confirm {
    color: var(--up);
    background: rgba(63, 185, 80, 0.16);
    border: 1px solid rgba(63, 185, 80, 0.45);
}

.lv-signal-dot.sig-danger {
    color: #f0883e;
    background: rgba(240, 136, 62, 0.16);
    border: 1px solid rgba(240, 136, 62, 0.5);
}

/* ==================== LIVERMORE ACTION BADGES, TRIGGERS & KOREAN STUDY POPOVER ==================== */
.lv-badge-slot {
    display: inline-flex;
    align-items: center;
}

.lv-badge-slot:empty {
    display: none;
}

.tbl-name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.matrix-right-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.lv-action-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1.35;
    white-space: nowrap;
    cursor: help;
    vertical-align: middle;
    border: 1px solid transparent;
}

.lv-action-badge.lv-act-compact {
    font-size: 8.5px;
    padding: 0 5px;
    line-height: 1.4;
}

.lv-action-badge.lv-act-ledger {
    margin-left: 6px;
    font-size: 9px;
    padding: 1px 5px;
}

.lv-act-buy {
    color: #3fb950;
    background: rgba(63, 185, 80, 0.18);
    border-color: rgba(63, 185, 80, 0.55);
}

.lv-act-add {
    color: #2dd4bf;
    background: rgba(45, 212, 191, 0.16);
    border-color: rgba(45, 212, 191, 0.55);
}

.lv-act-exit {
    color: #f0883e;
    background: rgba(240, 136, 62, 0.18);
    border-color: rgba(240, 136, 62, 0.55);
}

.lv-act-sell {
    color: #f85149;
    background: rgba(248, 81, 73, 0.18);
    border-color: rgba(248, 81, 73, 0.55);
}

.lv-act-watch {
    color: #58a6ff;
    background: rgba(88, 166, 255, 0.16);
    border-color: rgba(88, 166, 255, 0.52);
}

.lv-act-study {
    color: var(--muted);
    background: rgba(139, 148, 158, 0.14);
    border-color: rgba(139, 148, 158, 0.35);
}

/* Subtle top-right signal highlight on dashboard cards */
.tile.has-lv-badge.lv-card-buy { border-color: rgba(63, 185, 80, 0.5); }
.tile.has-lv-badge.lv-card-add { border-color: rgba(45, 212, 191, 0.5); }
.tile.has-lv-badge.lv-card-exit { border-color: rgba(240, 136, 62, 0.5); }
.tile.has-lv-badge.lv-card-sell { border-color: rgba(248, 81, 73, 0.5); }
.tile.has-lv-badge.lv-card-watch { border-color: rgba(88, 166, 255, 0.45); }

.lv-val.has-study-tip {
    cursor: help;
}

/* Modal Next Buy / Sell Trigger Strip */
.livermore-triggers-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px 16px;
    border-bottom: 1px solid var(--border);
    background: #101622;
    font-family: var(--mono);
    font-size: 11px;
}

.lv-triggers-label {
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.03em;
    margin-right: 2px;
}

.lv-trigger-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: help;
}

.lv-trig-tag {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.lv-trig-val {
    color: var(--text);
    font-weight: 600;
}

.lv-trig-buy { border-color: rgba(63, 185, 80, 0.42); background: rgba(63, 185, 80, 0.08); }
.lv-trig-buy .lv-trig-tag { color: #3fb950; }

.lv-trig-add { border-color: rgba(45, 212, 191, 0.42); background: rgba(45, 212, 191, 0.08); }
.lv-trig-add .lv-trig-tag { color: #2dd4bf; }

.lv-trig-watch { border-color: rgba(88, 166, 255, 0.42); background: rgba(88, 166, 255, 0.08); }
.lv-trig-watch .lv-trig-tag { color: #58a6ff; }

.lv-trig-exit { border-color: rgba(240, 136, 62, 0.42); background: rgba(240, 136, 62, 0.08); }
.lv-trig-exit .lv-trig-tag { color: #f0883e; }

.lv-trig-sell { border-color: rgba(248, 81, 73, 0.42); background: rgba(248, 81, 73, 0.08); }
.lv-trig-sell .lv-trig-tag { color: #f85149; }

/* Floating Korean Study Tooltip */
.lv-study-tooltip {
    position: fixed;
    z-index: 2000;
    width: 340px;
    max-width: calc(100vw - 24px);
    padding: 10px 12px;
    border-radius: 8px;
    background: #141b26;
    border: 1px solid #2b384d;
    border-left: 3px solid var(--accent);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.62);
    color: var(--text);
    font-size: 12px;
    line-height: 1.5;
    pointer-events: none;
    opacity: 0;
    transform: translateY(3px);
    transition: opacity 0.12s ease, transform 0.12s ease;
    visibility: hidden;
}

.lv-study-tooltip.open {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

.lv-study-tooltip.lv-tip-buy { border-left-color: #3fb950; }
.lv-study-tooltip.lv-tip-add { border-left-color: #2dd4bf; }
.lv-study-tooltip.lv-tip-exit { border-left-color: #f0883e; }
.lv-study-tooltip.lv-tip-sell { border-left-color: #f85149; }
.lv-study-tooltip.lv-tip-watch { border-left-color: #58a6ff; }
.lv-study-tooltip.lv-tip-study { border-left-color: #8b949e; }

.lv-tip-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
}

.lv-tip-meta {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--muted);
}

.lv-tip-title {
    font-size: 12.5px;
    font-weight: 700;
    color: #f0f6fc;
    margin-bottom: 7px;
}

.lv-tip-row {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 5px;
}

.lv-tip-k {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.lv-tip-v {
    font-size: 11.5px;
    color: #cdd6e2;
    word-break: keep-all;
}

.lv-tip-guide {
    margin-top: 7px;
    padding-top: 6px;
    border-top: 1px solid rgba(43, 56, 77, 0.8);
}

.lv-tip-guide .lv-tip-k {
    color: #3fb950;
}

/* ==================== STOCK BACKTEST TAB ==================== */
.bt-exec-note {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--muted);
}

.bt-desc-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 12px;
    color: #cdd6e2;
}

.bt-span-meta {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
}

.bt-kpi-grid .fin-kpi-val.up { color: var(--up); }
.bt-kpi-grid .fin-kpi-val.down { color: var(--down); }

.bt-kpi-sub {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--muted);
    margin-top: 2px;
}

.bt-chart-card {
    margin: 12px 0 14px;
    padding: 10px 12px 8px;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.bt-chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.bt-chart-title {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text);
}

.bt-chart-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
}

.bt-leg-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.bt-leg-item b {
    color: var(--text);
}

.bt-leg-line {
    display: inline-block;
    width: 14px;
    height: 2px;
    border-radius: 1px;
}

.bt-leg-bh {
    background: repeating-linear-gradient(90deg, #8b949e 0 4px, transparent 4px 7px);
}

.bt-equity-svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 200px;
}

.bt-cmp-row {
    cursor: pointer;
    transition: background 0.12s;
}

.bt-cmp-row:hover {
    background: rgba(88, 166, 255, 0.06);
}

.bt-cmp-row.is-selected {
    background: rgba(88, 166, 255, 0.11);
}

.bt-cmp-row.is-selected td:first-child {
    color: var(--accent);
}

.bt-bh-row {
    background: rgba(255, 255, 255, 0.02);
}

.lv-export-wrap {
    position: relative;
}

.lv-export-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--mono);
    line-height: 1.4;
}

.lv-export-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

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

.lv-export-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 140px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    z-index: 30;
}

.lv-export-wrap.open .lv-export-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lv-export-item {
    background: transparent;
    border: none;
    color: var(--text);
    text-align: left;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11.5px;
    font-family: var(--mono);
    cursor: pointer;
}

.lv-export-item:hover {
    background: rgba(88, 166, 255, 0.14);
    color: var(--accent);
}

.livermore-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.livermore-tbl {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--mono);
    font-size: 12px;
    table-layout: fixed;
}

.livermore-tbl thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid rgba(34, 44, 60, 0.55);
    padding: 8px 6px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.livermore-tbl thead th.col-upward_trend {
    color: var(--up);
    background: rgba(63, 185, 80, 0.08);
}

.livermore-tbl thead th.col-downward_trend {
    color: var(--down);
    background: rgba(248, 81, 73, 0.08);
}

.livermore-tbl tbody td {
    padding: 5px 8px;
    text-align: right;
    border-bottom: 1px solid rgba(34, 44, 60, 0.45);
    border-right: 1px solid rgba(34, 44, 60, 0.35);
    white-space: nowrap;
}

.livermore-tbl tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.livermore-tbl tbody tr.row-noise td.lv-date,
.livermore-tbl tbody tr.row-noise .lv-val {
    opacity: 0.48;
}

.livermore-tbl td.lv-date {
    text-align: left;
    color: var(--muted);
    font-size: 11px;
}

.livermore-tbl td.col-upward_trend {
    background: rgba(63, 185, 80, 0.03);
}

.livermore-tbl td.col-downward_trend {
    background: rgba(248, 81, 73, 0.03);
}

.lv-val {
    display: inline-block;
    padding: 0 2px;
}

.lv-val.ink-up {
    color: var(--up);
    font-weight: 700;
}

.lv-val.ink-down {
    color: var(--down);
    font-weight: 700;
}

.lv-val.ink-pencil {
    color: #b1bac4;
}

.lv-val.pivotal-top {
    border-bottom: 2px solid var(--down);
    padding-bottom: 1px;
}

.lv-val.pivotal-bottom {
    border-bottom: 2px solid var(--up);
    padding-bottom: 1px;
}

.livermore-legend {
    padding: 6px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}


/* ==================== LIVE WATCH & SECTOR FORCE REFRESH ==================== */
.widget-head-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.watch-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.watch-interval {
    background: var(--bg);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 3px 6px;
    font-family: var(--mono);
    font-size: 11px;
    cursor: pointer;
}

.watch-interval:hover,
.watch-interval:focus {
    border-color: var(--accent);
    color: var(--text);
    outline: none;
}

.watch-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.watch-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.market-refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

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

.market-refresh-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

.widget-sync-controls {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: auto;
}

.widget-refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

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

.widget-refresh-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

.refresh-icon {
    display: inline-block;
}

.is-refreshing .refresh-icon {
    animation: refresh-spin 0.8s linear infinite;
}

@keyframes refresh-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.refresh-error {
    border-color: var(--down);
    color: var(--down);
}

@keyframes widget-updated-flash {
    0% { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(240, 136, 62, 0.35); }
    100% { border-color: var(--border); box-shadow: none; }
}

.widget.widget-updated {
    animation: widget-updated-flash 0.9s ease-out;
}

.widget-sync-at {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
    white-space: nowrap;
}

.widget-head-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.market-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 7px;
    border-radius: 999px;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    border: 1px solid var(--border);
}

.market-status-badge.is-open {
    color: var(--up);
    background: var(--up-bg);
    border-color: rgba(63, 185, 80, 0.4);
}

.market-status-badge.is-closed {
    color: var(--muted);
    background: var(--flat-bg);
}

.market-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.market-status-badge.is-open .market-status-dot {
    box-shadow: 0 0 6px var(--up);
}

.watch-btn.watching {
    border-color: rgba(63, 185, 80, 0.55);
    background: rgba(63, 185, 80, 0.12);
    color: var(--up);
}

.watch-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
}

.watch-btn.watching .watch-dot {
    background: var(--up);
    box-shadow: 0 0 6px var(--up);
    animation: watch-pulse 1.8s infinite;
}

@keyframes watch-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.watch-status {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--muted);
}

.sector-refresh-btn {
    margin-left: auto;
    padding: 1px 7px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.sector-refresh-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--surface-2);
}

.sector-refresh-btn.loading {
    opacity: 0.65;
    cursor: wait;
    color: var(--accent);
    border-color: var(--accent);
}

@keyframes tile-flash-up {
    0% { box-shadow: inset 0 0 0 1px var(--up), 0 0 10px rgba(63, 185, 80, 0.25); }
    100% { box-shadow: none; }
}

@keyframes tile-flash-down {
    0% { box-shadow: inset 0 0 0 1px var(--down), 0 0 10px rgba(248, 81, 73, 0.25); }
    100% { box-shadow: none; }
}

.tile.flash-up {
    animation: tile-flash-up 1.1s ease-out;
}

.tile.flash-down {
    animation: tile-flash-down 1.1s ease-out;
}


/* ==================== INSTRUMENT DETAIL TABS (FINANCIALS, NEWS, REPORTS) ==================== */
.inst-detail-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 520px;
    overflow-y: auto;
    padding: 2px 2px 6px;
}

.detail-meta-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 11.5px;
    color: var(--muted);
}

.detail-refresh-btn {
    padding: 3px 9px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

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

.detail-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.detail-footnote {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.fin-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 8px;
}

.fin-kpi-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.fin-kpi-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.fin-kpi-val {
    font-family: var(--mono);
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text);
}

.fin-intro {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 8px 12px;
}

.fin-intro-head {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    list-style: none;
}

.fin-intro-head::-webkit-details-marker {
    display: none;
}

.fin-intro-tags {
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
}

.fin-web-link {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}

.fin-web-link:hover {
    text-decoration: underline;
}

.fin-intro-body {
    margin: 8px 0 2px;
    font-size: 12.5px;
    line-height: 1.55;
    color: #c5cedb;
}

.fin-section-title {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-top: 2px;
}

.fin-unit-tag {
    font-family: var(--mono);
    font-weight: 500;
    text-transform: none;
}

.fin-table-wrap {
    border: 1px solid var(--border);
    border-radius: 7px;
    overflow-x: auto;
}

.fin-tbl th.is-est,
.fin-tbl td.is-est {
    color: var(--accent);
}

.fin-tbl td.mono {
    font-family: var(--mono);
    font-size: 12px;
}

.fin-tbl td.muted { color: var(--muted); }
.fin-tbl td.up { color: var(--up); }
.fin-tbl td.down { color: var(--down); }

.news-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.news-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}

.news-item:hover {
    border-color: var(--accent);
    background: #172030;
}

.news-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
}

.news-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: var(--muted);
}

.news-pub {
    font-weight: 600;
    color: #9cb2cc;
}

.news-time {
    font-family: var(--mono);
}

.rep-consensus-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    padding: 10px 14px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.rep-cons-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rep-cons-val {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.rep-cons-val.up { color: var(--up); }
.rep-cons-val.muted { color: var(--muted); }

.rep-bar-track {
    display: flex;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.rep-bar-seg { height: 100%; }
.seg-sb { background: #2ea043; }
.seg-b  { background: #56d364; }
.seg-h  { background: #8b949e; }
.seg-s  { background: #f85149; }
.seg-ss { background: #b62324; }

.rep-bar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 11.5px;
    color: var(--muted);
}

.rep-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--mono);
}

.rep-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.rep-broker-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(88, 166, 255, 0.12);
    color: #8cc4ff;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.rep-ext-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 2px;
}

.rep-ext-chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}

.rep-ext-chip:hover {
    border-color: var(--accent);
    background: #172030;
}


/* ==================== AUTH & ADMIN ==================== */

.brand-link {
    color: inherit;
    text-decoration: none;
}

.auth-topbar-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--border);
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.nav-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.nav-btn-muted {
    color: var(--muted);
}

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

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at top center, rgba(240, 136, 62, 0.08), transparent 45%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 28px 26px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.auth-brand {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 18px;
}

.auth-brand h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.auth-brand .subtitle {
    color: var(--muted);
    font-size: 12px;
}

.auth-badge {
    display: inline-block;
    padding: 3px 8px;
    margin-bottom: 10px;
    border-radius: 4px;
    background: rgba(240, 136, 62, 0.14);
    border: 1px solid rgba(240, 136, 62, 0.4);
    color: var(--accent);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
}

.auth-desc {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.5;
}

.auth-alert {
    padding: 10px 12px;
    margin-bottom: 14px;
    border-radius: 6px;
    font-size: 12.5px;
    line-height: 1.4;
}

.auth-alert-error {
    background: var(--down-bg);
    border: 1px solid rgba(248, 81, 73, 0.4);
    color: #ff948e;
}

.auth-alert-warn {
    background: rgba(210, 153, 34, 0.12);
    border: 1px solid rgba(210, 153, 34, 0.4);
    color: #e6c068;
}

.auth-alert-ok {
    background: var(--up-bg);
    border: 1px solid rgba(63, 185, 80, 0.4);
    color: #7ee787;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: var(--muted);
}

.auth-field small {
    color: var(--muted);
    opacity: 0.75;
}

.auth-field input {
    width: 100%;
    padding: 9px 11px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}

.auth-field input:focus {
    border-color: var(--accent);
}

.auth-submit {
    margin-top: 4px;
    padding: 10px 14px;
    border-radius: 6px;
    border: none;
    background: var(--accent);
    color: #0b0e14;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s;
}

.auth-submit:hover {
    filter: brightness(1.08);
}

.admin-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 1320px;
    margin: 0 auto;
}

.admin-panel-body {
    padding: 16px;
}

.admin-create-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.admin-create-form .auth-field {
    flex: 1 1 170px;
}

.admin-create-form .admin-field-narrow {
    flex: 0 0 110px;
}

.admin-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 4px;
    color: var(--text);
    font-size: 12.5px;
    cursor: pointer;
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.admin-table th,
.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.admin-table th {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(255, 255, 255, 0.015);
}

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

.is-disabled-row {
    opacity: 0.58;
}

.role-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(240, 136, 62, 0.16);
    border: 1px solid rgba(240, 136, 62, 0.4);
    color: var(--accent);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
}

.status-pill {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.status-active {
    background: var(--up-bg);
    color: var(--up);
}

.status-disabled {
    background: var(--down-bg);
    color: var(--down);
}

.mini-pill {
    display: inline-block;
    margin-left: 5px;
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
}

.muted-sub {
    color: var(--muted);
    font-size: 11.5px;
}

.mono {
    font-family: var(--mono);
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 0;
}

.inline-num {
    width: 56px;
    padding: 4px 6px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
}

.inline-input {
    width: 130px;
    padding: 4px 7px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
}

.action-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.mini-btn {
    padding: 4px 8px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.mini-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.mini-btn-danger:hover {
    border-color: var(--down);
    color: var(--down);
}

.ua-cell {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 11.5px;
}

/* ==================== USER DROPDOWN MENU ==================== */

.user-menu {
    position: relative;
}

.user-menu-trigger {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s, background 0.15s;
}

.user-menu-trigger::-webkit-details-marker {
    display: none;
}

.user-menu-trigger:hover,
.user-menu[open] .user-menu-trigger {
    border-color: var(--accent);
    background: var(--surface-2);
}

.user-menu-caret {
    color: var(--muted);
    font-size: 10px;
    transition: transform 0.15s;
}

.user-menu[open] .user-menu-caret {
    transform: rotate(180deg);
    color: var(--accent);
}

.user-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 170px;
    padding: 5px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px 8px;
    margin-bottom: 3px;
    border-bottom: 1px solid var(--border);
}

.user-menu-id {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-item {
    display: block;
    width: 100%;
    padding: 7px 9px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--text);
    font-size: 12.5px;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.user-menu-item:hover {
    background: var(--surface-2);
    color: var(--accent);
}

.user-menu-item-danger {
    color: var(--muted);
}

.user-menu-item-danger:hover {
    background: var(--down-bg);
    color: #ff948e;
}
