/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-base: #0b0f19;
    --bg-card: #111827;
    --bg-inset: #0d1420;
    --bg-hover: #1a2233;
    --border: #1e293b;
    --border-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #475569;
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-dim: rgba(16, 185, 129, 0.12);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.12);
    --yellow: #f59e0b;
    --yellow-dim: rgba(245, 158, 11, 0.12);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== Layout ===== */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
}

/* ===== Market Event Alert Banner ===== */
.market-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
}

.market-alert .alert-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.market-alert .alert-body {
    flex: 1;
}

.market-alert .alert-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 2px;
}

.market-alert .alert-desc {
    color: var(--text-secondary);
}

.market-alert .alert-stat {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.market-alert .alert-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    flex-shrink: 0;
}

.market-alert .alert-close:hover {
    color: var(--text-primary);
}

.market-alert.alert-warn {
    background: var(--yellow-dim);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.market-alert.alert-warn .alert-title {
    color: var(--yellow);
}

.market-alert.alert-danger {
    background: var(--red-dim);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.market-alert.alert-danger .alert-title {
    color: var(--red);
}

.market-alert.alert-info {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.market-alert.alert-safe {
    background: var(--accent-dim);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.market-alert.alert-info .alert-title {
    color: #60a5fa;
}


/* ===== Economic Calendar ===== */
.calendar-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 11px;
    color: var(--text-secondary);
}

.cal-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.cal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cal-dot.danger { background: var(--red); }
.cal-dot.warn { background: var(--yellow); }
.cal-dot.safe { background: var(--accent); }
.cal-dot.info { background: #60a5fa; }

/* Calendar Legend Tooltips */
.cal-legend-item.has-tooltip {
    position: relative;
    cursor: help;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.cal-legend-item.has-tooltip:hover {
    background: var(--bg-hover);
}

.cal-tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 12px;
    line-height: 1.6;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.cal-legend-item.has-tooltip:hover .cal-tooltip {
    display: block;
}

.cal-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
}

.cal-tooltip.danger {
    background: #1a0f0f;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.cal-tooltip.danger::before {
    border-bottom-color: rgba(239, 68, 68, 0.3);
}

.cal-tooltip.warn {
    background: #1a1508;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.cal-tooltip.warn::before {
    border-bottom-color: rgba(245, 158, 11, 0.3);
}

.cal-tooltip.safe {
    background: #0a1a14;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.cal-tooltip.info {
    background: #0f1520;
    border: 1px solid rgba(96, 165, 250, 0.3);
}
.cal-tooltip.info::before {
    border-bottom-color: rgba(96, 165, 250, 0.3);
}

.cal-tooltip.safe::before {
    border-bottom-color: rgba(16, 185, 129, 0.3);
}

.cal-tooltip strong {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.cal-tooltip p {
    color: var(--text-secondary);
    margin: 0 0 6px 0;
}

.cal-tooltip-stat {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-secondary);
    padding: 2px 0;
}

.cal-tooltip-stat b {
    color: var(--text-primary);
}

.cal-tooltip-advice {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-primary);
}

.calendar-board {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.calendar-header-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}

.calendar-header-cell {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 4px 0;
}

.calendar-week-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-day {
    min-height: 60px;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
    font-family: var(--mono);
    font-size: 11px;
    position: relative;
    transition: border-color 0.15s;
}

.calendar-day:hover {
    border-color: var(--border-hover);
}

.calendar-day.today {
    border-color: var(--accent);
    background: rgba(16, 185, 129, 0.04);
}

.calendar-day.past {
    opacity: 0.4;
}

.calendar-day.empty {
    background: transparent;
    border-color: transparent;
    min-height: 0;
}

.calendar-day-num {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.calendar-day.today .calendar-day-num {
    color: var(--accent);
    font-weight: 700;
}

.calendar-event-pill {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 2px;
    line-height: 1.3;
    cursor: default;
}

.calendar-event-pill.danger {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.calendar-event-pill.warn {
    background: var(--yellow-dim);
    color: var(--yellow);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.calendar-event-pill.safe {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.calendar-event-pill .cal-pill-icon {
    font-size: 11px;
}

.calendar-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.calendar-event-pill[title] {
    cursor: help;
}

.calendar-week-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, border-color 0.15s;
}

.calendar-week-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.cal-toggle-arrow {
    font-size: 11px;
    color: var(--text-muted);
    width: 12px;
}

.cal-toggle-label {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-secondary);
}

.cal-toggle-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}

.cal-week-collapsed {
    display: none;
}

/* Calendar Event Popover */
.cal-popover {
    position: absolute;
    z-index: 200;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    animation: calPopIn 0.12s ease-out;
}

@keyframes calPopIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.cal-popover.danger { background: #1a0f0f; border: 1px solid rgba(239, 68, 68, 0.35); }
.cal-popover.warn { background: #1a1508; border: 1px solid rgba(245, 158, 11, 0.35); }
.cal-popover.safe { background: #0a1a14; border: 1px solid rgba(16, 185, 129, 0.35); }

.cal-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-primary);
    font-size: 13px;
}

.cal-popover-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
}

.cal-popover-close:hover { color: var(--text-primary); }

.cal-popover-stat {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Legend click active */
.cal-legend-item.has-tooltip.active .cal-tooltip {
    display: block;
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ===== Header ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

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

header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

/* 로고를 넣은 h1 — 텍스트가 아니라 이미지라 line-height 여백을 없앤다.
   높이만 지정하고 폭은 auto 로 둬 로고 비율(486:180)이 깨지지 않게 한다. */
header h1.brand { line-height: 0; }
.brand-logo {
    display: block;
    height: 32px;
    width: auto;
}

.header-symbols {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.header-symbols:empty { display: none; }

.header-coin {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 3px 8px 3px 4px;
    border-radius: 6px;
}

.header-coin img {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.symbol-checkboxes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.symbol-check {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    transition: all .15s;
}

.symbol-check:has(input:checked) {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-dim);
}

.symbol-check input { display: none; }

.symbol-check-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== Status Badge ===== */
.status-badge {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.status-badge.online { background: var(--accent-dim); color: var(--accent); }
.status-badge.offline { background: var(--red-dim); color: var(--red); }
.status-badge.cooldown { background: var(--yellow-dim); color: var(--yellow); }

/* ===== Dry Run Button ===== */
.btn-dry-run {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    transition: all 0.15s ease;
}

.btn-dry-run:hover {
    border-color: var(--border-hover);
    color: var(--text-secondary);
}

.btn-dry-run.active {
    border-color: var(--yellow);
    background: var(--yellow-dim);
    color: var(--yellow);
}

/* ===== Pause Button ===== */
.btn-pause {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.btn-pause:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    color: var(--yellow);
}

.btn-pause.paused {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
}

/* ===== Pause Banner ===== */
.pause-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    margin-bottom: 12px;
    background: var(--yellow-dim);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius);
    color: var(--yellow);
    font-size: 13px;
    font-weight: 500;
    animation: pausePulse 2s ease-in-out infinite;
}
.pause-banner-icon { font-size: 16px; }
.pause-banner-btn {
    margin-left: auto;
    background: var(--yellow);
    color: #000;
    border: none;
    padding: 4px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.pause-banner-btn:hover { opacity: 0.85; }
@keyframes pausePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===== Card ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: border-color 0.15s ease;
}

.card:hover { border-color: var(--border-hover); }

.card-wide { grid-column: span 2; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.card-header h2 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Collapsible Card (<details>/<summary> 기반, 기본 접힘) ===== */
.card-collapsible > summary {
    cursor: pointer;
    list-style: none;
}
.card-collapsible > summary::-webkit-details-marker { display: none; }
.card-collapsible > summary::after {
    content: '▾';
    margin-left: auto;
    padding-left: 8px;
    color: var(--text-muted);
    transition: transform 0.15s;
    flex-shrink: 0;
}
.card-collapsible[open] > summary::after { transform: rotate(180deg); }
.card-collapsible > summary:hover::after { color: var(--text-primary); }

/* ===== Tooltip ===== */
.tooltip-wrap {
    position: relative;
    display: inline-flex;
    margin-left: 6px;
}

.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    font-style: italic;
    cursor: help;
    transition: all 0.15s ease;
}

.tooltip-wrap:hover .tooltip-icon {
    background: var(--accent);
    color: #fff;
}

.tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 280px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.6;
    text-transform: none;
    letter-spacing: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 100;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
}

.tooltip-text::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 14px;
    border: 6px solid transparent;
    border-bottom-color: var(--border-hover);
}

.tooltip-wrap:hover .tooltip-text,
.tooltip-wrap.open .tooltip-text,
.tooltip-wrap:focus-within .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* 터치 기기: hover 없이 탭으로 열기 (static/js/common.js가 .open 토글) */
.tooltip-wrap.open .tooltip-icon {
    background: var(--accent);
    color: #fff;
}

/* ===== Balance ===== */
.balance-value {
    font-family: var(--mono);
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.5px;
}

.position-box {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--bg-inset);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: 13px;
    line-height: 1.7;
}

.position-box .long { color: var(--accent); font-weight: 600; }
.position-box .short { color: var(--red); font-weight: 600; }
.pos-symbol {
    display: inline-block;
    background: var(--border);
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    margin-right: 4px;
    letter-spacing: 0.5px;
}
.pos-coin-icon {
    width: 16px;
    height: 16px;
    vertical-align: -2px;
    margin-right: 3px;
    border-radius: 50%;
}
.pos-multi {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.pos-multi:last-child { border-bottom: none; }

/* ===== Colors ===== */
.pnl-positive { color: var(--accent); }
.pnl-negative { color: var(--red); }
.text-muted { color: var(--text-muted); }

/* ===== Stats ===== */
.stat-tabs, .card-tabs {
    display: flex;
    gap: 4px;
}

.stat-tab {
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .15s;
}

.stat-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.trade-coin {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-right: 2px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 4px;
    background: var(--bg-inset);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-family: var(--mono);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}
.stat-value.pnl-positive { color: var(--accent); }
.stat-value.pnl-negative { color: var(--red); }

.stat-unit {
    font-size: 10px;
    font-weight: 500;
    opacity: 0.5;
    margin-left: 2px;
    letter-spacing: 0.5px;
}

/* ===== Inputs ===== */
.input {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    transition: border-color 0.15s ease;
    outline: none;
    width: 100%;
}

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

.input::placeholder { color: var(--text-muted); }

/* Select */
.select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

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

.select option {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 8px;
}

.select-sm {
    padding: 4px 28px 4px 8px;
    font-size: 12px;
}

/* Symbol Select */
.symbol-select {
    font-size: 14px;
    font-weight: 500;
    padding: 10px 36px 10px 14px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
    background: var(--bg-inset);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-danger {
    background: var(--red);
    color: #fff;
    padding: 10px 28px;
    font-size: 14px;
    border-radius: var(--radius);
}

.btn-danger:hover { background: #dc2626; }

/* ===== Forms ===== */
.form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.form-row .input[type="number"] { width: 150px; flex-shrink: 0; }
.form-row .input[type="text"] { flex: 1; min-width: 100px; }

.form-grid-3col {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}

.form-grid-3col label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    font-weight: 500;
}

/* ===== Flatpickr Override ===== */
.flatpickr-calendar {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5) !important;
    font-family: var(--font) !important;
    max-width: calc(100vw - 24px) !important;
    overflow-x: hidden;
}

.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-weekdays,
span.flatpickr-weekday {
    background: var(--bg-card) !important;
    color: var(--text-secondary) !important;
}

.flatpickr-day {
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
}

.flatpickr-day:hover {
    background: var(--bg-hover) !important;
    border-color: var(--border-hover) !important;
}

.flatpickr-day.selected {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
}

.flatpickr-day.today {
    border-color: var(--accent) !important;
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: var(--text-muted) !important;
}

.flatpickr-time input,
.flatpickr-time .flatpickr-am-pm {
    background: var(--bg-inset) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    font-family: var(--mono) !important;
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    fill: var(--text-secondary) !important;
}

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
    fill: var(--text-primary) !important;
}

.numInputWrapper span {
    border-color: var(--border) !important;
}

.numInputWrapper span:hover {
    background: var(--bg-hover) !important;
}

.numInputWrapper span svg path {
    fill: var(--text-secondary) !important;
}

/* ===== Toggle Group ===== */
.toggle-group {
    display: flex;
    gap: 6px;
    background: var(--bg-inset);
    padding: 4px;
    border-radius: var(--radius);
}

.toggle-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.toggle-btn.active.long {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

.toggle-btn.active.short {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-dim);
}

/* ===== Lists ===== */
.list-scroll {
    max-height: 300px;
    overflow-y: auto;
}
.trades-scroll {
    overflow-y: auto;
}
.card-trades {
    display: flex;
    flex-direction: column;
}
.card-trades .trades-scroll {
    flex: 1;
    min-height: 0;
}

.list-scroll::-webkit-scrollbar, .trades-scroll::-webkit-scrollbar { width: 4px; }
.list-scroll::-webkit-scrollbar-track, .trades-scroll::-webkit-scrollbar-track { background: transparent; }
.list-scroll::-webkit-scrollbar-thumb, .trades-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.level-item, .trade-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.level-item:last-child, .trade-item:last-child { border-bottom: none; }

.level-item .type-support { color: var(--accent); font-weight: 500; }
.level-item .type-resistance { color: var(--red); font-weight: 500; }

.remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.remove-btn:hover { color: var(--red); background: var(--red-dim); }

.trade-clickable { cursor: pointer; transition: background 0.15s ease; }
.trade-clickable:hover { background: var(--bg-hover); }

.trade-item .win { color: var(--accent); font-family: var(--mono); font-weight: 600; font-size: 13px; }
.trade-item .loss { color: var(--red); font-family: var(--mono); font-weight: 600; font-size: 13px; }
.trade-item .long { color: var(--accent); font-weight: 600; }
.trade-item .short { color: var(--red); font-weight: 600; }

.trade-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 4px;
    vertical-align: middle;
}

.trade-badge.score { background: var(--yellow-dim); color: var(--yellow); }
.trade-badge.pattern { background: var(--accent-dim); color: var(--accent); }
.trade-badge.mode { background: var(--bg-inset); color: var(--text-muted); border: 1px solid var(--border); }
.trade-badge.safe-lock { background: rgba(59,130,246,0.12); color: #60a5fa; }
.trade-badge.time-stop { background: rgba(251,146,60,0.12); color: #fb923c; }

/* ===== Fibonacci ===== */
.fib-list { max-height: 400px; overflow-y: auto; }

.fib-item {
    padding: 14px;
    background: var(--bg-inset);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 8px;
}

.fib-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
}

.fib-header .remove-btn { margin-left: auto; }

.btn-calibrate {
    background: var(--yellow-dim);
    color: var(--yellow);
    border: 1px solid rgba(245, 158, 11, 0.2);
    padding: 3px 10px;
    border-radius: 4px;
    font-family: var(--font);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-calibrate:hover { background: rgba(245, 158, 11, 0.2); border-color: var(--yellow); }

.fib-points {
    display: flex;
    gap: 16px;
    margin-bottom: 10px;
    padding: 8px 10px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.fib-point {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.fib-point strong {
    color: var(--text-primary);
    font-family: var(--mono);
}

.fib-point small {
    color: var(--text-muted);
}

.fib-levels {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 4px;
}

.fib-level {
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 12px;
    font-family: var(--mono);
}

.fib-active { border-left: 3px solid var(--red); }
.fib-half { border-left: 3px solid var(--accent); opacity: 0.7; }

/* ===== Skills ===== */
.skills-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.skill-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-inset);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: border-color 0.15s ease;
}

.skill-item:hover { border-color: var(--border-hover); }

.skill-info { flex: 1; min-width: 0; }

.skill-name {
    font-weight: 600;
    color: var(--accent);
    font-size: 14px;
}

.skill-desc {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-install {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    margin-left: 12px;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.btn-install:hover { background: var(--accent-hover); }

.btn-installed {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    margin-left: 12px;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.btn-installed:hover { background: var(--red-dim); color: var(--red); border-color: rgba(239, 68, 68, 0.2); }

/* ===== Logs ===== */
.logs-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.log-container {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    height: 300px;
    overflow-y: auto;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.7;
}

.log-container::-webkit-scrollbar { width: 4px; }
.log-container::-webkit-scrollbar-track { background: transparent; }
.log-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.log-line { white-space: pre-wrap; word-break: break-all; }
.log-ts { color: var(--text-muted); }
.log-lv { font-weight: 700; margin: 0 4px; }
.log-name { color: var(--text-secondary); margin-right: 4px; }
.log-info { color: #b0bec5; }
.log-info .log-lv { color: var(--accent); }
.log-warn { color: var(--yellow); }
.log-warn .log-lv { color: var(--yellow); }
.log-error { color: var(--red); }
.log-error .log-lv { color: var(--red); }
.log-debug { color: var(--text-muted); }
.log-debug .log-lv { color: var(--text-muted); }

/* ===== Settings ===== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-item label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.setting-symbol { grid-column: span 2; }

.settings-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.save-status {
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
}

/* ===== Footer ===== */
.footer-actions {
    margin-top: 24px;
    text-align: center;
}

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 680px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.modal::-webkit-scrollbar { width: 4px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.modal-close:hover { color: var(--red); background: var(--red-dim); }

.modal-body {
    padding: 22px;
}

/* Modal: Trade Detail */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.detail-item {
    padding: 10px 14px;
    background: var(--bg-inset);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.detail-item .detail-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.detail-item .detail-value {
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-item.span-2 { grid-column: span 2; }

.detail-section {
    margin-bottom: 18px;
}

.detail-section h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.detail-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.detail-tag.green { background: var(--accent-dim); color: var(--accent); }
.detail-tag.red { background: var(--red-dim); color: var(--red); }
.detail-tag.yellow { background: var(--yellow-dim); color: var(--yellow); }
.detail-tag.muted { background: var(--bg-inset); color: var(--text-secondary); border: 1px solid var(--border); }

.detail-pnl-bar {
    position: relative;
    height: 32px;
    background: var(--bg-inset);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-top: 8px;
    overflow: hidden;
}

.detail-pnl-bar .bar-fill {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 0.3s ease;
}

.detail-pnl-bar .bar-label {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    padding: 0 8px;
    white-space: nowrap;
}

.detail-candle-chart {
    height: 200px;
    margin-top: 8px;
}

.detail-oi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-top: 6px;
}
.detail-oi-table th {
    text-align: left;
    padding: 4px 8px;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
}
.detail-oi-table td {
    padding: 4px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-family: var(--mono);
}

/* ===== Confirm Modal ===== */
.confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.confirm-overlay.open { display: flex; }

.confirm-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 28px 24px;
    width: 90%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: confirmIn 0.2s ease;
}

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

.confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.confirm-icon.danger {
    background: var(--red-dim);
    border: 2px solid rgba(239, 68, 68, 0.3);
}

.confirm-icon.warn {
    background: var(--yellow-dim);
    border: 2px solid rgba(245, 158, 11, 0.3);
}

.confirm-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.confirm-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.confirm-actions {
    display: flex;
    gap: 10px;
}

.confirm-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
}

.confirm-btn-cancel {
    background: var(--bg-inset);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.confirm-btn-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.confirm-btn-ok.danger {
    background: var(--red);
    color: #fff;
}

.confirm-btn-ok.danger:hover { background: #dc2626; }

.confirm-btn-ok.warn {
    background: var(--yellow);
    color: #000;
}

.confirm-btn-ok.warn:hover { background: #d97706; }

.confirm-btn-ok.info {
    background: #3b82f6;
    color: #fff;
}
.confirm-btn-ok.info:hover { background: #2563eb; }

.confirm-icon.info { color: #3b82f6; }

/* ===== Responsive ===== */

/* Tablet */
@media (max-width: 1024px) {
    .settings-grid { grid-template-columns: repeat(3, 1fr); }
    .fib-levels { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* Mobile */
@media (max-width: 768px) {
    .container { padding: 12px; }
    .grid { grid-template-columns: 1fr; gap: 12px; }
    .card-wide { grid-column: span 1; }
    .card { padding: 16px; overflow-x: auto; max-width: 100%; }
    .card table { font-size: 12px; }
    .card pre, .card code { word-break: break-all; white-space: pre-wrap; }

    /* Header */
    header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
        margin-bottom: 16px;
        padding-bottom: 14px;
    }
    header h1 { font-size: 17px; }
    .brand-logo { height: 27px; }
    .header-right {
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
    }
    .btn-dry-run { padding: 5px 8px; font-size: 10px; }
    .btn-pause { padding: 5px 10px; font-size: 12px; }

    /* Balance */
    .balance-value { font-size: 22px; }

    /* Stats */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .stat-value { font-size: 15px; }
    .stat-item { padding: 8px 4px; }

    /* Settings */
    .settings-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .setting-symbol { grid-column: span 2; }
    .settings-actions { grid-column: span 2; }

    /* Forms */
    .form-row {
        flex-direction: column;
        gap: 6px;
    }
    .form-row .input[type="number"] { width: 100%; }
    .form-row .input[type="text"] { width: 100%; }
    .form-grid-3col {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    .form-grid-3col label {
        grid-column: 1 / -1;
        margin-top: 4px;
    }
    .form-grid-3col input {
        width: 100%;
        min-width: 0;
    }

    /* Toggle */
    .toggle-btn { font-size: 12px; padding: 6px; }

    /* Fibonacci */
    .fib-points {
        flex-direction: column;
        gap: 6px;
        font-size: 11px;
    }
    .fib-levels { grid-template-columns: 1fr 1fr; gap: 3px; }
    .fib-level { font-size: 11px; padding: 4px 8px; }

    /* Logs */
    .log-container {
        height: 200px;
        padding: 10px;
        font-size: 11px;
    }
    .logs-controls { flex-wrap: wrap; gap: 6px; }

    /* Modal */
    .modal {
        width: 95%;
        max-height: 90vh;
    }
    .modal-header { padding: 14px 16px; }
    .modal-body { padding: 16px; }
    .detail-grid { grid-template-columns: 1fr; gap: 8px; }
    .detail-item.span-2 { grid-column: span 1; }
    .detail-item .detail-value { font-size: 14px; }

    /* Footer */
    .btn-danger { width: 100%; padding: 12px; }

    /* Tooltip — 모바일에서 잘리지 않도록 */
    .tooltip-text {
        left: auto;
        right: 0;
        width: 240px;
    }
    .tooltip-text::before {
        left: auto;
        right: 14px;
    }
}

/* Small mobile */
@media (max-width: 400px) {
    .container { padding: 8px; }
    .card { padding: 12px; }
    header h1 { font-size: 15px; }
    .brand-logo { height: 23px; }
    .balance-value { font-size: 20px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 13px; }
    .settings-grid { grid-template-columns: 1fr; }
    .setting-symbol { grid-column: span 1; }
    .settings-actions { grid-column: span 1; }
    .fib-levels { grid-template-columns: 1fr; }
    .header-right { gap: 4px; }
    .btn-dry-run { padding: 4px 6px; font-size: 9px; }
    .form-grid-3col { grid-template-columns: 1fr; }
    .form-grid-3col label { grid-column: 1; }
}

/* ==========================================================
   TOOLTIP (?)
   ========================================================== */
.tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-secondary);
    font-size: 9px;
    font-weight: 700;
    cursor: help;
    position: relative;
    vertical-align: middle;
    margin-left: 2px;
    flex-shrink: 0;
}
.tip:hover, .tip.open { background: var(--accent); color: #000; }
.tip:hover::after, .tip.open::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-hover);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
    width: 240px;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    pointer-events: none;
    text-transform: none;
    letter-spacing: 0;
}
.tip:hover::before, .tip.open::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border-hover);
    z-index: 101;
}

/* ==========================================================
   NAVIGATION
   ========================================================== */
.top-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    row-gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}
.nav-group { display: flex; gap: 4px; }
.nav-divider {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 8px;
    flex-shrink: 0;
}
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-link.active {
    color: var(--accent);
    background: var(--accent-dim);
}
.nav-icon { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.7; }
.nav-link:hover .nav-icon, .nav-link.active .nav-icon { opacity: 1; }

/* --- Reference Table Badges --- */
.ref-dir-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 3px;
    letter-spacing: 0.3px;
}
.ref-dir-badge.long { color: var(--accent); background: var(--accent-dim); }
.ref-dir-badge.short { color: var(--red); background: rgba(239,68,68,0.12); }
.ref-coin-icon {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 2px;
}
.ref-stat {
    display: inline-block;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.ref-stat.win { color: var(--accent); }

/* --- Mobile Bottom Navigation --- */
.bottom-nav { display: none; }
.bottom-sheet-overlay { display: none; }
.bottom-sheet { display: none; }
.ref-mobile { display: none; }
.ref-table-wrap { overflow-x: auto; }

@media (max-width: 768px) {
    .top-nav { display: none; }
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        padding: 6px 0;
        padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
        justify-content: space-around;
        align-items: center;
        /* iOS 키보드 닫힌 후 빈 공간 방지 */
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
    .bottom-nav-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 4px 12px;
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 10px;
        font-weight: 500;
        transition: color 0.15s;
        -webkit-tap-highlight-color: transparent;
    }
    .bottom-nav-link svg {
        width: 22px;
        height: 22px;
    }
    .bottom-nav-link.active {
        color: var(--accent);
    }
    .bottom-nav-more {
        background: none;
        border: none;
        font-family: inherit;
        -webkit-tap-highlight-color: transparent;
    }
    .bottom-nav-more.active-group { color: var(--accent); }

    /* "더보기" 바텀시트 (2026-08-15 — 시그널/BTC분석/ALGO-LAB/섀도매매/챌린지 수납) */
    .bottom-sheet-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        z-index: 1001;
    }
    .bottom-sheet-overlay.open { display: block; }
    .bottom-sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1002;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-bottom: none;
        border-radius: 18px 18px 0 0;
        padding: 10px 8px calc(16px + env(safe-area-inset-bottom, 0px));
        display: flex;
        flex-direction: column;
        gap: 2px;
        transform: translateY(100%);
        transition: transform 0.2s ease;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
    }
    .bottom-sheet.open { transform: translateY(0); }
    .bottom-sheet-handle {
        width: 36px;
        height: 4px;
        border-radius: 2px;
        background: var(--border);
        margin: 0 auto 10px;
    }
    .bottom-sheet-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        border-radius: var(--radius);
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 14px;
        font-weight: 500;
        -webkit-tap-highlight-color: transparent;
    }
    .bottom-sheet-link svg { width: 20px; height: 20px; flex-shrink: 0; }
    .bottom-sheet-link:active { background: var(--bg-hover); }
    .bottom-sheet-link.active { color: var(--accent); background: var(--accent-dim); }

    /* 하단 네비 높이만큼 본문 여백 (safe-area 포함) */
    .container {
        padding-bottom: calc(72px + env(safe-area-inset-bottom));
    }
    body {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
    html {
        height: -webkit-fill-available;
    }

    /* 레퍼런스 테이블 → 카드 전환 */
    .ref-desktop { display: none !important; }
    .ref-table-wrap { display: none; }
    .ref-mobile { display: flex; flex-direction: column; gap: 8px; }
    .ref-card {
        background: var(--bg-hover);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 10px 12px;
    }
    .ref-card-head {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 4px;
    }
    .ref-card-name { font-weight: 600; color: var(--text-primary); font-size: 13px; }
    .ref-card-dir { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 3px; }
    .ref-card-dir.short { color: var(--red); background: rgba(239,68,68,0.12); }
    .ref-card-dir.long { color: var(--accent); background: var(--accent-dim); }
    .ref-card-sym { font-size: 11px; color: var(--text-secondary); margin-bottom: 6px; }
    .ref-card-sym code { font-size: 10px; background: var(--bg-card); padding: 1px 4px; border-radius: 3px; }
    .ref-card-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.5; }
}

/* ==========================================================
   BACKTEST PAGE
   ========================================================== */
.bt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.bt-header h1 { font-size: 22px; font-weight: 700; }
.bt-header-status { display: flex; gap: 8px; }
.badge-info {
    background: var(--accent-dim);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--mono);
}
.badge-cached {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--mono);
}
.badge-fresh {
    background: var(--yellow-dim);
    color: var(--yellow);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--mono);
}

/* Settings */
.bt-settings { margin-bottom: 16px; overflow: visible; }
.bt-settings-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

/* 전략 ON/OFF 토글 바 */
.bt-toggle-bar {
    display: flex;
    gap: 16px;
    padding: 10px 16px;
    background: var(--bg-inset);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    align-items: center;
}
.bt-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.bt-toggle input { display: none; }
.bt-toggle-dot {
    width: 36px;
    height: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    position: relative;
    transition: background 0.2s, border-color 0.2s;
}
.bt-toggle-dot::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--text-secondary);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s, background 0.2s;
}
.bt-toggle input:checked + .bt-toggle-dot {
    background: var(--accent);
    border-color: var(--accent);
}
.bt-toggle input:checked + .bt-toggle-dot::after {
    transform: translateX(16px);
    background: #fff;
}
.bt-toggle input:checked ~ span:last-child,
.bt-toggle:has(input:checked) {
    color: var(--text-primary);
}

/* 전략별 설정 카드 (4열) */
.bt-strategy-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 0;
    padding: 12px 16px 16px;
}
.bt-strategy-card {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
}
.bt-strategy-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 6px;
    text-align: center;
    letter-spacing: 0.3px;
}
.bt-strategy-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
.bt-strategy-row label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
}
.bt-strategy-row input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 6px 8px;
    font-size: 13px;
    width: 100%;
    box-sizing: border-box;
}
.bt-strategy-row input:focus {
    outline: none;
    border-color: var(--accent);
}
@media (max-width: 1024px) {
    .bt-strategy-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .bt-strategy-grid { grid-template-columns: 1fr; }
}
.bt-field { display: flex; flex-direction: column; gap: 4px; }
.bt-field label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.bt-field input, .bt-field select {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--mono);
    width: 110px;
}
.bt-field input:focus, .bt-field select:focus {
    outline: none;
    border-color: var(--accent);
}
.bt-field input[type="date"] { width: 140px; }
.bt-field select { width: 90px; }
.bt-checks {
    display: flex;
    flex-direction: row !important;
    gap: 12px;
    align-items: center;
}
.bt-checks label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
}
.bt-checks input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
}

.btn-run {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 8px 24px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.btn-run:hover { background: var(--accent-hover); }
.btn-run:disabled { opacity: 0.5; cursor: not-allowed; }

/* Chart */
.bt-chart-wrap { margin-bottom: 16px; padding: 0 !important; }
#chart-container { width: 100%; height: 500px; overflow: hidden; }

/* Playback Controls */
.bt-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-inset);
}
.btn-ctrl {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.btn-ctrl:hover { border-color: var(--accent); color: var(--accent); }
.speed-group {
    display: flex;
    gap: 2px;
    margin-left: 8px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}
.btn-speed {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-speed:hover { color: var(--text-primary); }
.btn-speed.active { background: var(--accent); color: #000; }
.candle-counter {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: auto;
}
.candle-date {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
}

/* Bottom panels */
.bt-bottom {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 16px;
}

/* Stats */
.bt-stats h3 { font-size: 14px; font-weight: 600; }
.bt-stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.btn-stats-reset {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-stats-reset:hover { border-color: var(--accent); color: var(--accent); }
.bt-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.stat-label { font-size: 12px; color: var(--text-secondary); }
.stat-val { font-size: 13px; font-family: var(--mono); font-weight: 600; }

/* Trade list */
.bt-trades h3 { font-size: 14px; margin-bottom: 12px; font-weight: 600; }
.bt-trade-list {
    max-height: 400px;
    overflow-y: auto;
}
.bt-trade-row {
    display: grid;
    grid-template-columns: 55px 120px 100px 1fr 90px 130px;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.1s;
}
.bt-trade-row:hover { background: var(--bg-hover); }
.bt-trade-row.selected {
    background: rgba(251, 191, 36, 0.12);
    border-left: 3px solid #fbbf24;
    padding-left: 8px;
}
.trade-side {
    font-weight: 700;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    text-align: center;
}
.side-long { background: var(--accent-dim); color: var(--accent); }
.side-short { background: var(--red-dim); color: var(--red); }
.trade-time { font-family: var(--mono); color: var(--text-secondary); font-size: 11px; }
.trade-price { font-family: var(--mono); }
.trade-reason { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trade-reason-short { display: none; color: var(--text-secondary); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trade-close { color: var(--text-muted); font-size: 11px; }
.safe-lock-badge {
    display: inline-block;
    background: #f59e0b;
    color: #000;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
    letter-spacing: 0.5px;
}
.trade-pnl { font-family: var(--mono); font-weight: 600; text-align: right; }
.pnl-win { color: var(--accent); }
.pnl-loss { color: var(--red); }
.text-muted { color: var(--text-muted); }

/* Loading overlay */
.bt-loading {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.bt-loading-inner { text-align: center; }
.bt-loading-inner p { margin-top: 12px; font-size: 14px; }
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Backtest responsive */
@media (max-width: 900px) {
    .bt-bottom { grid-template-columns: 1fr; }
    /* 모바일: Trades를 Statistics 위에 배치 (사용자 피드백) */
    .bt-trades { order: 1; }
    .bt-stats { order: 2; }
    /* 모바일: 긴 trade-reason 대신 짧은 전략명(trade-reason-short) 표시 */
    .bt-trade-row { grid-template-columns: 48px 85px 80px 1fr auto auto; gap: 6px; font-size: 11px; }
    .trade-reason { display: none; }
    .trade-reason-short { display: inline; }
    .trade-close { font-size: 10px; }
    .trade-pnl { font-size: 11px; }
    #chart-container { height: 350px; }
    .bt-settings-grid { gap: 8px; }
    .bt-field input, .bt-field select { width: 90px; }
}
@media (max-width: 500px) {
    .bt-controls { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
    .candle-counter { margin-left: 0; }
    .btn-ctrl { width: 32px; height: 32px; font-size: 14px; }
    .speed-group { order: 10; }
    .candle-date { order: 11; width: 100%; }
    /* 좁은 폰: 가격/close 숨김 — 방향/시간/전략명/PnL만 */
    .bt-trade-row { grid-template-columns: 42px 72px 1fr auto; gap: 4px; font-size: 10px; }
    .trade-price, .trade-close { display: none; }
}

/* ==========================================================
   PERFORMANCE PAGES 공통 (algolab / calculator / trades_detail)
   2026-08-15 — TS-104: algolab.html에 있던 걸 calculator.html이 그대로
   복사해 쓰던 .al-* 체계 + 세 페이지가 각자 재구현하던 toolbar/state-box/
   sym-tabs/승패색 을 여기로 통합. 클래스명은 그대로 유지(HTML/JS 무변경) —
   각 페이지 embedded <style> 블록에서 이 규칙들만 제거.
   ========================================================== */
.al-grid { display: grid; gap: 12px; margin-bottom: 16px; }
.al-3 { grid-template-columns: repeat(3, 1fr); }
.al-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .al-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .al-3, .al-2 { grid-template-columns: 1fr; } }
.al-grid > * { min-width: 0; }
.al-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    min-width: 0;
    overflow: hidden;
}
.al-card h3 {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: .03em;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: none;
}
.al-big { font-size: 26px; font-weight: 700; font-family: var(--mono); line-height: 1.15; color: var(--text-primary); }
.al-unit { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-left: 2px; }
.al-sub { font-size: 11px; color: var(--text-muted); margin-top: 5px; line-height: 1.6; }
.al-pos { color: var(--accent); }
.al-neg { color: var(--red); }
.al-warn { color: var(--yellow); }
.al-dim { color: var(--text-muted); }

.al-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    white-space: nowrap;
}
.al-badge.live { background: var(--red-dim); border-color: var(--red); color: var(--red); }

.al-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; max-width: 100%; }
.al-tab {
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all .15s ease;
    white-space: nowrap;
}
.al-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.al-tab.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.al-gate { display: flex; flex-direction: column; gap: 8px; }
.al-gate-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-inset);
    border: 1px solid var(--border);
}
.al-gate-row.ok { border-color: var(--accent); background: var(--accent-dim); }
.al-gate-name { font-size: 12px; color: var(--text-primary); }
.al-gate-val { font-family: var(--mono); font-size: 12px; white-space: nowrap; }

.al-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--bg-inset);
    overflow: hidden;
    margin-top: 8px;
    border: 1px solid var(--border);
}
.al-bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s ease; }

.al-scroll { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; max-width: 100%; position: relative; }
.al-scroll::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 24px; height: 100%;
    pointer-events: none;
    background: linear-gradient(to right, transparent, var(--bg-card));
}
@media (min-width: 900px) { .al-scroll::after { display: none; } }

table.al { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 520px; }
table.al th, table.al td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
table.al th:first-child, table.al td:first-child { text-align: left; }
table.al thead th { color: var(--text-muted); font-weight: 600; font-size: 11px; position: sticky; top: 0; background: var(--bg-card); }
table.al tbody tr:hover { background: var(--bg-hover); }
table.al td.mono { font-family: var(--mono); }

.al-chip {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 10px;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    margin: 2px 4px 2px 0;
    font-family: var(--mono);
}
.al-note {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.7;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.al-note b { color: var(--text-secondary); }
.al-empty { text-align: center; padding: 44px 16px; color: var(--text-muted); font-size: 13px; line-height: 1.9; }

.al-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.al-title h1 { margin: 0; font-size: 20px; line-height: 1.3; }
.al-title .al-sub { margin-top: 3px; }
.al-ctrl { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; flex: 0 0 auto; }
.al-ctrl > * { flex: 0 0 auto; width: auto; }
.al-ctrl .btn { width: auto; min-width: 0; }

@media (max-width: 640px) {
    .al-card { padding: 14px; }
    .al-big { font-size: 23px; }
    .al-title h1 { font-size: 17px; }
    .al-ctrl { width: 100%; justify-content: space-between; flex-wrap: wrap; row-gap: 6px; }
    .al-tab { flex: 1 1 0; min-width: 0; text-align: center; padding: 8px 6px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
    table.al { min-width: 440px; }
    .al-badge { font-size: 10px; padding: 4px 9px; }
    .al-ctrl .btn { font-size: 12px; padding: 5px 10px; }
    .al-note { font-size: 10.5px; }
}

/* 성과 페이지 공통 툴바/상태박스/심볼탭 (calculator.html · trades_detail.html) */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; gap: 10px; }
.toolbar-ts { font-size: 11px; color: var(--text-muted); }
.refresh-btn {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    transition: all .15s;
}
.refresh-btn:hover { color: var(--text-primary); border-color: var(--border-hover); }
.refresh-btn.loading { opacity: .5; pointer-events: none; }

.state-box {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 13px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.state-box p { margin: 6px 0; }

.sym-tabs { display: flex; gap: 6px; }
.sym-tab {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    transition: all .15s;
}
.sym-tab.active { color: var(--text-primary); border-color: var(--border-hover); background: var(--bg-card); }

/* 원래 각 페이지가 하드코딩해 쓰던 값 그대로 유지 (--accent/--red 와 미묘하게 다른 별도 톤 —
   의도적 팔레트 변경 아님, 통합 과정에서 임의로 맞추지 않음) */
.side-long { color: #3cbe82; font-weight: 700; }
.side-short { color: #f05a5a; font-weight: 700; }

/* ==========================================================
   MANUAL 전략 페이지 공통 (manual_ll_hh / manual_three_black_crows /
   manual_ma_rebound / manual_ichi_span / manual_trendline / manual_double_top)
   2026-08-15 — TS-104 Phase F: ll_hh/three_black_crows/ma_rebound 3개 페이지가
   .manual-card·.strategy-hint를 HTML에서 쓰면서 CSS 정의가 어디에도 없어
   카드/설명박스가 전부 무스타일로 렌더되던 실제 버그 발견 → 공통 정의로 수정.
   나머지(symbol-tabs/toggle-row/param-badge/info-grid/backtest-table)는
   ichi_span/trendline/double_top이 각자 복사해 쓰던 순수 중복 제거.
   ========================================================== */
.manual-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}
.manual-card h3 { font-size: 14px; font-weight: 700; color: var(--text-primary); margin: 0 0 14px; }

.strategy-hint {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 16px;
    line-height: 1.7;
}
.strategy-hint span { color: var(--accent); font-weight: 600; }

.symbol-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.symbol-tab {
    padding: 6px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background .15s, color .15s, border-color .15s;
}
.symbol-tab.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.symbol-tab:hover:not(.active) { background: var(--bg-hover); }

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-info { display: flex; flex-direction: column; gap: 4px; }
.toggle-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.toggle-sub { font-size: 12px; color: var(--text-muted); }

.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle-state { font-size: 13px; color: var(--text-muted); min-width: 28px; text-align: right; }
.toggle-state.on { color: var(--accent); font-weight: 600; }
.toggle-label { font-size: 13px; color: var(--text-secondary); }
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--bg-inset); border: 1px solid var(--border);
    border-radius: 24px; transition: .2s;
}
.toggle-slider::before {
    content: ""; position: absolute; width: 16px; height: 16px;
    left: 3px; bottom: 3px; background: var(--text-muted);
    border-radius: 50%; transition: .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent-dim); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); background: var(--accent); }
.toggle-switch input:disabled + .toggle-slider { opacity: .5; cursor: not-allowed; }

.param-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.param-badge {
    font-size: 11px; font-weight: 600; padding: 3px 8px;
    border-radius: 4px; background: var(--bg-inset);
    color: var(--text-muted); font-family: 'JetBrains Mono', monospace;
}
.param-badge.long { background: rgba(34,197,94,.15); color: #4ade80; }
.param-badge.short { background: rgba(239,68,68,.15); color: #f87171; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.info-item { background: var(--bg-inset); border-radius: 8px; padding: 12px 14px; }
.info-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.info-value { font-size: 13px; font-weight: 600; color: var(--text-primary); font-family: 'JetBrains Mono', monospace; }

.backtest-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 12px; }
.backtest-table th {
    text-align: left; padding: 6px 8px;
    color: var(--text-muted); font-weight: 500;
    border-bottom: 1px solid var(--border);
}
.backtest-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}
.backtest-table tr:last-child td { border-bottom: none; }
.pos { color: #4ade80; }
.neg { color: #f87171; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.form-input {
    background: var(--bg-inset); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text-primary);
    font-size: 14px; padding: 8px 12px; outline: none;
    font-family: 'JetBrains Mono', monospace;
    transition: border-color .15s;
}
.form-input:focus { border-color: var(--accent); }

/* 섹션 구분 라벨 (2026-08-16 — manual_index.html에서 공용으로 승격,
   algolab.html/calculator.html의 카드 그룹핑에도 사용) */
.section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 28px;
    margin-bottom: 4px;
}
.section-label:first-child { margin-top: 0; }

/* ==========================================================
   SRC-CARD 요약 그리드 + 기록 테이블 공통 (calculator.html shadow-* /
   trades_detail.html td-*) — 2026-08-16, TS-104 Phase D2.
   클래스명은 그대로 두고(JS 무변경) 그룹 셀렉터로 중복 선언만 제거.
   페이지별 실제 차이(카드 최소폭 240/280px, 소스명 mono 폰트, 정렬 가능한
   th)는 각 파일에 작은 로컬 규칙으로 남김.
   ========================================================== */
.shadow-summary, .td-summary {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px; margin-bottom: 16px;
}
.shadow-src-card, .td-src-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 16px;
    cursor: pointer; transition: border-color .15s, background .15s;
}
.shadow-src-card:hover, .td-src-card:hover { border-color: var(--border-hover); }
.shadow-src-card.active, .td-src-card.active { border-color: var(--yellow, #e0b040); background: var(--bg-inset); }
.shadow-src-card.all-card, .td-src-card.all-card { display: flex; align-items: center; justify-content: center; }
.shadow-src-head, .td-src-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.shadow-src-name, .td-src-name { font-weight: 700; font-size: 13px; }
.shadow-src-stats, .td-src-stats { display: flex; gap: 14px; flex-wrap: wrap; }
.shadow-stat, .td-stat { display: flex; flex-direction: column; gap: 2px; }
.shadow-stat .k, .td-stat .k { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.shadow-stat .v, .td-stat .v { font-size: 16px; font-weight: 700; font-family: var(--mono); }

.shadow-table-wrap, .td-table-wrap {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow-x: auto;
}
.shadow-table, .td-table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 820px; }
.shadow-table th, .td-table th {
    text-align: left; padding: 10px 12px; color: var(--text-muted);
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.shadow-table td, .td-table td {
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    font-family: var(--mono); white-space: nowrap; vertical-align: top;
}
.shadow-table tr:last-child td, .td-table tr:last-child td { border-bottom: none; }

.res-badge, .badge {
    display: inline-block; padding: 2px 8px; border-radius: 10px;
    font-size: 10.5px; font-weight: 700; font-family: var(--font);
}

/* ===== 알림 토스트 =====
   사용자가 준 참고 디자인(Coinness 알림 카드)의 구조를 그대로 따른다:
   ● 출처 라벨 / 우측 경과시간 · 굵은 제목 · 2줄 말줄임 본문 · 하단 닫기·보기 텍스트 버튼.
   좌측 등급 스트립과 진행 게이지는 뺐다 — 참고 디자인에 없고, 요소가 늘수록 읽기 느려진다.
   생명주기(위치·스택·자동소멸·a11y)는 Toastify-JS 가 맡는다. */
.toastify.tmt-shell {
    background: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
    max-width: min(400px, calc(100vw - 32px));
    /* 등장은 우리 keyframes, 소멸은 라이브러리가 .on 을 뗄 때의 opacity 전환.
       ⚠️ 등장 keyframes 에서 opacity 를 건드리면 animation 이 transition 을 이겨
       페이드아웃이 먹히지 않는다 → transform 만 다룬다.
       ⚠️ `:not(.on)` 로 소멸 모션을 걸면 삽입 직후에도 매칭돼(아직 .on 이 없음)
       사라지는 모션이 먼저 재생된다. 쓰지 않는다. */
    /* 사라질 때는 **희미하게** — 투명도만 뚝 떨어뜨리지 않고 살짝 가라앉으며 흐려진다.
       Toastify 는 .on 을 뗀 뒤 400ms 후 DOM 에서 지우므로 그 안에 끝나야 잘리지 않는다.
       ⚠️ 여기에 animation 을 쓰면 안 된다 — `:not(.on)` 은 **삽입 직후에도** 매칭돼
       (아직 .on 이 없음) 사라지는 모션이 먼저 재생된다. transition 은 시작 상태로만
       쓰이므로 안전하다. */
    /* ⚠️ 껍데기(.toastify)의 transform 은 건드릴 수 없다 — Toastify 가 오프셋용으로
       **인라인 style.transform 을 직접 박기 때문에**(실측: "translate(0px, 0px)")
       클래스 규칙이 항상 진다. 움직임은 안쪽 카드(.tmt)에 건다. */
    transition: opacity .36s ease-out, filter .36s ease-out;
}
.toastify.tmt-shell:not(.on) { opacity: 0; filter: blur(3px); }
.toastify.tmt-shell.on      { opacity: 1; filter: blur(0); }

/* 등장/소멸 움직임은 인라인 간섭이 없는 안쪽 카드에서 처리한다 */
.tmt { transition: transform .36s ease-out; }
.toastify.tmt-shell:not(.on) .tmt { transform: translateY(8px) scale(.985); }
.toastify.tmt-shell .tmt { animation: tmt-in .34s cubic-bezier(.18, 1.1, .32, 1); }
@keyframes tmt-in {
    from { transform: translateY(16px) scale(.97); }
    to   { transform: translateY(0)    scale(1); }
}

.tmt {
    padding: 14px 16px 10px;
    border-radius: 11px;
    border: 1px solid rgba(148, 163, 184, .14);
    background: #232936;                 /* 참고 디자인의 밝은 슬레이트 카드 */
    box-shadow: 0 14px 36px rgba(0, 0, 0, .5);
    text-align: left;
}

/* ── 머리: ● 출처 ............ 경과시간 ── */
.tmt-head { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.tmt-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent); flex-shrink: 0;
}
.tmt-warn     .tmt-dot { background: var(--yellow); }
.tmt-critical .tmt-dot { background: var(--red); }
.tmt-src {
    font-size: 12px; font-weight: 600;
    color: var(--accent);
}
.tmt-warn     .tmt-src { color: var(--yellow); }
.tmt-critical .tmt-src { color: var(--red); }
.tmt-time {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.tmt-title {
    font-size: 14px; font-weight: 700; line-height: 1.42;
    color: #f8fafc;
    font-variant-numeric: tabular-nums;   /* 금액 자릿수가 흔들리지 않게 */
}
/* 본문은 2줄까지만 — 참고 디자인처럼 넘치면 말줄임. 알림은 요약이지 본문이 아니다. */
.tmt-body {
    margin-top: 5px;
    font-size: 12.5px; line-height: 1.5;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── 동작: 닫기 / 보기 ── */
.tmt-acts { display: flex; align-items: center; gap: 18px; margin-top: 11px; }
.tmt-act {
    background: none; border: 0; padding: 2px 0; cursor: pointer;
    font-family: inherit; font-size: 13px; font-weight: 600;
    color: var(--text-muted);
    transition: color .12s;
}
.tmt-act:hover { color: var(--text-secondary); }
.tmt-act-primary { color: var(--accent); }
.tmt-act-primary:hover { color: var(--accent-hover); }
.tmt-warn     .tmt-act-primary { color: var(--yellow); }
.tmt-critical .tmt-act-primary { color: var(--red); }

@media (prefers-reduced-motion: reduce) {
    .toastify.tmt-shell { animation: none; }
}
@media (max-width: 768px) {
    /* 하단 내비게이션에 가리지 않게 더 띄운다 */
    .toastify.tmt-shell { bottom: 78px !important; }
}

/* ===== 스크롤바 (전역 기본값) =====
   브라우저 기본 스크롤바는 밝은 회색 덩어리라 어두운 패널 위에서 튄다.
   표준 속성(scrollbar-width/color)과 WebKit 의사요소를 **둘 다** 쓴다 —
   표준만 쓰면 hover·모서리·라운드를 못 만지고, WebKit 만 쓰면 파이어폭스가 기본값이다
   (MDN "CSS scrollbars styling" 권장). 이미 있는 .list-scroll / .log-container /
   .modal 의 4px 규칙은 더 구체적이라 그대로 살아남는다 — 의도된 값이라 건드리지 않았다. */
/* ⚠️ 표준 속성과 WebKit 의사요소를 **같은 요소에 함께 쓰면 안 된다**.
   scrollbar-color 는 상속되므로 html 에 주면 모든 요소가 표준 스크롤바로 전환되고,
   Chrome 은 그 순간 ::-webkit-scrollbar 를 통째로 무시한다(실측: 의도한 10px 대신
   기본 15px 이 나왔다). 그래서 WebKit 을 기본으로 쓰고, 의사요소를 모르는 브라우저
   (파이어폭스)만 @supports 로 걸러 표준 속성을 준다. */
@supports not selector(::-webkit-scrollbar) {
    html {
        scrollbar-width: thin;
        scrollbar-color: rgba(148, 163, 184, .35) transparent;
    }
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, .38);
    border-radius: 8px;
    /* 투명 테두리 + content-box 로 트랙과 간격을 준다 — 실제보다 얇고 떠 보인다 */
    border: 3px solid transparent;
    background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, .62);
    background-clip: content-box;
}
/* 잡고 끄는 동안엔 브랜드색 — 지금 내가 스크롤 중이라는 걸 분명히 한다 */
*::-webkit-scrollbar-thumb:active {
    background: var(--accent);
    background-clip: content-box;
}
*::-webkit-scrollbar-corner { background: transparent; }
/* 위아래 화살표 버튼 제거 — 요즘 UI 에선 쓰지 않고 얇은 막대를 방해한다 */
*::-webkit-scrollbar-button { display: none; }

/* 스크롤이 생겼다 사라질 때 내용이 좌우로 흔들리지 않게 자리를 미리 잡아둔다 */
.panel-grid > .tm-panel > .acc-body,
.cluster-list { scrollbar-gutter: stable; }

/* ===== 시장 브리핑 카드 (2026-08-29) =====
   ⚠️ 알림 토스트(.tmt)와 **의도적으로 다르게** 생겼다. 사용자 지적: "뉴스 정보건이랑
   청산 정보 같은 알림이 같은 모양과 같은 위치에 뜨면 정보 혼란이 온다".
   구분 축을 셋 다 벌린다 — 위치(하단중앙 → **우하단**), 형태(슬레이트 카드 →
   **좌측 그라디언트 리본 + 진행 게이지**), 소리(똘롱 → **8비트 뽀로롱**).
   생명주기도 Toastify 를 쓰지 않고 직접 관리한다(라이브러리는 하단중앙 스택 전용). */
.tbf-stack {
    /* ⚠️ 9800 이면 /liquidation 전체보기 오버레이(z-index:9990)에 통째로 가려진다
       (2026-08-29 실측: 전체화면에서 브리핑이 안 보인다는 제보). 알림은 원래 알림층에
       떠야 하므로 토스트(Toastify, 2147483647) 바로 아래로 올린다. */
    position: fixed; right: 20px; bottom: 20px; z-index: 2147483646;
    display: flex; flex-direction: column; gap: 10px;
    align-items: flex-end; pointer-events: none;
}
.tbf {
    position: relative; overflow: hidden; pointer-events: auto;
    width: min(384px, calc(100vw - 40px));
    padding: 13px 15px 11px 18px;
    border-radius: 4px 12px 12px 4px;      /* 리본 쪽만 각지게 — 토스트의 균일 11px 와 구분 */
    border: 1px solid rgba(148,163,184,.16);
    border-left: 0;
    background: linear-gradient(145deg, rgba(19,24,34,.97), rgba(13,17,25,.97));
    backdrop-filter: blur(10px);
    box-shadow: 0 18px 44px rgba(0,0,0,.55), 0 0 0 1px rgba(56,189,248,.06);
    text-align: left;
}
/* 좌측 리본 — 브리핑의 정체성. 등급 색이 아니라 고정 그라디언트라
   "경보가 아니라 읽을거리"라는 신호를 준다. */
.tbf:before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: linear-gradient(180deg, #38bdf8, #818cf8 55%, #22d3ee);
}
/* 등장 시 한 번 훑고 지나가는 광택 — 시선을 끌되 반복되지 않는다 */
.tbf:after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(105deg, transparent 30%, rgba(125,211,252,.13) 47%, transparent 64%);
    transform: translateX(-130%);
}
.tbf.in:after { animation: tbf-sheen 1.15s .28s cubic-bezier(.4,0,.2,1); }
@keyframes tbf-sheen { to { transform: translateX(130%); } }

/* 우측에서 밀려들어오며 살짝 오버슈트 */
.tbf { opacity: 0; transform: translateX(120%) scale(.94); }
.tbf.in   { animation: tbf-in .52s cubic-bezier(.16,1.12,.3,1) forwards; }
.tbf.out  { animation: tbf-out .3s ease-in forwards; }
@keyframes tbf-in  { to   { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes tbf-out { from { opacity: 1; transform: translateX(0) scale(1); }
                     to   { opacity: 0; transform: translateX(30%) scale(.97); } }

.tbf-head { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.tbf-chip {
    font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: .1em;
    color: #7dd3fc; border: 1px solid rgba(56,189,248,.36); border-radius: 3px;
    padding: 2px 5px; line-height: 1; flex: none;
}
.tbf-tag { font-size: 11px; color: var(--text-secondary); font-weight: 600; }
.tbf-time { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--text-muted); }
.tbf-title {
    font-size: 13px; font-weight: 700; line-height: 1.5; color: var(--text-primary);
    letter-spacing: -.01em; margin-bottom: 5px;
}
.tbf-body {
    font-size: 11.5px; line-height: 1.72; color: var(--text-secondary);
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tbf-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.tbf-host { font-family: var(--mono); font-size: 10px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbf-act {
    margin-left: auto; background: none; border: 0; cursor: pointer; padding: 3px 2px;
    font-size: 11px; font-weight: 600; color: var(--text-muted); font-family: inherit;
}
.tbf-act:hover { color: var(--text-secondary); }
.tbf-act-go { color: #7dd3fc; margin-left: 0; }
.tbf-act-go:hover { color: #bae6fd; }
/* 남은 시간 게이지 — 토스트에는 없는 요소라 형태 구분에도 쓰인다 */
.tbf-gauge { position: absolute; left: 3px; right: 0; bottom: 0; height: 2px;
    background: linear-gradient(90deg, #38bdf8, #818cf8); transform-origin: left center; }
.tbf.in .tbf-gauge { animation: tbf-drain linear forwards; }
@keyframes tbf-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (prefers-reduced-motion: reduce) {
    .tbf, .tbf.in { animation: none; opacity: 1; transform: none; }
    .tbf.in:after, .tbf.in .tbf-gauge { animation: none; }
    .tbf.out { animation: none; opacity: 0; }
}
