:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-muted: #eef2f0;
  --text: #14201c;
  --muted: #617069;
  --line: #dce4e0;
  --primary: #176b55;
  --primary-dark: #0f5644;
  --primary-soft: #e6f3ef;
  --danger: #b42318;
  --danger-soft: #fef0ed;
  --warning: #a15c00;
  --warning-soft: #fff5dd;
  --blue: #175cd3;
  --shadow: 0 8px 24px rgba(20, 32, 28, .06);
  --radius: 14px;
  --content: 1240px;
}

* { box-sizing: border-box; }
html { font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, sans-serif; color: var(--text); background: var(--bg); }
body { margin: 0; min-width: 320px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button, .button { min-height: 44px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(23, 107, 85, .26); outline-offset: 2px; }
img { max-width: 100%; display: block; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.75rem, 3vw, 2.35rem); letter-spacing: -.035em; line-height: 1.2; }
h2 { margin-bottom: 6px; font-size: 1.15rem; letter-spacing: -.02em; }
small { display: block; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; left: 12px; top: -60px; padding: 10px 14px; background: var(--text); color: #fff; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.muted { color: var(--muted); margin-bottom: 0; }
.eyebrow { margin-bottom: 6px; color: var(--primary); font-size: .78rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.grow { flex: 1; min-width: 0; }
.top-gap { margin-top: 12px; }

.app-header { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(10px); }
.header-inner { width: min(calc(100% - 32px), var(--content)); min-height: 68px; margin: auto; display: flex; align-items: center; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 850; letter-spacing: -.02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: white; font-size: 1.1rem; }
nav { display: flex; gap: 6px; }
nav a { min-height: 40px; display: inline-flex; align-items: center; padding: 0 13px; border-radius: 9px; color: var(--muted); font-weight: 700; }
nav a:hover { background: var(--surface-muted); text-decoration: none; }
nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-dark); }
.logout-form { margin-left: auto; }
.page-shell { width: min(calc(100% - 32px), var(--content)); margin: 0 auto; padding: 34px 0 64px; }
.page-heading, .detail-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 9px; padding: 0 16px; font-weight: 760; cursor: pointer; transition: background-color .15s, border-color .15s, transform .1s; }
.button:hover { text-decoration: none; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: .65; }
.button.primary { color: white; background: var(--primary); }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { color: var(--text); background: white; border-color: var(--line); }
.button.secondary:hover { background: var(--surface-muted); }
.button.ghost { color: var(--muted); background: transparent; }
.button.danger { color: white; background: var(--danger); }
.button.compact { min-height: 36px; padding: 0 11px; font-size: .88rem; }
.button.full { width: 100%; }

.notice { margin-bottom: 20px; padding: 13px 16px; border: 1px solid #a9d8ca; border-radius: 10px; background: var(--primary-soft); color: var(--primary-dark); font-weight: 650; }
.notice.error { border-color: #f4b2a9; background: var(--danger-soft); color: var(--danger); }
.notice.warning { border-color: #f0cf8f; background: var(--warning-soft); color: #754400; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); padding: 22px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading p { color: var(--muted); font-size: .9rem; margin: 0; }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.metric-grid article { border: 1px solid var(--line); border-top: 3px solid #8b9a93; border-radius: 11px; background: var(--surface); padding: 17px; }
.metric-grid article.good { border-top-color: var(--primary); }
.metric-grid article.warning { border-top-color: var(--warning); }
.metric-grid article.danger { border-top-color: var(--danger); }
.metric-grid span { display: block; color: var(--muted); font-size: .82rem; font-weight: 700; }
.metric-grid strong { display: block; margin: 4px 0 1px; font-size: 1.8rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric-grid small { font-size: .75rem; }
.split-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; }
.compact-list { display: grid; }
.compact-product { display: flex; align-items: center; gap: 13px; padding: 12px 2px; color: var(--text); border-top: 1px solid var(--line); }
.compact-product:first-child { border-top: 0; }
.compact-product:hover { text-decoration: none; background: #fafcfb; }
.compact-product strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb { flex: 0 0 48px; width: 48px; height: 48px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.price { font-variant-numeric: tabular-nums; letter-spacing: -.025em; white-space: nowrap; }
.compact-product .price { font-size: 1rem; }
.status-list { margin: 0 0 20px; }
.status-list div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.status-list div:first-child { border-top: 0; }
.status-list dt { color: var(--muted); }
.status-list dd { margin: 0; font-weight: 700; text-align: right; }
.status-dot { width: 8px; height: 8px; display: inline-block; margin-right: 7px; border-radius: 50%; background: #89968f; }
.status-dot.good { background: var(--primary); }
.status-dot.warning { background: var(--warning); }
.status-dot.danger { background: var(--danger); }

.filter-bar { display: grid; grid-template-columns: minmax(220px, 1fr) 170px 190px 170px auto; gap: 10px; margin-bottom: 16px; }
input, select, textarea { width: 100%; min-height: 44px; border: 1px solid #c8d3ce; border-radius: 9px; background: #fff; color: var(--text); padding: 10px 12px; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #87948e; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.product-table { width: 100%; min-width: 1060px; border-collapse: collapse; }
.product-table th { padding: 12px 14px; background: #f0f4f2; color: var(--muted); text-align: left; font-size: .78rem; letter-spacing: .02em; }
.product-table td { padding: 15px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.product-table td > small, .product-table td > span + small { margin-top: 3px; }
.product-cell { min-width: 260px; display: flex; align-items: center; gap: 12px; }
.product-cell strong { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--text); line-height: 1.35; }
.change { display: inline-flex; align-items: center; font-size: .9rem; font-weight: 750; white-space: nowrap; }
.down { color: var(--primary-dark); }
.up { color: var(--danger); }
.neutral { color: var(--muted); }
.badge { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; background: var(--surface-muted); color: #44534c; font-size: .77rem; font-weight: 800; white-space: nowrap; }
.status-normal { border-color: #a9d8ca; background: var(--primary-soft); color: var(--primary-dark); }
.status-checking { border-color: #abc6ee; background: #edf4ff; color: #164d9b; }
.status-out_of_stock, .status-product_removed, .status-error { border-color: #f2b2aa; background: var(--danger-soft); color: var(--danger); }
.status-blocked, .status-manual_check, .status-option_changed, .status-paused_due_to_failures { border-color: #eccd92; background: var(--warning-soft); color: #744500; }
.row-actions { width: 54px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--text); font-size: 1.5rem; }
.icon-button:hover { text-decoration: none; background: var(--surface-muted); }

.empty-state { min-height: 290px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 20px; }
.empty-state > span { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 15px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 1.5rem; }
.empty-state h2, .empty-state h3 { margin-bottom: 6px; }
.empty-state p { color: var(--muted); margin-bottom: 18px; }
.empty-inline { padding: 24px; border: 1px dashed #c8d3ce; border-radius: 10px; color: var(--muted); text-align: center; }

.form-section { max-width: 900px; margin: 0 auto; }
.product-form { padding: 0; overflow: hidden; }
.product-form fieldset { margin: 0; padding: 24px; border: 0; border-top: 1px solid var(--line); }
.product-form fieldset:first-of-type { border-top: 0; }
.product-form legend { float: left; width: 100%; margin-bottom: 17px; font-size: 1.05rem; font-weight: 820; }
.product-form legend + * { clear: both; }
label { display: grid; gap: 7px; color: #32423b; font-size: .9rem; font-weight: 720; }
label small { font-weight: 450; }
.required { color: var(--danger); font-size: .75rem; }
.optional { color: var(--muted); font-size: .75rem; font-weight: 500; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field-grid + label, fieldset > label + label { margin-top: 18px; }
.input-suffix { display: flex; align-items: center; border: 1px solid #c8d3ce; border-radius: 9px; background: #fff; overflow: hidden; }
.input-suffix:focus-within { outline: 3px solid rgba(23,107,85,.2); border-color: var(--primary); }
.input-suffix input { border: 0; border-radius: 0; outline: 0; }
.input-suffix span { padding-right: 12px; color: var(--muted); }
.checkbox-card { display: flex; align-items: center; align-self: end; min-height: 72px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafcfb; }
.checkbox-card input, .checkbox-row input { width: 20px; min-height: 20px; flex: 0 0 20px; accent-color: var(--primary); }
.checkbox-card span { display: grid; gap: 2px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 18px 24px; background: #f7f9f8; border-top: 1px solid var(--line); }

.detail-heading { align-items: center; }
.detail-product { display: flex; align-items: center; gap: 18px; min-width: 0; }
.detail-image { flex: 0 0 84px; width: 84px; height: 84px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); font-size: 1.8rem; }
.detail-image img { width: 100%; height: 100%; object-fit: contain; }
.detail-product h1 { max-width: 720px; font-size: clamp(1.45rem, 3vw, 2rem); }
.external-link { display: inline-block; margin-top: 8px; font-weight: 700; }
.action-cluster { display: flex; gap: 8px; }
.price-hero { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(0, 1.8fr); gap: 30px; align-items: center; margin-bottom: 18px; }
.price-hero > div > span { color: var(--muted); font-weight: 700; }
.price-hero > div > strong { display: block; margin: 4px 0; font-size: clamp(2rem, 5vw, 3rem); line-height: 1.15; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.price-hero dl { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; }
.price-hero dl div { padding: 6px 18px; border-left: 1px solid var(--line); }
.price-hero dt { color: var(--muted); font-size: .8rem; }
.price-hero dd { margin: 4px 0 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.chart-panel { margin-bottom: 18px; }
.chart-wrap { height: 310px; }
.period-tabs { display: flex; padding: 3px; border-radius: 9px; background: var(--surface-muted); }
.period-tabs a { padding: 6px 10px; border-radius: 7px; color: var(--muted); font-size: .82rem; font-weight: 750; }
.period-tabs a:hover { text-decoration: none; }
.period-tabs a[aria-current="page"] { background: white; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.mini-table-wrap { overflow-x: auto; }
.mini-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: .84rem; }
.mini-table th { color: var(--muted); text-align: left; }
.mini-table th, .mini-table td { padding: 10px 8px; border-top: 1px solid var(--line); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; align-items: flex-start; gap: 7px; padding: 11px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; }
.timeline .status-dot { margin-top: 7px; }
.timeline p { margin: 4px 0 0; color: var(--muted); font-size: .85rem; }
.danger-zone { display: grid; gap: 10px; }
.danger-zone h2 { margin-bottom: 4px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.stack-form { display: grid; gap: 15px; }
.wide-panel { grid-column: 1 / -1; }
.export-actions { display: flex; gap: 9px; margin-bottom: 16px; }
.backup-list { list-style: none; padding: 0; margin: 0; }
.backup-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.backup-list strong { display: block; }
.narrow-section { max-width: 620px; margin: 0 auto; }
.narrow-section > .panel { margin-top: 22px; }

.confirm-dialog { width: min(calc(100% - 32px), 440px); border: 0; border-radius: 14px; padding: 24px; box-shadow: 0 24px 80px rgba(0,0,0,.28); }
.confirm-dialog::backdrop { background: rgba(15, 25, 21, .55); }
.confirm-dialog p { color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #edf2ef; }
.login-card { width: min(100%, 430px); padding: 34px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 18px 60px rgba(20,32,28,.1); }
.login-brand { margin-bottom: 28px; }
.login-card h1 { font-size: 2rem; }
.login-card > .muted { margin-bottom: 24px; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .filter-bar { grid-template-columns: minmax(180px, 1fr) repeat(3, 150px) auto; }
  .price-hero { grid-template-columns: 1fr; }
  .price-hero dl div:first-child { border-left: 0; padding-left: 0; }
}

@media (max-width: 780px) {
  .header-inner { width: calc(100% - 20px); min-height: 62px; gap: 10px; }
  .brand > span:last-child { display: none; }
  nav { flex: 1; justify-content: center; }
  nav a { padding: 0 10px; font-size: .88rem; }
  .logout-form .button { padding: 0 8px; font-size: .8rem; }
  .page-shell { width: calc(100% - 24px); padding-top: 24px; }
  .page-heading, .detail-heading { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .split-grid, .settings-grid, .detail-grid { grid-template-columns: 1fr; }
  .wide-panel { grid-column: auto; }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar .search-field { grid-column: 1 / -1; }
  .filter-bar .button { grid-column: 1 / -1; }
  .field-grid { grid-template-columns: 1fr; }
  .detail-product { align-items: flex-start; }
  .detail-image { flex-basis: 68px; width: 68px; height: 68px; }
  .action-cluster { width: 100%; }
  .action-cluster > * { flex: 1; }
  .action-cluster .button { width: 100%; }
  .price-hero dl { grid-template-columns: repeat(2, 1fr); gap: 14px 0; }
  .price-hero dl div:nth-child(odd) { border-left: 0; padding-left: 0; }
}

@media (max-width: 600px) {
  .page-shell { width: calc(100% - 20px); }
  .metric-grid { gap: 8px; }
  .metric-grid article { padding: 13px; }
  .metric-grid strong { font-size: 1.55rem; }
  .panel { padding: 17px; }
  .table-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .product-table { min-width: 0; display: block; }
  .product-table thead { display: none; }
  .product-table tbody { display: grid; gap: 12px; }
  .product-table tr { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px 12px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
  .product-table td { display: grid; align-content: start; gap: 2px; padding: 0; border: 0; }
  .product-table td::before { content: attr(data-label); color: var(--muted); font-size: .72rem; font-weight: 700; }
  .product-table td:first-child { grid-column: 1 / -1; }
  .product-table td:first-child::before, .product-table td.row-actions::before { display: none; }
  .product-table .row-actions { position: absolute; width: 0; height: 0; overflow: hidden; }
  .product-cell { min-width: 0; }
  .product-cell .thumb { flex-basis: 56px; width: 56px; height: 56px; }
  .product-cell strong { font-size: 1.02rem; }
  .product-table td:nth-child(2) .price { font-size: 1.15rem; }
  .product-table td:nth-child(5) { grid-column: 1 / -1; }
  .product-table td:nth-child(6) { grid-column: 1 / -1; }
  .product-form fieldset { padding: 20px 16px; }
  .form-actions { position: sticky; bottom: 0; padding: 12px 16px; }
  .form-actions .button { flex: 1; }
  .detail-product h1 { font-size: 1.35rem; overflow-wrap: anywhere; }
  .price-hero > div > strong { font-size: 2.15rem; }
  .price-hero dl { grid-template-columns: 1fr; gap: 0; }
  .price-hero dl div, .price-hero dl div:nth-child(odd) { padding: 10px 0; border-left: 0; border-top: 1px solid var(--line); }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .period-tabs { width: 100%; }
  .period-tabs a { flex: 1; text-align: center; }
  .export-actions { flex-direction: column; }
  .login-card { padding: 26px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
