:root {
    --ink: #374151;
    --muted: #6b7280;
    --line: #e5e7eb;
    --border: #d1d5db;
    --accent: #2563eb;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --head: #f9fafb;
    --warn: #b3261e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Pretendard", system-ui, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.6;
}

.wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

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

/* ---------- 공개 시세 페이지 ---------- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 22px 0 20px;
    text-align: center;
}

.logo-link {
    display: inline-block;
    line-height: 0;
}
.logo {
    height: 96px;
    width: auto;
    max-width: 100%;
}
@media (max-width: 480px) {
    .logo { height: 72px; }
}

.tagline {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

main.wrap { padding-top: 24px; padding-bottom: 48px; }

.page-title {
    margin: 0 0 16px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    text-align: center;
}

.quote-section {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
    overflow: hidden;
}

.section-header {
    background: var(--head);
    padding: 14px 16px;
    text-align: center;
    border-bottom: 1px solid var(--line);
}

.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
}

.table-container {
    overflow-x: auto;
    padding: 16px;
}

.quote-section table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    border: 1px solid var(--border);
    font-size: 0.92rem;
}

.quote-section col.col-price { width: 33%; }

.quote-section th,
.quote-section td {
    border: 1px solid var(--border);
    padding: 11px 12px;
}

.quote-section th {
    background: var(--head);
    font-weight: 600;
    text-align: center;
    color: var(--ink);
}

.quote-section th small {
    display: block;
    font-weight: 400;
    font-size: 0.8em;
    color: var(--muted);
    margin-top: 2px;
}

.quote-section td.name {
    color: var(--ink);
    white-space: normal;
    word-break: keep-all;
}

.quote-section td.price-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.quote-section .price {
    color: var(--accent);
    font-weight: 700;
}

.quote-section .percentage {
    font-size: 0.8em;
    color: var(--muted);
    margin-left: 4px;
}

/* 같은 분류 안에서 브랜드가 바뀌면 이름이 적힌 구분 행 */
.quote-section tbody tr.brand-row td {
    background: var(--head);
    text-align: center;
    font-weight: 700;
    color: var(--ink);
    padding: 8px 12px;
}
.quote-section tbody tr:not(.brand-row):hover td { background: #eef2f8; }

.empty {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin: 14px 0;
    text-align: center;
    color: var(--muted);
}

.site-footer {
    color: var(--muted);
    font-size: 0.82rem;
    border-top: 1px solid var(--line);
    padding-top: 16px;
    padding-bottom: 40px;
    text-align: center;
}
.site-footer a { color: var(--accent); }

.biz-info {
    margin: 16px auto 0;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    max-width: 640px;
    text-align: left;
    font-size: 0.78rem;
    line-height: 1.7;
    color: var(--muted);
}
.biz-info div {
    display: flex;
    gap: 8px;
}
.biz-info dt {
    flex: 0 0 104px;
    font-weight: 600;
    color: var(--ink);
}
.biz-info dd { margin: 0; }
@media (max-width: 480px) {
    .biz-info div { flex-wrap: wrap; gap: 2px 8px; }
}

/* "N원 이상 대량 판매는 별도 문의" 상시 안내 */
.bulk-notice {
    margin: 0 0 20px;
    padding: 11px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--head);
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.7;
    text-align: center;
    word-break: keep-all;
}
/* 핵심 어구만 또렷하게 */
.bulk-notice b { color: var(--ink); font-weight: 700; }
.bulk-notice .bn-amount {
    color: var(--accent);
    /* 형광펜 느낌의 옅은 밑줄 강조 */
    background: linear-gradient(transparent 58%, rgba(37, 99, 235, 0.16) 58%);
    padding: 0 2px;
}
.bn-tel {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.bn-tel:hover { text-decoration: underline; }
.calc-note .bn-tel { font-weight: 600; }
/* 계산기 경고(빨강) 박스 안에서는 같은 색으로 굵게만 */
.calc-notice b { font-weight: 800; }
.calc-notice a { color: inherit; font-weight: 700; text-decoration: underline; white-space: nowrap; }

/* ---------- 판매금액 계산기 (시세표 상단 접이식) ---------- */
.calc-box {
    margin: 0 0 18px;
}
.calc-open-btn {
    list-style: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 12px;
    color: #fff;
    /* 브랜드 블루 계열을 오가며 천천히 흐르는 그라데이션 */
    background: linear-gradient(115deg, #2563eb, #4f46e5, #0ea5e9, #2563eb);
    background-size: 280% 280%;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    animation: calc-drift 14s ease-in-out infinite, calc-glow 4s ease-in-out infinite;
}
/* 아이콘·문구·화살표는 광택(::after) 위로 */
.calc-open-btn > * { position: relative; z-index: 1; }
/* 6초에 한 번, 표면을 스치는 빛 */
.calc-open-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(100deg, transparent 40%, rgba(255, 255, 255, 0.38) 50%, transparent 60%);
    transform: translateX(-130%) skewX(-14deg);
    animation: calc-shimmer 6.5s ease-in-out infinite;
}
.calc-open-btn::-webkit-details-marker { display: none; }
.calc-open-btn:hover { transform: translateY(-1px); }
.calc-open-btn:active { transform: translateY(0); }

@keyframes calc-drift {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}
@keyframes calc-glow {
    0%, 100% { box-shadow: 0 4px 14px rgba(37, 99, 235, 0.24); }
    50%      { box-shadow: 0 8px 26px rgba(37, 99, 235, 0.46); }
}
@keyframes calc-shimmer {
    0%, 84%, 100% { transform: translateX(-130%) skewX(-14deg); }
    93%           { transform: translateX(130%) skewX(-14deg); }
}
@media (prefers-reduced-motion: reduce) {
    .calc-open-btn { animation: none; background-position: 0% 50%; }
    .calc-open-btn::after { display: none; }
}

.calc-open-icon { font-size: 1.7rem; line-height: 1; }
.calc-open-label { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.calc-open-label strong { font-size: 1.05rem; font-weight: 700; }
.calc-open-sub { font-size: 0.82rem; opacity: 0.9; font-weight: 400; word-break: keep-all; }
.calc-open-arrow {
    width: 0; height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 7px solid #fff;
    transition: transform 0.15s ease;
    flex: 0 0 auto;
}
.calc-box[open] .calc-open-arrow { transform: rotate(180deg); }
/* 펼쳐지면 시선 유도는 끝 — 애니메이션을 멈추고 차분한 단색 그라데이션으로 */
.calc-box[open] .calc-open-btn {
    border-radius: 12px 12px 0 0;
    box-shadow: none;
    animation: none;
    background: linear-gradient(135deg, var(--accent), #1d4ed8);
    background-size: auto;
}
.calc-box[open] .calc-open-btn::after { animation: none; opacity: 0; }

.calc-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 12px 12px;
    padding: 18px;
}

.calc-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.calc-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.calc-row-item {
    flex: 1 1 220px;
    min-width: 0;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font: inherit;
    background: var(--surface);
}

.calc-row-qty {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    color: var(--muted);
}
.calc-row-qty input {
    width: 72px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.calc-row-remove { flex: 0 0 auto; }

.calc-actions { margin: 16px 0 20px; }

.calc-result {
    overflow-x: auto;
    border-top: 1px solid var(--line);
    padding-top: 16px;
}
.calc-result table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
    font-size: 0.92rem;
    table-layout: fixed;
}
.calc-result col.col-qty { width: 64px; }
.calc-result col.col-price { width: 30%; }
.calc-result th,
.calc-result td {
    border: 1px solid var(--border);
    padding: 10px 12px;
}
.calc-result th {
    background: var(--head);
    font-weight: 600;
    text-align: center;
}
.calc-result td.name { word-break: keep-all; }
.calc-result td.price-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.calc-result td.qty-cell {
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.calc-result .price { color: var(--accent); font-weight: 700; }
.calc-result td.calc-empty {
    text-align: center;
    color: var(--muted);
}
.calc-result tfoot th {
    text-align: right;
}
.calc-result tfoot td {
    text-align: right;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    background: var(--head);
}

.calc-notice {
    margin: 14px 0 0;
    padding: 10px 14px;
    border: 1px solid var(--warn);
    border-radius: 6px;
    background: #fdf1f0;
    color: var(--warn);
    font-size: 0.86rem;
    font-weight: 600;
}

.calc-note {
    margin: 16px 0 0;
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.6;
}

/* ---------- 관리자 / 로그인 ---------- */
.site-header.admin { text-align: left; }
.site-header.admin .wrap {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.flash, .hint {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 14px 0;
}
.flash { border-color: var(--accent); color: var(--accent); }
.hint { color: var(--muted); font-size: 0.86rem; }
.muted { color: var(--muted); font-size: 0.82rem; }
.err { color: var(--warn); }

main.wrap .empty { margin: 14px 0; }

/* ---------- 관리자 시세 계산기 ---------- */
.admin-calc {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    margin: 16px 0 24px;
}
.admin-calc-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
    margin-bottom: 18px;
}
.admin-calc-controls label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.82rem;
    color: var(--muted);
}
.admin-calc-controls select,
.admin-calc-controls input {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font: inherit;
}
.admin-calc-controls select { min-width: 220px; }
.admin-calc-controls input[type="number"] { width: 96px; text-align: right; }

.admin-calc-result { overflow-x: auto; }
.admin-calc-result table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
    font-size: 0.9rem;
}
.admin-calc-result th,
.admin-calc-result td {
    border: 1px solid var(--border);
    padding: 9px 12px;
    text-align: left;
}
.admin-calc-result thead th { background: var(--head); text-align: right; }
.admin-calc-result thead th:first-child { text-align: left; }
.admin-calc-result tbody th { background: var(--head); font-weight: 600; white-space: nowrap; }
.admin-calc-result td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.admin-calc-result tr.muted-row td,
.admin-calc-result tr.muted-row th { color: var(--muted); }
.admin-calc-result #ac-d1, .admin-calc-result #ac-d2 { color: var(--accent); font-weight: 600; }
.admin-calc-result #ac-meta { margin: 10px 0 0; }

.status-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 20px;
}
.status-chip {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 10px;
    display: inline-flex;
    gap: 6px;
    align-items: center;
}
.status-chip .err { color: var(--warn); }

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin: 20px 0 24px;
}

.btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 0.88rem;
    cursor: pointer;
}
.btn.sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-link {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    text-decoration: underline;
}
form.inline { margin: 0; }

.bulk-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 24px;
}
.bulk-box h2 { margin: 0 0 12px; font-size: 1rem; }
.bulk-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}
.bulk-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.82rem;
    color: var(--muted);
}
.bulk-form input, .bulk-form select {
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
    font: inherit;
}
.bulk-form input[type="number"] { width: 96px; }
.bulk-box .hint { margin: 12px 0 0; padding: 0; border: none; background: none; }

.config-grid {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.config-head, .config-row {
    display: grid;
    grid-template-columns: minmax(170px, 2fr) 88px 96px 96px 84px 46px 64px;
    gap: 10px;
    align-items: center;
    padding: 8px 12px;
    font-size: 0.86rem;
}
.config-head {
    background: var(--head);
    color: var(--muted);
    font-size: 0.76rem;
}
.config-row {
    border-top: 1px solid var(--line);
    margin: 0;
}
.config-row input[type="number"] { width: 100%; }
.config-row .num { text-align: right; }

.cell-name { display: flex; flex-direction: column; gap: 2px; }
.cell-name .muted { font-size: 0.74rem; }
.cell-name .fees {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 2px;
}
.cell-name .fees .best {
    color: var(--accent);
    font-weight: 600;
}
.cell-name .apply-preview {
    margin-top: 3px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

input[type="number"], input[type="text"], input[type="password"] {
    padding: 5px 7px;
    border: 1px solid var(--line);
    border-radius: 5px;
    font: inherit;
}

.login-wrap { max-width: 340px; padding-top: 60px; }
.login-form { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }

/* ==================== 모바일 (≤ 640px) ==================== */
@media (max-width: 640px) {
    html { overflow-x: hidden; }
    .wrap { padding: 0 14px; }
    .site-header { padding: 16px 0 14px; }
    .tagline { font-size: 0.82rem; word-break: keep-all; }
    main.wrap { padding-top: 16px; padding-bottom: 32px; }

    /* iOS 가 입력창 포커스 시 확대하지 않도록 폼 컨트롤은 16px 이상 */
    input, select, textarea { font-size: 16px; }
    .btn { padding: 11px 16px; }

    /* ----- 공개 시세표: 행마다 카드 ----- */
    .table-container { padding: 0; }
    .quote-section table,
    .quote-section tbody,
    .quote-section tr,
    .quote-section td { display: block; }
    .quote-section thead { display: none; }
    .quote-section table { border: 0; }
    .quote-section col { width: auto; }
    .quote-section tbody { border-top: 1px solid var(--border); }

    .quote-section tbody tr.brand-row td {
        text-align: left;
        border: 0;
        border-bottom: 1px solid var(--line);
        padding: 9px 14px;
        font-size: 0.9rem;
    }
    .quote-section tbody tr:not(.brand-row) {
        padding: 12px 14px;
        border-bottom: 1px solid var(--line);
    }
    .quote-section tbody tr:not(.brand-row) td { border: 0; padding: 0; }
    .quote-section td.name { font-weight: 600; margin-bottom: 7px; }
    .quote-section td.price-cell {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 10px;
        text-align: left;
        padding: 3px 0;
    }
    .quote-section td.price-cell::before {
        color: var(--muted);
        font-size: 0.82rem;
        font-weight: 500;
        white-space: nowrap;
    }
    .quote-section td.price-cell:nth-of-type(2)::before { content: "매입가 (팔 때)"; }
    .quote-section td.price-cell:nth-of-type(3)::before { content: "판매가 (살 때)"; }
    .quote-section td.price-cell .pv { text-align: right; white-space: nowrap; }
    .quote-section .percentage { display: inline; margin-left: 4px; }
    .quote-section tbody tr:not(.brand-row):hover td { background: transparent; }

    /* ----- 판매금액 계산기 ----- */
    .calc-open-btn { padding: 14px 16px; gap: 12px; }
    .calc-open-icon { font-size: 1.5rem; }
    .calc-open-label strong { font-size: 1rem; }
    .calc-panel { padding: 14px; }
    .calc-row {
        gap: 8px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--head);
    }
    .calc-row-item { flex: 1 1 100%; }
    .calc-row-qty { flex: 1 1 auto; }
    .calc-row-qty input { flex: 1; width: auto; min-width: 84px; }
    .calc-row-remove { margin-left: auto; }

    .calc-result table,
    .calc-result tbody,
    .calc-result tfoot,
    .calc-result tr,
    .calc-result td,
    .calc-result th { display: block; }
    .calc-result thead { display: none; }
    .calc-result table { border: 0; }
    .calc-result col { width: auto; }
    .calc-result tbody tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 10px 12px;
        margin-bottom: 8px;
    }
    .calc-result tbody td { border: 0; padding: 2px 0; text-align: left; }
    .calc-result tbody td.name { font-weight: 600; margin-bottom: 4px; }
    .calc-result tbody td.price-cell,
    .calc-result tbody td.qty-cell {
        display: flex;
        justify-content: space-between;
        font-size: 0.9rem;
    }
    .calc-result tbody td::before { color: var(--muted); font-size: 0.82rem; }
    .calc-result tbody td.price-cell:nth-of-type(2)::before { content: "장당 매입가"; }
    .calc-result tbody td.qty-cell::before { content: "매수"; }
    .calc-result tbody td.price-cell:nth-of-type(4)::before { content: "받으실 금액"; font-weight: 600; }
    .calc-result tbody td.calc-empty { text-align: center; padding: 8px 0; }
    .calc-result tfoot tr {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        border: 0;
        border-top: 2px solid var(--border);
        margin-top: 4px;
        padding: 12px 2px 0;
    }
    .calc-result tfoot th,
    .calc-result tfoot td { padding: 0; border: 0; background: transparent; }

    /* ----- 관리자 상단 ----- */
    .site-header.admin .wrap { gap: 10px; }
    .site-header.admin h1 { font-size: 1.15rem; margin: 0; }
    .site-header.admin .wrap a,
    .site-header.admin .wrap button { white-space: nowrap; }
    .admin-actions { gap: 10px; margin: 16px 0 20px; }
    .admin-actions .btn { flex: 1 1 auto; text-align: center; }
    .bulk-form { flex-direction: column; align-items: stretch; }
    .bulk-form label { width: 100%; }
    .bulk-form input, .bulk-form select { width: 100%; }
    .bulk-form input[type="number"] { width: 100%; }

    /* ----- 관리자 권종 설정: 행마다 카드 + 항목 라벨 ----- */
    .config-head { display: none; }
    .config-grid { border: 0; background: transparent; border-radius: 0; overflow: visible; }
    .config-row {
        display: block;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 14px;
    }
    .config-row .cell-name { margin-bottom: 8px; }
    .config-row > span[data-label] {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        padding: 8px 0;
        border-top: 1px solid var(--line);
        font-size: 0.92rem;
        text-align: right;
    }
    .config-row > span[data-label]::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.82rem;
        white-space: nowrap;
    }
    .config-row input[type="number"] { width: 120px; }
    .config-row input[type="checkbox"] { width: 22px; height: 22px; }
    .config-row span.config-save {
        display: block;
        margin-top: 12px;
    }
    .config-row span.config-save button { width: 100%; padding: 12px; font-size: 0.9rem; }

    /* ----- 관리자 시세 계산기 ----- */
    .admin-calc { padding: 14px; }
    .admin-calc-controls { flex-direction: column; align-items: stretch; gap: 10px; }
    .admin-calc-controls label { width: 100%; }
    .admin-calc-controls select { min-width: 0; width: 100%; }
    .admin-calc-controls input[type="number"] { width: 100%; }
    .admin-calc-result table { font-size: 0.82rem; min-width: 500px; }
    .admin-calc-result th,
    .admin-calc-result td { padding: 7px 9px; white-space: nowrap; }
    .admin-calc-result::after {
        content: "← 좌우로 밀어서 비교 →";
        display: block;
        text-align: center;
        color: var(--muted);
        font-size: 0.72rem;
        margin-top: 6px;
    }
}
