:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --line: #dde3ea;
    --line-soft: #ebeff4;
    --text: #171f29;
    --muted: #66727f;
    --faint: #93a0ad;
    --up: #d13c3c;          /* 상승 = 빨강 (국내 시세 관례) */
    --up-bg: #fbeeee;
    --down: #2160c4;        /* 하락 = 파랑 */
    --down-bg: #ebf1fb;
    --flat: #66727f;
    --flat-bg: #eef1f4;
    --buy: #157a4c;
    --buy-bg: #e5f4ec;
    --hold: #8a6a12;
    --hold-bg: #f7f0da;
    --high: #b23a24;
    --high-bg: #fae8e3;
    --ink: #1c2836;         /* 상단바/강조 배경 */
    --link: #2458a6;
    --thead-bg: #f4f6f9;
    --row-hover: #f7fafd;
    --best-bg: #f2f9f4;
    --mono: ui-monospace, "SFMono-Regular", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

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

.wrap { width: min(1200px, calc(100% - 28px)); margin: 0 auto; }
.wrap.narrow { width: min(820px, calc(100% - 28px)); }

/* ================= top bar ================= */

.topbar {
    background: var(--ink);
    color: #dfe6ee;
    border-bottom: 3px solid #3b82f6;
}

.topbar .bar {
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 8px 18px;
    flex-wrap: wrap;
    padding: 6px 0;
}

.brand {
    color: #fff;
    font-weight: 800;
    text-decoration: none;
    font-size: 1.22rem;
    letter-spacing: 0.01em;
}

.brand .beta {
    margin-left: 7px;
    padding: 1.5px 7px;
    border-radius: 4px;
    background: #3b82f6;
    color: #fff;
    font-size: 0.64rem;
    font-weight: 700;
    vertical-align: 2.5px;
    letter-spacing: 0.06em;
}

.topbar nav { display: flex; gap: 4px; margin-right: auto; }

.topbar nav a {
    color: #aab6c4;
    text-decoration: none;
    padding: 5px 11px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.topbar nav a.on, .topbar nav a:hover { background: rgba(255,255,255,0.12); color: #fff; }

.updated {
    flex-basis: 100%;
    text-align: right;
    font-size: 0.73rem;
    color: #8b99a9;
    font-variant-numeric: tabular-nums;
    margin-top: -4px;
}

/* ---- 검색창 + 자동완성 ---- */

.searchbox { position: relative; flex: 0 1 250px; min-width: 160px; }

.searchbox input {
    width: 100%;
    min-height: 33px;
    padding: 0 12px;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 17px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    font: inherit;
    font-size: 0.85rem;
    outline: none;
}

.searchbox input::placeholder { color: #8b99a9; }
.searchbox input:focus { border-color: #3b82f6; background: rgba(255,255,255,0.12); }

.sug {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 50;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--panel);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.sug-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 9px 13px;
    border: 0;
    border-top: 1px solid var(--line-soft);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.86rem;
    text-align: left;
    cursor: pointer;
}

.sug-item:first-child { border-top: 0; }
.sug-item:hover { background: var(--row-hover); }
.sug-item b { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sug-item span { color: var(--faint); font-size: 0.75rem; white-space: nowrap; font-variant-numeric: tabular-nums; }

main { padding: 18px 0 52px; }

/* ================= summary strip ================= */

.summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
    margin-bottom: 14px;
}

.summary div { padding: 12px 18px 10px; }
.summary div + div { border-left: 1px solid var(--line-soft); }

.summary strong {
    display: block;
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.summary span {
    color: var(--muted);
    font-size: 0.75rem;
}

/* ================= sections ================= */

.sec { margin-bottom: 22px; }

.sec-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 14px;
    flex-wrap: wrap;
    margin-bottom: 9px;
}

.sec-head h2 {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.sec-head h2 small { color: var(--faint); font-size: 0.78rem; font-weight: 600; margin-left: 4px; }

.chips { display: flex; gap: 5px; flex-wrap: wrap; }

.chip {
    min-height: 30px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--panel);
    color: var(--muted);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.12s, color 0.12s;
}

.chip:hover { border-color: var(--faint); color: var(--text); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---- 인기 시세 카드 그리드 ---- */

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

.pcard {
    display: block;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--panel);
    padding: 13px 15px 11px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.12s, box-shadow 0.12s;
}

.pcard:hover {
    border-color: var(--faint);
    box-shadow: 0 2px 10px rgba(23, 31, 41, 0.06);
}

.pcard-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.rank-n {
    color: #2160c4;
    font-size: 1.02rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.pcard-name {
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.35;
    word-break: keep-all;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pcard-meta {
    color: var(--faint);
    font-size: 0.76rem;
    margin: 1px 0 8px;
}

.pcard-price {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.pcard-price .pp {
    font-size: 1.12rem;
    font-weight: 800;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.pcard .spark { width: 100%; height: 36px; }

/* ---- 무버 4패널 ---- */

.movers {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.mover {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 12px 14px 10px;
}

.mover h3 {
    margin: 0 0 8px;
    font-size: 0.84rem;
    font-weight: 750;
    padding-left: 9px;
    border-left: 3px solid var(--line);
}

.mover h3.mv-up { border-color: var(--up); color: var(--up); }
.mover h3.mv-down { border-color: var(--down); color: var(--down); }
.mover h3.mv-buy { border-color: var(--buy); color: var(--buy); }
.mover h3.mv-os { border-color: #7c4dbc; color: #7c4dbc; }

.mover ul { list-style: none; margin: 0; padding: 0; }

.mover li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6.5px 0;
    border-top: 1px solid var(--line-soft);
    font-size: 0.85rem;
}

.mover li:first-child { border-top: 0; }

.mover li a {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}

.mover li a:hover { color: var(--link); text-decoration: underline; }

.mover .m-price {
    color: var(--muted);
    
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.mover .none { color: var(--faint); }

.mv-note { margin: 8px 0 0; color: var(--faint); font-size: 0.72rem; }

/* ---- 출처 칩 ---- */

.src {
    display: inline-block;
    padding: 1.5px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.src-public { background: #e2f1f0; color: #0f766e; }
.src-mall { background: var(--flat-bg); color: var(--muted); }
.src-overseas { background: #efe8f9; color: #7c4dbc; }

/* ---- 보조 숫자/메타 ---- */

.subnum { display: block; color: var(--faint); font-size: 0.72rem; font-weight: 400; }
.big-sub { display: block; color: var(--muted); font-size: 0.78rem; margin: 2px 0 4px; }

.meta-line { margin: 0 0 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meta { color: var(--faint); font-size: 0.8rem; }
.meta b { color: var(--muted); font-weight: 650; }

.board .rank {
    width: 34px;
    text-align: center;
    color: var(--faint);
    
    font-weight: 700;
    font-size: 0.82rem;
}

.delta.good { color: var(--buy); background: var(--buy-bg); }
.delta.warn { color: var(--high); background: var(--high-bg); }

/* ================= controls ================= */

.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 14px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.tabs { display: flex; gap: 5px; flex-wrap: wrap; }

.tab {
    min-height: 33px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: var(--panel);
    color: var(--muted);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.12s, color 0.12s;
}

.tab:hover { border-color: var(--faint); color: var(--text); }
.tab.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.sort { color: var(--muted); font-size: 0.84rem; display: inline-flex; align-items: center; gap: 7px; }

.sort select {
    min-height: 33px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    font: inherit;
    font-size: 0.85rem;
    padding: 0 8px;
    color: var(--text);
}

/* ================= table ================= */

.table-scroll {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

table.board { width: 100%; border-collapse: collapse; font-size: 0.93rem; }

.board th, .board td {
    padding: 10px 13px;
    text-align: right;
    border-bottom: 1px solid var(--line-soft);
    white-space: nowrap;
    vertical-align: middle;
}

.board thead th {
    background: var(--thead-bg);
    color: var(--faint);
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    position: sticky;
    top: 0;
    z-index: 1;
}

.board .left { text-align: left; }
.board tbody tr:last-child td { border-bottom: 0; }
.board tbody tr:hover { background: var(--row-hover); }

.board .num {
    font-variant-numeric: tabular-nums;
    font-size: 0.93rem;
}

.board .strong { font-weight: 700; font-size: 0.95rem; }

.board td.name a {
    text-decoration: none;
    font-weight: 650;
    color: var(--text);
}

.board td.name a:hover { color: var(--link); text-decoration: underline; }

.board td.name small, .board td.seller small {
    display: block;
    color: var(--faint);
    font-size: 0.73rem;
    font-weight: 400;
    margin-top: 1px;
}

.board td.seller small { color: var(--muted); font-variant-numeric: tabular-nums; }

.board.slim td { padding: 7px 13px; }

.best-row { background: var(--best-bg); }
.best-row:hover { background: var(--best-bg); }

/* ---- 스파크라인 ---- */

.sparkcell { padding-top: 6px; padding-bottom: 6px; }

.spark { width: 104px; height: 30px; display: block; }
.spark polyline { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { stroke: none; }
.spark .sp-area { stroke: none; opacity: 0.10; }
.spark.sp-down polyline, .spark.sp-down circle { stroke: var(--down); fill: var(--down); }
.spark.sp-down circle { fill: var(--down); }
.spark.sp-down .sp-area { fill: var(--down); }
.spark.sp-up polyline { stroke: var(--up); }
.spark.sp-up circle { fill: var(--up); }
.spark.sp-up .sp-area { fill: var(--up); }

/* ---- 30일 범위 게이지 ---- */

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

.gauge {
    position: relative;
    width: 92px;
    height: 5px;
    border-radius: 3px;
    background: linear-gradient(90deg, #7fb69a, #d9dee5 45%, #d8a08f);
    flex: 0 0 auto;
}

.gauge-mark {
    position: absolute;
    top: 50%;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--ink);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
    transform: translate(-50%, -50%);
}

.gauge-label {
    color: var(--faint);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.range-panel { padding: 12px 16px; }
.range-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.range-row .gauge { width: min(420px, 50vw); height: 6px; }
.range-cap { color: var(--muted); font-size: 0.8rem; font-weight: 700; }

/* ---- 변동 필 ---- */

.delta {
    display: inline-block;
    padding: 2.5px 8px;
    border-radius: 5px;
    
    font-size: 0.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.delta em { font-style: normal; font-family: inherit; font-weight: 500; opacity: 0.75; font-size: 0.72rem; }
.delta.up { color: var(--up); background: var(--up-bg); }
.delta.down { color: var(--down); background: var(--down-bg); }
.delta.flat { color: var(--flat); background: var(--flat-bg); }

.up { color: var(--up); }
.down { color: var(--down); }
.buy-c { color: var(--buy); }
.muted { color: var(--muted); }

/* ---- 배지/태그 ---- */

.badge {
    display: inline-block;
    padding: 2.5px 10px;
    border-radius: 5px;
    font-size: 0.76rem;
    font-weight: 750;
    white-space: nowrap;
}

.badge.buy { background: var(--buy-bg); color: var(--buy); }
.badge.hold { background: var(--hold-bg); color: var(--hold); }
.badge.high { background: var(--high-bg); color: var(--high); }

.tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--muted);
    font-size: 0.69rem;
    vertical-align: 1px;
}

.tag.best { border-color: var(--buy); color: var(--buy); font-weight: 700; }

.cat-chip {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 9px;
    border-radius: 12px;
    background: var(--flat-bg);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    vertical-align: 4px;
}

.empty-note { color: var(--muted); padding: 18px 4px; }

/* ================= product detail ================= */

.crumb { margin: 2px 0 12px; color: var(--faint); font-size: 0.82rem; }
.crumb a { color: var(--faint); text-decoration: none; }
.crumb a:hover { color: var(--muted); text-decoration: underline; }

.quote-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 24px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.quote-title h1 {
    margin: 0 0 6px;
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    word-break: keep-all;
}

.reason { margin: 0; color: var(--muted); font-size: 0.9rem; }
.reason .badge { margin-right: 6px; vertical-align: 1px; }

.quote-price { text-align: right; }

.quote-price strong {
    display: block;
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.quote-price .delta { margin-top: 4px; }

.quote {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
    margin-bottom: 14px;
}

.quote div { padding: 10px 15px; }
.quote div + div { border-left: 1px solid var(--line-soft); }
.quote span { display: block; color: var(--faint); font-size: 0.73rem; }

.quote strong {
    font-variant-numeric: tabular-nums;
    
    font-size: 0.93rem;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 15px 17px;
    margin-bottom: 14px;
}

.panel h2 { margin: 0 0 10px; font-size: 1rem; font-weight: 750; }
.panel h3 { margin: 0 0 8px; font-size: 0.85rem; color: var(--muted); }
.panel .table-scroll { border: 0; border-top: 1px solid var(--line-soft); border-radius: 0; }

.chart-box { position: relative; height: 300px; }

.history-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ================= admin ================= */

.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.detail-head h1 { margin: 0; font-size: 1.3rem; }

.admin-form label { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 600; margin-bottom: 10px; }

.admin-form input, .admin-form select, .admin-form textarea {
    width: 100%;
    min-height: 38px;
    margin-top: 4px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
    font-size: 0.92rem;
}

.admin-form textarea { resize: vertical; }
.admin-form.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.admin-form.grid .wide, .admin-form.grid .btn { grid-column: span 2; }

.btn {
    min-height: 37px;
    padding: 0 17px;
    border: 0;
    border-radius: 6px;
    background: var(--ink);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.notice-ok {
    border: 1px solid #bfe0cd;
    background: var(--buy-bg);
    color: var(--buy);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.9rem;
}

.foot { border-top: 1px solid var(--line); padding: 16px 0 24px; color: var(--faint); font-size: 0.78rem; }


/* ================= 다크 모드 ================= */

:root[data-theme="dark"] {
    --bg: #12161c;
    --panel: #1a2029;
    --line: #2b3442;
    --line-soft: #232b37;
    --text: #e5eaf1;
    --muted: #9aa7b5;
    --faint: #6d7a89;
    --up: #ef6a6a;
    --up-bg: #3a2226;
    --down: #6b9fe8;
    --down-bg: #1e2b40;
    --flat: #9aa7b5;
    --flat-bg: #242c37;
    --buy: #4cc38a;
    --buy-bg: #1a3328;
    --hold: #d3ab3d;
    --hold-bg: #35301b;
    --high: #e8836b;
    --high-bg: #3a251e;
    --ink: #0e1319;
    --link: #7aa7e8;
    --thead-bg: #1f2733;
    --row-hover: #202834;
    --best-bg: #1c2f26;
}

:root[data-theme="dark"] .topbar { border-bottom-color: #2f6fd8; }
:root[data-theme="dark"] .src-public { background: #14332f; color: #5ec4b8; }
:root[data-theme="dark"] .src-overseas { background: #2b2140; color: #b18ae8; }
:root[data-theme="dark"] .pcard:hover { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4); }
:root[data-theme="dark"] .gauge { background: linear-gradient(90deg, #2e5c46, #3a4450 45%, #5c3a30); }
:root[data-theme="dark"] .chip.on, :root[data-theme="dark"] .tab.on { background: #2f6fd8; border-color: #2f6fd8; }
:root[data-theme="dark"] .btn { background: #2f6fd8; }
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background: var(--panel); color: var(--text); border-color: var(--line); }

.theme-btn {
    margin-left: 4px;
    min-width: 34px;
    min-height: 30px;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 6px;
    background: transparent;
    color: #dfe6ee;
    font-size: 0.95rem;
    cursor: pointer;
    line-height: 1;
}

.theme-btn:hover { background: rgba(255,255,255,0.12); }

/* ================= responsive ================= */

@media (max-width: 1000px) {
    .movers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
    .card-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 700px) {
    .hide-m { display: none; }
}

@media (max-width: 460px) {
    .hide-s { display: none; }
}

@media (max-width: 560px) {
    .movers { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
    .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .summary div:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
    .summary div:nth-child(3) { border-left: 0; }

    .quote { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .quote div:nth-child(n+4) { border-top: 1px solid var(--line-soft); }
    .quote div:nth-child(4) { border-left: 0; }

    .history-cols { grid-template-columns: 1fr; }
    .admin-form.grid { grid-template-columns: 1fr; }
    .admin-form.grid .wide, .admin-form.grid .btn { grid-column: span 1; }

    .quote-price { text-align: left; }
}

@media (max-width: 560px) {
    .board th, .board td { padding: 8px 10px; }
    table.board { font-size: 0.84rem; }
    .board .num { font-size: 0.86rem; }
    .summary strong { font-size: 1.15rem; }
    .summary div { padding: 10px 13px 8px; }
    .chart-box { height: 230px; }
    .quote-price strong { font-size: 1.55rem; }
    .spark { width: 88px; height: 26px; }
    .gauge { width: 76px; }
}

/* ================= 시세맵 푸터/문서 ================= */

.foot .wrap { display: block; }

.foot-links {
    display: flex;
    gap: 4px 16px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.foot-links a { color: var(--muted); text-decoration: none; font-size: 0.82rem; }
.foot-links a:hover { color: var(--text); text-decoration: underline; }

.panel h3 { margin: 16px 0 6px; font-size: 0.92rem; color: var(--text); }
.panel p { font-size: 0.92rem; line-height: 1.65; color: var(--muted); }
.panel p b { color: var(--text); }

.src-live { background: #e5f4ec; color: #157a4c; font-weight: 700; }
:root[data-theme="dark"] .src-live { background: #1a3328; color: #4cc38a; }

/* 예시(더미) 데이터 표시 + 준비 중 배너 */
.src-sample { background: var(--hold-bg); color: var(--hold); }

.dev-note {
    background: #fdf3d7;
    border-bottom: 1px solid #ecd9a0;
    color: #7a5e10;
    font-size: 0.8rem;
    padding: 7px 0;
}
.dev-note b { font-weight: 750; }
:root[data-theme="dark"] .dev-note { background: #322b14; border-bottom-color: #4a3f1c; color: #d3ab3d; }

/* 상품 이미지 (네이버쇼핑 수집) */
.pcard { position: relative; }
.pcard-img {
    position: absolute;
    top: 38px;
    right: 15px;
    width: 52px;
    height: 52px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--line-soft);
    background: #fff;
}
.pcard-name, .pcard-meta { padding-right: 62px; }

.detail-img {
    width: 86px;
    height: 86px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--line);
    background: #fff;
    flex: 0 0 auto;
}
@media (max-width: 560px) {
    .detail-img { width: 64px; height: 64px; }
}

/* 요약 타일 클릭 가능 표시 */
.summary [data-stat] { cursor: pointer; transition: background 0.12s; }
.summary [data-stat]:hover { background: var(--row-hover); }
.summary [data-stat].on { background: var(--row-hover); box-shadow: inset 0 -2px 0 #3b82f6; }
.summary [data-stat]:focus-visible { outline: 2px solid #3b82f6; outline-offset: -2px; }

/* 표 반응형: 폭이 좁아지면 덜 중요한 컬럼부터 접기 (가로 스크롤 최소화) */
@media (max-width: 1150px) {
    .hide-t { display: none; }
}
@media (max-width: 950px) {
    .hide-t2 { display: none; }
}

/* 긴 품목명 말줄임 — 품목 칸이 표를 밀어내지 않게 */
.board td.name { max-width: 300px; }
.board td.name a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.board td.name small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (max-width: 700px) {
    .board td.name { max-width: 190px; }
}

/* 요약 목록의 카테고리 구분 행 */
.cat-row td {
    background: var(--thead-bg);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
    padding: 6px 13px;
    text-align: left;
    white-space: nowrap;
}

/* ---- 관리자 대시보드 (비밀 경로 전용) ---- */
.notice-err { background: color-mix(in srgb, #e5484d 12%, transparent); border: 1px solid #e5484d55; color: var(--text); border-radius: 8px; padding: 10px 14px; font-size: 0.85rem; margin-bottom: 14px; }
.log-tail { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: 0.72rem; line-height: 1.7; overflow-x: auto; white-space: pre; color: var(--muted); }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.83rem; }
.plain-list li:last-child { border-bottom: none; }
.admin-form .btn { margin-right: 8px; margin-bottom: 8px; }

/* ---- 물가 읽기: 공시 보고서 ---- */
.ins-no { font-family: inherit; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.ins-list td.name a { font-weight: 600; }
.ins-doc { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--text); border-radius: 10px; padding: 30px 32px 24px; margin-bottom: 26px; }
.ins-doc-kind { font-size: 0.75rem; letter-spacing: 0.14em; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.ins-doc-head h1 { font-size: 1.32rem; line-height: 1.45; margin: 0 0 18px; }
.ins-doc-meta { width: 100%; border-collapse: collapse; border-top: 2px solid var(--text); border-bottom: 1px solid var(--line); font-size: 0.8rem; margin-bottom: 22px; }
.ins-doc-meta th { background: color-mix(in srgb, var(--text) 4%, transparent); color: var(--muted); font-weight: 600; text-align: left; padding: 8px 12px; width: 96px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ins-doc-meta td { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.ins-summary { background: color-mix(in srgb, var(--text) 3.5%, transparent); border-left: 3px solid var(--accent, #2160c4); border-radius: 6px; padding: 14px 18px; margin-bottom: 26px; }
.ins-summary h2 { font-size: 0.82rem; letter-spacing: 0.1em; color: var(--muted); margin: 0 0 8px; }
.ins-summary p { margin: 0; font-size: 0.9rem; line-height: 1.75; }
.ins-body { font-size: 0.92rem; line-height: 1.85; }
.ins-body h2 { font-size: 1.02rem; margin: 30px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.ins-body p { margin: 0 0 14px; }
.ins-body ul { margin: 0 0 14px; padding-left: 20px; }
.ins-body li { margin-bottom: 6px; }
.ins-num { font-variant-numeric: tabular-nums; }
.ins-num small { color: var(--muted); font-weight: 500; }
.ins-board { margin: 6px 0 18px; }
.ins-chart { margin: 18px 0 22px; }
.ins-chart .chart-box.small { height: 220px; }
.ins-chart figcaption { font-size: 0.76rem; color: var(--muted); margin-top: 8px; text-align: center; }
.ins-doc-foot { margin-top: 30px; border-top: 2px solid var(--text); padding-top: 14px; font-size: 0.76rem; color: var(--muted); line-height: 1.7; }
.ins-doc-foot p { margin: 0 0 8px; }
.ins-rel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.ins-rel-card { display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; text-decoration: none; color: var(--text); transition: border-color 0.15s; }
.ins-rel-card:hover { border-color: var(--accent, #2160c4); }
.ins-rel-card .name { font-size: 0.82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-rel-card .num { font-size: 0.95rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ins-rel-card .num small { color: var(--muted); font-weight: 500; }
.ins-teaser { display: block; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent, #2160c4); border-radius: 8px; padding: 12px 16px; text-decoration: none; color: var(--text); margin-bottom: 10px; }
.ins-teaser:hover { border-color: var(--accent, #2160c4); }
.ins-teaser .t-no { font-size: 0.72rem; color: var(--muted); margin-right: 8px; }
.ins-teaser .t-title { font-size: 0.86rem; font-weight: 600; }
@media (max-width: 700px) {
    .ins-doc { padding: 20px 16px 16px; }
    .ins-doc-meta th { width: 74px; }
    .ins-doc-meta tr { display: block; }
    .ins-doc-meta th, .ins-doc-meta td { display: inline-block; border-bottom: none; }
    .ins-doc-meta { border-bottom: 1px solid var(--line); padding-bottom: 6px; }
}
.panel .sub-h { font-size: 0.82rem; color: var(--muted); margin: 16px 0 8px; }
.vf-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.vf-chips .btn { font-size: 0.76rem; padding: 4px 12px; }
.vf-chips .btn.on { border-color: var(--accent, #2160c4); color: var(--accent, #2160c4); font-weight: 700; }

/* ============ UX 폴리시: 모바일 탭바·관심·마이크로 인터랙션 ============ */

/* 테마 전환을 부드럽게 (주요 표면만 — 전체 * 트랜지션은 무거움) */
body, .topbar, .panel, .pcard, .mover, .board, .foot, .tabbar, .summary > div {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.15s ease;
}

/* 숫자는 자릿수 정렬 (표에서 흔들리지 않게) */
.num, .pcard-price, .quote strong, .quote-price strong, .m-price, .summary strong {
    font-variant-numeric: tabular-nums;
}

/* 눌림 피드백 — 카드·버튼·타일 */
.pcard, .btn, .summary > div, .ins-teaser, .ins-rel-card, .chip, .tabbar a {
    transition: transform 0.12s ease, background-color 0.25s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.pcard:active, .summary > div:active, .ins-teaser:active, .ins-rel-card:active { transform: scale(0.98); }
.btn:active, .chip:active { transform: scale(0.95); }

/* 차트 부드러운 등장 */
@keyframes sm-fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.chart-box canvas { animation: sm-fade-up 0.45s ease both; }
@media (prefers-reduced-motion: reduce) {
    .chart-box canvas { animation: none; }
    .pcard, .btn, .summary > div, .tabbar a { transition: none; }
}

/* 관심(별) 버튼 */
.fav-btn { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 6px; border-radius: 8px; vertical-align: middle; }
.fav-btn:hover { color: #eab308; }
.fav-btn.on { color: #eab308; }
.fav-btn.big { font-size: 1.5rem; padding: 4px 8px; }
.fav-btn.row { font-size: 0.95rem; padding: 4px 6px 4px 0; }
.empty-fav { text-align: center; padding: 40px 16px; }
.empty-fav p:first-child { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }
.empty-fav .btn { margin: 12px 4px 0; }

/* 모바일 하단 탭바 */
.tabbar { display: none; }
@media (max-width: 700px) {
    .tabbar {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 999;
        background: var(--panel);              /* 불투명 기본 — 일부 브라우저의 fixed+블러 렌더 버그 회피 */
        border-top: 1px solid var(--line);
        padding: 6px 4px 8px;
        box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
    }
    .tabbar a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        padding: 6px 0 4px;
        min-height: 48px;                 /* 터치 타깃 */
        color: var(--muted);
        text-decoration: none;
        font-size: 0.66rem;
        font-weight: 600;
        border-radius: 10px;
    }
    .tabbar a svg { width: 22px; height: 22px; }
    .tabbar a.on { color: var(--accent, #2160c4); }
    .tabbar a:active { transform: scale(0.92); }
    body { padding-bottom: 72px; }   /* 탭바에 내용 안 가리게 */
    .foot { margin-bottom: 8px; }

    /* 모바일 숫자 위계: 현재가 크게, 부가정보 작게 */
    .quote-price strong { font-size: 1.7rem; }
    .pcard-price .pp { font-size: 1.12rem; font-weight: 800; }
    .board td.num.strong { font-weight: 700; }
    /* 터치 타깃 확대 */
    .board td { padding-top: 12px; padding-bottom: 12px; }
    .chips .chip { padding: 8px 14px; }
}

/* 모바일 헤더 압축: 로고 + 검색 + 테마 한 줄 (메뉴·갱신 문구는 하단 탭바가 대체) */
@media (max-width: 700px) {
    .topbar nav { display: none; }
    .topbar .updated { display: none; }
    .topbar .bar { flex-wrap: nowrap; align-items: center; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
    .topbar .brand { flex-shrink: 0; }
    .topbar .brand .beta { display: none; }
    .searchbox { flex: 1 1 auto; min-width: 0; }
    .theme-btn { flex-shrink: 0; }
}

/* 가로 넘침 방지 — 어떤 요소가 삐져나와도 레이아웃 폭은 화면 폭으로 고정 */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, video, canvas { max-width: 100%; }
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 12px 0 0; }
.pager small { margin-right: 8px; }
.pager .pg { min-width: 30px; text-align: center; padding: 4px 6px; border: 1px solid var(--line); border-radius: 7px; text-decoration: none; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.pager .pg.on { border-color: var(--down); color: var(--down); font-weight: 700; }
.pager .pg:hover { border-color: var(--faint); }
.stat-cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 8px 24px; align-items: start; }
@media (max-width: 900px) { .stat-cols { grid-template-columns: minmax(0, 1fr); } }
.stat-cols .board td { padding-top: 5px; padding-bottom: 5px; font-size: 0.78rem; }
.stat-cols .sub-h { margin-top: 8px; }

/* ---- 해외 비교 페이지 ---- */
.os-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 900px) { .os-top { grid-template-columns: minmax(0, 1fr); } }
.fx-now { font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; margin: 4px 0 10px; }
.fx-now small { font-size: 1rem; color: var(--muted); font-weight: 600; margin-left: 2px; }
.fx-panel .chart-box.small { height: 180px; }
.calc-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
@media (max-width: 560px) { .calc-form { grid-template-columns: minmax(0, 1fr); } }
.calc-out { background: color-mix(in srgb, var(--text) 4%, transparent); border-radius: 8px; padding: 10px 14px; margin: 4px 0 10px; }
.calc-out p { margin: 4px 0; font-size: 0.85rem; }
.calc-total strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
    #osTable td.name a { max-width: 132px; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
    #osTable td.name small { display: none; }           /* 단위(1개)는 모바일에서 생략 */
    #osTable td.num.strong { font-size: 0.82rem; }
    #osTable th, #osTable td { padding-left: 6px; padding-right: 6px; }
    #osTable .delta { padding: 2.5px 5px; font-size: 0.74rem; }
}
.fresh-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 76px; z-index: 1001; background: var(--ink); color: #fff; border-radius: 24px; padding: 10px 16px; font-size: 0.84rem; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,0.25); display: flex; align-items: center; gap: 10px; animation: sm-fade-up 0.3s ease; }
.fresh-toast button { background: #fff; color: var(--ink); border: none; border-radius: 16px; padding: 5px 12px; font-size: 0.8rem; font-weight: 700; cursor: pointer; }
@media (min-width: 701px) { .fresh-toast { bottom: 24px; } }
.brand-logo { vertical-align: -4px; margin-right: 7px; border-radius: 5px; }
.foot .copyright { margin-top: 8px; color: var(--faint); font-size: 0.72rem; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable::after { content: ' ↕'; opacity: 0.35; font-size: 0.8em; }
th.sortable[data-dir="asc"]::after { content: ' ▲'; opacity: 1; }
th.sortable[data-dir="desc"]::after { content: ' ▼'; opacity: 1; }
