/* ============================================
   Scanner Chart V6 — On-Brand Terminal
   ============================================
   Design Identity: matches the platform theme.
   Warm dark surfaces · Emerald #10B981 accent ·
   Squared flat UI (4/8px). Candle + indicator
   colors are a data layer and stay untouched.
   ============================================ */

/* ── Design Tokens (mapped to theme.css) ── */
.chart-overlay {
    --sc-accent: #10B981;
    --sc-accent-rgb: 16, 185, 129;
    --sc-accent-dim: rgba(16, 185, 129, 0.09);
    --sc-accent-glow: rgba(16, 185, 129, 0.18);
    --sc-accent-border: rgba(16, 185, 129, 0.30);
    --sc-accent-bright: #34d399;

    --sc-surface: rgba(22, 22, 25, 0.96);
    --sc-surface-solid: #161619;
    --sc-surface-elevated: rgba(28, 28, 32, 0.97);

    --sc-danger: #e5484d;
    --sc-warning: #d99a2b;
    --sc-success: #10B981;

    --sc-text: #ffffff;
    --sc-text-mid: #888899;
    --sc-text-dim: #5A5A6A;
    --sc-text-ghost: rgba(255, 255, 255, 0.14);

    --sc-border: rgba(255, 255, 255, 0.06);
    --sc-border-accent: rgba(16, 185, 129, 0.30);
    --sc-border-strong: rgba(255, 255, 255, 0.13);

    --sc-radius: 8px;
    --sc-radius-sm: 4px;
    --sc-radius-lg: 12px;
    --sc-radius-pill: 8px;
}

/* ── Overlay Shell ── */

.chart-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: radial-gradient(ellipse at top, #1E1E2E 0%, #0F0F14 100%);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
    transition:
        transform 0.38s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.25s ease;
    will-change: transform, opacity;
}

.chart-overlay[hidden] {
    display: none !important;
}

.chart-overlay.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Top white scanline — identity marker */
.chart-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(16, 185, 129, 0.04) 10%,
        rgba(16, 185, 129, 0.28) 35%,
        rgba(16, 185, 129, 0.45) 50%,
        rgba(16, 185, 129, 0.28) 65%,
        rgba(16, 185, 129, 0.04) 90%,
        transparent 100%
    );
    z-index: 10;
}

.chart-overlay::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 20%;
    right: 20%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(16, 185, 129, 0.06),
        transparent
    );
    z-index: 10;
    filter: blur(1px);
}

/* ── Toolbar ── */

.chart-toolbar {
    height: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    border-bottom: 1px solid var(--sc-border);
    background: linear-gradient(180deg, #17171b 0%, #141417 100%);
    flex-shrink: 0;
    position: relative;
    z-index: 5;
}

.chart-toolbar__left {
    display: flex;
    align-items: center;
    gap: 9px;
    padding-right: 14px;
    border-right: 1px solid var(--sc-border);
    align-self: stretch;
    flex-shrink: 0;
}

.chart-toolbar__ticker-symbol {
    font-family: 'Rajdhani', sans-serif;
    font-size: 17px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: #ffffff;
    line-height: 1;
}

.chart-toolbar__ticker-price {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 500;
    color: var(--sc-text-mid);
    letter-spacing: 0.02em;
    transition: color 0.3s ease, text-shadow 0.3s ease;
    min-width: 70px;
}

/* Price flash animations */
@keyframes sc-flash-up {
    0% { color: var(--sc-success); text-shadow: 0 0 8px rgba(74, 222, 128, 0.4); }
    100% { color: var(--sc-text-mid); text-shadow: none; }
}
@keyframes sc-flash-down {
    0% { color: var(--sc-danger); text-shadow: 0 0 8px rgba(255, 59, 59, 0.4); }
    100% { color: var(--sc-text-mid); text-shadow: none; }
}

.chart-toolbar__ticker-price.flash-up {
    animation: sc-flash-up 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.chart-toolbar__ticker-price.flash-down {
    animation: sc-flash-down 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.chart-toolbar__price-change {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--sc-text-dim);
}

.chart-toolbar__center {
    display: flex;
    align-items: center;
    margin-right: auto;
    min-width: 0;
}

.chart-toolbar__tools {
    display: flex;
    align-items: center;
    gap: 0;
}

.chart-tool-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.chart-toolbar__divider {
    width: 1px;
    min-width: 1px;
    height: 22px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0 9px;
    flex: 0 0 1px;
    align-self: center;
}

.chart-toolbar__right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    flex-shrink: 0;
}

.chart-mode-toggle {
    width: 150px;
}

/* ── Tool Buttons ── */

.chart-tool {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #9a9aa8;
    border-radius: 7px;
    cursor: pointer;
    transition:
        color 0.14s ease,
        background 0.14s ease;
    font-size: 16px;
    position: relative;
    flex: 0 0 auto;
}

/* Custom inline-SVG tool icons */
.chart-tool .ti {
    width: 19px;
    height: 19px;
    display: block;
    pointer-events: none;
}

.chart-tool:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.07);
}

.chart-tool:active {
    background: rgba(255, 255, 255, 0.10);
}

.chart-tool.active {
    color: var(--sc-accent-bright);
    background: rgba(16, 185, 129, 0.12);
}

.chart-tool--close:hover {
    color: var(--sc-danger);
    background: rgba(229, 72, 77, 0.12);
}

.chart-tool--action {
    width: auto;
    height: 32px;
    min-width: 0;
    padding: 0 12px;
    gap: 6px;
    border-radius: 9px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #9a9aa8;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--sc-border);
}

.chart-tool--action .ti {
    width: 15px;
    height: 15px;
    opacity: 0.9;
}

.chart-tool--action:hover {
    color: #ffffff;
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.10);
}

.chart-tool--action:hover .ti {
    color: var(--sc-accent-bright);
    opacity: 1;
}

.chart-tool--action.chart-tool--warning {
    color: #f5c86a;
    border-color: rgba(217, 154, 43, 0.30);
    background: rgba(217, 154, 43, 0.10);
}

.chart-tool--action:disabled {
    opacity: 0.38;
    cursor: default;
    background: transparent;
}

/* TradingView-style per-pane value legend (top-left of each pane). */
.chart-pane-legend {
    position: absolute;
    z-index: 11;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}

/* One stacked line (OHLC, then VWAP, then EMA …) */
.chart-pane-legend .cpl-row {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

/* OHLC row sits slightly larger; indicator rows a touch smaller */
.chart-pane-legend .cpl-row:first-child {
    font-size: 14px;
    gap: 6px;
}

.chart-pane-legend .cpl-row:not(:first-child) {
    font-size: 12px;
}

/* Lower-pane (VOL / RSI / TTM subpanes) legends stay compact. */
.chart-pane-legend.chart-pane-legend--lower,
.chart-pane-legend.chart-pane-legend--lower .cpl-row,
.chart-pane-legend.chart-pane-legend--lower .cpl-row:first-child,
.chart-pane-legend.chart-pane-legend--lower .cpl-row:not(:first-child) {
    font-size: 12px;
    gap: 5px;
}

.chart-pane-legend .cpl-tag {
    color: rgba(255, 255, 255, 0.72);
}

/* Compact red X used in place of a wide "Abbrechen" label. */
.chart-tool--cancel-x {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    color: var(--sc-danger);
    font-size: 18px;
    line-height: 36px;
    text-align: center;
    padding: 0;
}
.chart-tool--cancel-x:hover {
    background: rgba(229, 72, 77, 0.12);
    border-color: rgba(229, 72, 77, 0.30);
}

/* Abbrechen button next to Erstellen in alert-create form */
.chart-alarm-edit__cancel {
    background: transparent;
    border: 1px solid rgba(229, 72, 77, 0.45);
    border-radius: var(--sc-radius-sm);
    color: var(--sc-danger);
    padding: 8px 18px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    cursor: pointer;
    transition: all 0.12s ease;
    min-width: 120px;
}
.chart-alarm-edit__cancel:hover {
    background: rgba(229, 72, 77, 0.10);
    border-color: rgba(229, 72, 77, 0.70);
}

.chart-tool i { pointer-events: none; }

.chart-tool__count {
    position: absolute;
    top: 3px;
    right: 3px;
    min-width: 12px;
    height: 12px;
    padding: 0 3px;
    border-radius: 3px;
    background: var(--sc-accent);
    color: #06110a;
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    font-weight: 800;
    line-height: 12px;
}

/* ── Chart Container ── */

.chart-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #131316;
}

.chart-container::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    box-shadow:
        inset 0 16px 32px -16px rgba(0, 0, 0, 0.4),
        inset 0 -8px 24px -12px rgba(0, 0, 0, 0.25);
}

/* ── Indicator Panel ── */

.chart-indicator-panel {
    position: absolute;
    top: 56px;
    left: 50%;
    width: 236px;
    transform: translateX(-50%) translateY(-6px) scale(0.97);
    opacity: 0;
    background: rgba(22, 22, 25, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: var(--sc-radius-lg);
    z-index: 30;
    overflow: hidden;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow:
        0 14px 40px rgba(0, 0, 0, 0.70),
        0 1px 0 rgba(255, 255, 255, 0.04) inset;
    animation: sc-indicator-in 0.18s ease-out forwards;
}
.chart-indicator-panel.is-closing {
    animation: sc-indicator-out 0.14s ease-in forwards;
}
@keyframes sc-indicator-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(0.97); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0)    scale(1); }
}
@keyframes sc-indicator-out {
    from { opacity: 1; transform: translateX(-50%) translateY(0)    scale(1); }
    to   { opacity: 0; transform: translateX(-50%) translateY(-4px) scale(0.98); }
}

.chart-indicator-panel[hidden] {
    display: none;
}

.chart-indicator-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 10px 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: rgba(255, 255, 255, 0.62);
}

.chart-indicator-panel__list {
    display: grid;
    padding: 6px;
    gap: 2px;
}

.chart-indicator-item {
    width: 100%;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid transparent;
    border-radius: var(--sc-radius);
    background: transparent;
    color: rgba(255, 255, 255, 0.48);
    cursor: pointer;
    padding: 0 8px 0 10px;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chart-indicator-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.78);
}

.chart-indicator-item.active {
    background: var(--sc-accent-dim);
    border-color: var(--sc-accent-border);
    color: var(--sc-accent-bright);
}

.chart-indicator-item__name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.chart-indicator-item__toggle {
    min-width: 32px;
    height: 17px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--sc-border);
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--sc-text-dim);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chart-indicator-item__toggle::after {
    content: 'AUS';
}

.chart-indicator-item.active .chart-indicator-item__toggle {
    background: var(--sc-accent-dim);
    border-color: var(--sc-accent-border);
    color: var(--sc-accent-bright);
}

.chart-indicator-item.active .chart-indicator-item__toggle::after {
    content: 'AN';
}

/* Lower indicators: reorderable rows with a drag handle. */
.chart-indicator-panel__divider {
    height: 1px;
    margin: 5px 8px;
    background: rgba(255, 255, 255, 0.08);
}

.chart-indicator-panel__reorder {
    display: grid;
    gap: 2px;
}

.chart-indicator-item--lower .chart-indicator-item__name {
    flex: 1 1 auto;
}

.chart-indicator-item__arrows {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.chart-indicator-item__move-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 18px;
    padding: 0;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    cursor: pointer;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.12s ease, background 0.12s ease;
}
.chart-indicator-item__move-btn .ti {
    width: 12px;
    height: 12px;
    stroke-width: 2.4;
}

.chart-indicator-item__move-btn:hover:not(:disabled) {
    color: rgba(255, 255, 255, 0.90);
}

.chart-indicator-item__move-btn:disabled {
    color: rgba(255, 255, 255, 0.15);
    cursor: default;
}

/* ── Alert Panel — Redesigned ── */

.chart-alert-panel {
    position: absolute;
    bottom: 36px;
    right: 10px;
    width: 256px;
    max-height: 252px;
    background: rgba(22, 22, 25, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--sc-radius-lg);
    z-index: 20;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.70),
        0 1px 0 rgba(255, 255, 255, 0.04) inset;
    /* Collapsed by default — expands only when the alarm tool is active. */
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.98);
    transform-origin: bottom right;
    transition:
        opacity 0.16s ease,
        transform 0.16s ease,
        visibility 0.16s ease;
}

.chart-alert-panel.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.chart-alert-panel__header {
    padding: 9px 12px 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.20em;
    color: rgba(255, 255, 255, 0.28);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Pulse dot — amber for alarm identity */
.chart-alert-panel__header::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--sc-warning);
    flex-shrink: 0;
    animation: sc-pulse 2.8s ease-in-out infinite;
}

@keyframes sc-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

.chart-alert-panel__list {
    padding: 3px 0;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.06) transparent;
}

.chart-alert-panel__empty {
    padding: 16px 12px;
    font-size: 10px;
    color: var(--sc-text-ghost);
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.03em;
}

/* ── Alert Items ── */

.chart-alert-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    transition: background 0.12s ease;
    position: relative;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.chart-alert-item:last-child {
    border-bottom: none;
}

.chart-alert-item:hover {
    background: rgba(255, 255, 255, 0.025);
}

.chart-alert-item.inactive {
    opacity: 0.18;
}

.chart-alert-item.triggered {
    animation: sc-alert-flash 2.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes sc-alert-flash {
    0% {
        background: rgba(217, 154, 43, 0.22);
    }
    30% {
        background: rgba(217, 154, 43, 0.07);
    }
    100% {
        background: transparent;
    }
}

.chart-alert-item__info {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--sc-text);
    min-width: 0;
}

.chart-alert-item__direction {
    color: var(--sc-warning);
    font-size: 12px;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.85;
}

.chart-alert-item__price {
    font-weight: 600;
    letter-spacing: 0.01em;
    color: rgba(255, 255, 255, 0.85);
}

.chart-alert-item__label {
    color: var(--sc-text-dim);
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
}

.chart-alert-item__controls {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.chart-alert-item__recurring,
.chart-alert-item__delete {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    background: transparent;
    color: var(--sc-text-ghost);
    border-radius: var(--sc-radius-sm);
    cursor: pointer;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    transition: all 0.12s ease;
}

.chart-alert-item__recurring:hover {
    background: rgba(217, 154, 43, 0.08);
    border-color: rgba(217, 154, 43, 0.20);
    color: var(--sc-warning);
}

.chart-alert-item__delete:hover {
    background: rgba(229, 72, 77, 0.08);
    border-color: rgba(229, 72, 77, 0.25);
    color: var(--sc-danger);
}

/* ── Status Bar ── */

.chart-status-bar {
    height: 24px;
    min-height: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 14px;
    border-top: 1px solid var(--sc-border);
    background: #161619;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--sc-text-mid);
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.chart-status-bar span::before {
    content: '·';
    margin-right: 7px;
    opacity: 0.20;
    font-size: 12px;
    vertical-align: middle;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1;
}

.chart-status-bar span:first-child::before {
    display: none;
}

.chart-status-bar .chart-status-bar__warning {
    color: #f5c86a;
}

.chart-status-bar .chart-status-bar__ok {
    color: rgba(255, 255, 255, 0.42);
}

/* ── Color Picker Popover ── */

.chart-color-picker {
    position: absolute;
    z-index: 30;
    background: rgba(28, 28, 32, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: var(--sc-radius-lg);
    padding: 12px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.80);
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 204px;
    animation: sc-popover-in 0.14s ease-out;
}

@keyframes sc-popover-in {
    from { opacity: 0; transform: translateY(-3px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chart-color-picker[hidden] { display: none; }

.chart-color-picker__presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.chart-color-swatch {
    width: 100%;
    aspect-ratio: 1.3;
    border: 2px solid transparent;
    border-radius: var(--sc-radius-sm);
    cursor: pointer;
    transition: border-color 0.12s, transform 0.12s;
}

.chart-color-swatch:hover {
    transform: scale(1.10);
    border-color: rgba(255, 255, 255, 0.30);
}

.chart-color-swatch.active {
    border-color: rgba(255, 255, 255, 0.80);
    transform: scale(1.07);
}

.chart-color-picker__custom input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--sc-radius-sm);
    color: var(--sc-text);
    padding: 6px 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.04em;
    transition: border-color 0.12s;
    box-sizing: border-box;
}

.chart-color-picker__custom input:focus {
    outline: none;
    border-color: var(--sc-accent-border);
}

.chart-color-picker__section-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.24);
    margin-top: 2px;
}

.chart-linewidth-picker {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.chart-linewidth-option {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--sc-radius-sm);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.82);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 7px 0 6px;
    line-height: 1;
    transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.12s;
}

.chart-linewidth-option:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.07);
}

.chart-linewidth-option.active {
    border-color: rgba(255, 255, 255, 0.72);
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.98);
}

/* ── Drawings Manager Panel — Redesigned ── */

.chart-manager-panel {
    position: absolute;
    top: 46px;
    right: 0;
    bottom: 24px;
    width: 268px;
    background: rgba(20, 20, 23, 0.98);
    border-left: 1px solid rgba(255, 255, 255, 0.07);
    z-index: 25;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.55);
    opacity: 0;
    transform: translateX(100%);
    pointer-events: none;
    transition:
        opacity 0.18s ease,
        transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.chart-manager-panel.is-visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.chart-manager-panel.is-closing {
    opacity: 0;
    transform: translateX(100%);
    pointer-events: none;
}

.chart-manager-panel[hidden] { display: none; }

.chart-manager-panel__header {
    padding: 12px 14px 11px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.20em;
    color: rgba(255, 255, 255, 0.28);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chart-manager-panel__close {
    background: none;
    border: none;
    color: var(--sc-text-dim);
    font-size: 16px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.12s;
}

.chart-manager-panel__close:hover {
    color: var(--sc-text);
}

.chart-manager-panel__list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.06) transparent;
}

.chart-manager-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    transition: background 0.10s ease;
    border-left: 2px solid transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.chart-manager-item:last-child {
    border-bottom: none;
}

.chart-manager-item:hover {
    background: rgba(255, 255, 255, 0.025);
}

.chart-manager-item.selected {
    background: var(--sc-accent-dim);
    border-left-color: var(--sc-accent);
}

.chart-manager-item__icon {
    width: 20px;
    font-size: 13px;
    color: var(--sc-text-dim);
    text-align: center;
    flex-shrink: 0;
}

.chart-manager-item.selected .chart-manager-item__icon {
    color: rgba(255, 255, 255, 0.65);
}

.chart-manager-item__color {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.10);
}

.chart-manager-item__info {
    flex: 1;
    min-width: 0;
}

.chart-manager-item__type {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
}

.chart-manager-item.selected .chart-manager-item__type {
    color: rgba(255, 255, 255, 0.85);
}

.chart-manager-item__detail {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--sc-text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

.chart-manager-item__delete {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--sc-radius-sm);
    color: var(--sc-text-ghost);
    cursor: pointer;
    font-size: 12px;
    flex-shrink: 0;
    transition: all 0.12s ease;
}

.chart-manager-item__delete:hover {
    color: var(--sc-danger);
    border-color: rgba(229, 72, 77, 0.28);
    background: rgba(229, 72, 77, 0.06);
}

.chart-manager-empty {
    padding: 24px 14px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--sc-text-ghost);
    text-align: center;
    letter-spacing: 0.04em;
}

/* ── Alarm Edit Modal ── */

.chart-alarm-edit {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 35;
    background: rgba(24, 24, 28, 0.99);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: var(--sc-radius-lg);
    padding: 0;
    width: 296px;
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85);
    overflow: hidden;
    animation: sc-modal-in 0.18s ease-out;
}

@keyframes sc-modal-in {
    from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Fade-out: JS adds .is-closing for 180ms before setting [hidden]. */
.chart-alarm-edit.is-closing {
    animation: sc-modal-out 0.18s ease-in forwards;
}

@keyframes sc-modal-out {
    from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    to   { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
}

.chart-alarm-edit[hidden] { display: none; }

.chart-alarm-edit__header {
    padding: 13px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: rgba(255, 255, 255, 0.30);
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-alarm-edit__body {
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chart-alarm-edit__field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.chart-alarm-edit__field > span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--sc-text-dim);
}

.chart-alarm-edit__field input[type="number"],
.chart-alarm-edit__field input[type="text"],
.chart-alarm-edit__field select {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--sc-radius-sm);
    color: rgba(255, 255, 255, 0.85);
    padding: 9px 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    transition: border-color 0.12s;
}

.chart-alarm-edit__field input:focus,
.chart-alarm-edit__field select:focus {
    outline: none;
    border-color: var(--sc-accent-border);
}

.chart-alarm-edit__field select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='rgba(255,255,255,0.25)' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.chart-alarm-edit__field--row {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.chart-alarm-edit__field--row input[type="checkbox"] {
    accent-color: rgba(255, 255, 255, 0.7);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.chart-alarm-edit__actions {
    padding: 11px 16px 13px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.chart-alarm-edit__save {
    background: var(--sc-accent-dim);
    border: 1px solid var(--sc-accent-border);
    border-radius: var(--sc-radius-sm);
    color: var(--sc-accent-bright);
    padding: 8px 18px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    cursor: pointer;
    transition: all 0.12s ease;
}

.chart-alarm-edit__save:hover {
    background: rgba(16, 185, 129, 0.16);
    border-color: rgba(16, 185, 129, 0.50);
    color: #ffffff;
}

/* ── Scrollbars ── */

.chart-alert-panel__list::-webkit-scrollbar,
.chart-manager-panel__list::-webkit-scrollbar {
    width: 2px;
}

.chart-alert-panel__list::-webkit-scrollbar-track,
.chart-manager-panel__list::-webkit-scrollbar-track {
    background: transparent;
}

.chart-alert-panel__list::-webkit-scrollbar-thumb,
.chart-manager-panel__list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 1px;
}

.chart-alert-panel__list::-webkit-scrollbar-thumb:hover,
.chart-manager-panel__list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* ── Segmented Direction Toggle ── */

.chart-seg-toggle {
    display: flex;
    gap: 0;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--sc-border);
    border-radius: 10px;
    padding: 2px;
    height: 32px;
    box-sizing: border-box;
}

.chart-seg-btn {
    flex: 1;
    padding: 0 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #9a9aa8;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition:
        background 0.16s ease,
        color 0.16s ease;
    white-space: nowrap;
    position: relative;
}

.chart-seg-btn:hover {
    color: #ffffff;
}

.chart-seg-btn.active {
    background: rgba(16, 185, 129, 0.14);
    color: var(--sc-accent-bright);
}

.chart-seg-btn.active::after {
    content: none;
}

/* ── Custom Toggle Switch ── */

.chart-toggle-wrap {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.chart-toggle-track {
    display: block;
    width: 32px;
    height: 18px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 9px;
    position: relative;
    transition:
        background 0.20s ease,
        border-color 0.20s ease;
}

.chart-toggle-thumb {
    display: block;
    position: absolute;
    top: 3px;
    left: 3px;
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    transition:
        transform 0.20s cubic-bezier(0.16, 1, 0.3, 1),
        background 0.20s ease;
}

.chart-toggle-wrap.active .chart-toggle-track {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.30);
}

.chart-toggle-wrap.active .chart-toggle-thumb {
    transform: translateX(14px);
    background: #ffffff;
}

/* ── Custom Prompt Modal ── */

.chart-prompt-modal {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
}

.chart-prompt-modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.chart-prompt-modal[hidden] {
    display: none !important;
}

.chart-prompt-card {
    width: 300px;
    background: rgba(24, 24, 28, 0.99);
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: var(--sc-radius-lg);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
    transform: translateY(6px) scale(0.98);
    transition:
        transform 0.20s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.18s ease;
    opacity: 0;
}

.chart-prompt-modal.visible .chart-prompt-card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.chart-prompt-card__header {
    padding: 13px 16px 11px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.20em;
    color: rgba(255, 255, 255, 0.28);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chart-prompt-card__body {
    padding: 16px;
}

.chart-prompt-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: var(--sc-radius);
    color: #ffffff;
    padding: 10px 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.02em;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}

.chart-prompt-input:focus {
    border-color: var(--sc-accent-border);
    background: rgba(255, 255, 255, 0.06);
}

.chart-prompt-card__actions {
    padding: 0 16px 14px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.chart-prompt-btn {
    padding: 7px 18px;
    border-radius: var(--sc-radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    cursor: pointer;
    transition: all 0.12s ease;
    border: 1px solid transparent;
}

.chart-prompt-btn--cancel {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--sc-text-dim);
}

.chart-prompt-btn--cancel:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--sc-text-mid);
}

.chart-prompt-btn--confirm {
    background: var(--sc-accent-dim);
    border-color: var(--sc-accent-border);
    color: var(--sc-accent-bright);
}

.chart-prompt-btn--confirm:hover {
    background: rgba(16, 185, 129, 0.16);
    border-color: rgba(16, 185, 129, 0.50);
    color: #ffffff;
}
