:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #17202a;
  --muted: #657180;
  --line: #dfe5eb;
  --primary: #1565c0;
  --primary-dark: #0c4d96;
  --soft-blue: #eaf3ff;
  --danger: #c62828;
  --warning: #8a5a00;
  --warning-bg: #fff7e4;
  --success: #19744a;
  --shadow: 0 10px 28px rgba(24, 40, 58, .07);
  --radius: 18px;
}
* { box-sizing: border-box; }
html { font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif; color: var(--text); background: var(--bg); }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-header { display: flex; justify-content: space-between; gap: 24px; align-items: center; padding: 30px clamp(18px, 4vw, 54px) 22px; background: #fff; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 6px; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .12em; }
h1 { margin: 0; font-size: clamp(25px, 4vw, 38px); letter-spacing: -.04em; }
.subtext { margin: 8px 0 0; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.status-chip { padding: 9px 12px; border-radius: 999px; background: #eef1f4; color: var(--muted); font-size: 13px; font-weight: 700; }
.status-chip.online { background: #e7f6ee; color: var(--success); }
.status-chip.offline { background: #fdecec; color: var(--danger); }
.tab-nav { display: flex; gap: 8px; padding: 14px clamp(18px, 4vw, 54px); background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; overflow-x: auto; }
.tab-btn { border: 0; background: transparent; color: var(--muted); padding: 11px 16px; border-radius: 11px; font-weight: 800; white-space: nowrap; }
.tab-btn.active { background: var(--soft-blue); color: var(--primary); }
.page-shell { max-width: 1500px; margin: 0 auto; padding: 26px clamp(14px, 3vw, 42px) 60px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel-grid { display: grid; gap: 22px; }
.two-col { grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 22px; }
.card-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 18px; }
.card h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.card-head p, .card > p { color: var(--muted); margin: 6px 0 0; font-size: 14px; }
.platform-picker { display: flex; gap: 10px; border: 0; padding: 0; margin: 0 0 16px; }
.platform-picker legend { width: 100%; font-weight: 800; margin-bottom: 9px; }
.platform-option { flex: 1; display: grid; place-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 12px; font-weight: 800; color: var(--muted); cursor: pointer; }
.platform-option input { position: absolute; opacity: 0; }
.platform-option.active { border-color: var(--primary); color: var(--primary); background: var(--soft-blue); }
.drop-zone { min-height: 190px; border: 2px dashed #b9c6d2; border-radius: 15px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 24px; background: #fbfcfd; transition: .18s ease; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--primary); background: var(--soft-blue); }
.drop-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 27px; margin-bottom: 12px; }
.drop-zone small { color: var(--muted); margin-top: 6px; }
.file-list { display: grid; gap: 8px; margin: 14px 0; max-height: 210px; overflow: auto; }
.file-list.empty { color: var(--muted); font-size: 14px; padding: 10px 0; }
.file-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; background: #f6f8fa; border-radius: 10px; }
.file-item img { width: 52px; height: 42px; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); }
.file-meta { min-width: 0; flex: 1; }
.file-meta strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.file-meta small { color: var(--muted); }
.icon-btn { border: 0; background: transparent; color: var(--danger); font-weight: 900; padding: 7px; }
.button-row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.button-row.compact { gap: 8px; }
.btn { border: 1px solid transparent; padding: 11px 15px; border-radius: 10px; font-weight: 800; transition: .16s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.danger-text { color: var(--danger); }
.progress-box { margin-top: 18px; border-radius: 12px; padding: 14px; background: #f6f8fa; }
.progress-track { height: 9px; border-radius: 999px; background: #dce4eb; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .25s ease; }
.progress-box p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.guide-list { display: grid; gap: 12px; }
.guide-list > div { display: grid; grid-template-columns: 38px 1fr; gap: 11px; align-items: start; }
.guide-list span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--soft-blue); color: var(--primary); font-size: 12px; font-weight: 900; }
.guide-list p { margin: 5px 0 0; color: #3e4a57; line-height: 1.55; }
.notice { margin-top: 20px; border-radius: 12px; padding: 15px; }
.notice.warning { background: var(--warning-bg); color: var(--warning); }
.notice p { margin: 6px 0 0; font-size: 14px; line-height: 1.55; }
.warning-list { margin-bottom: 15px; background: var(--warning-bg); color: var(--warning); border-radius: 12px; padding: 12px 15px; font-size: 14px; }
.warning-list ul { margin: 7px 0 0; padding-left: 20px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 13px; }
.tall-table { max-height: 620px; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 940px; }
.data-table th { position: sticky; top: 0; z-index: 2; background: #f6f8fa; color: #4d5a67; text-align: left; font-size: 13px; padding: 13px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 12px; border-bottom: 1px solid #edf0f3; vertical-align: top; font-size: 14px; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .menu-col { min-width: 320px; }
.editable-table input, .editable-table textarea, .editable-table select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; }
.editable-table textarea { min-height: 56px; resize: vertical; }
.editable-table .low-confidence { border-color: #ef9a9a; background: #fff5f5; }
.platform-badge { display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.platform-badge.baemin { background: #e5f8f7; color: #007d79; }
.platform-badge.coupang { background: #fff0ef; color: #c43b34; }
.filter-bar { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.filter-bar label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 800; }
.filter-bar input, .filter-bar select { min-height: 42px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text); }
.search-label { min-width: min(280px, 100%); flex: 1; }
.mini-summary { display: flex; gap: 16px; flex-wrap: wrap; margin: 16px 0; color: var(--muted); font-size: 14px; }
.mini-summary strong { color: var(--text); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.kpi-card span { color: var(--muted); font-size: 14px; font-weight: 800; }
.kpi-card strong { display: block; margin-top: 10px; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.04em; }
.kpi-card small { color: var(--muted); display: block; margin-top: 7px; }
.performance-list { display: grid; gap: 13px; }
.performance-row { display: grid; grid-template-columns: minmax(105px, .8fr) 2fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid #edf0f3; }
.performance-row:last-child { border-bottom: 0; }
.performance-name strong { display: block; }
.performance-name small { color: var(--muted); }
.bar-shell { height: 10px; border-radius: 99px; background: #e8edf2; overflow: hidden; }
.bar-shell span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.performance-value { text-align: right; }
.performance-value strong { display: block; }
.performance-value small { color: var(--muted); }
.empty-state { text-align: center; color: var(--muted); padding: 35px 15px !important; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; min-width: 260px; max-width: min(430px, calc(100vw - 44px)); padding: 14px 16px; border-radius: 12px; background: #16202a; color: #fff; box-shadow: 0 15px 40px rgba(0,0,0,.24); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .22s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #9f2525; }
.hidden { display: none !important; }
@media (max-width: 980px) {
  .two-col, .kpi-grid { grid-template-columns: 1fr 1fr; }
  .guide-card { grid-column: span 2; }
}
@media (max-width: 720px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  .header-actions { justify-content: flex-start; }
  .two-col, .kpi-grid { grid-template-columns: 1fr; }
  .guide-card { grid-column: auto; }
  .responsive-head { flex-direction: column; }
  .button-row { justify-content: flex-start; }
  .card { padding: 16px; border-radius: 14px; }
  .page-shell { padding-left: 10px; padding-right: 10px; }
  .performance-row { grid-template-columns: 1fr; }
  .performance-value { text-align: left; }
}

/* 1.2 브랜드 기능 */
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.source-picker-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(260px, .85fr); gap: 14px; margin-bottom: 16px; }
.source-picker-grid .platform-picker { margin-bottom: 0; align-content: start; }
.brand-picker { display: grid; align-content: start; gap: 8px; }
.brand-picker > label { font-weight: 800; }
.brand-picker-row { display: flex; gap: 8px; }
.brand-picker-row select { flex: 1; min-width: 0; min-height: 50px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; color: var(--text); font-weight: 800; }
.brand-picker small { color: var(--muted); line-height: 1.45; }
.brand-manager { margin: 0 0 16px; padding: 16px; border: 1px solid #cbd8e5; border-radius: 14px; background: #f8fbff; }
.brand-manager-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.brand-manager-head strong { display: block; }
.brand-manager-head small { display: block; margin-top: 4px; color: var(--muted); }
.icon-btn.neutral { color: var(--muted); font-size: 20px; line-height: 1; }
.brand-add-row { display: flex; gap: 8px; }
.brand-add-row input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.brand-list { display: grid; gap: 8px; margin-top: 12px; }
.brand-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.brand-badge { display: inline-flex; align-items: center; max-width: 100%; padding: 6px 10px; border-radius: 999px; background: var(--soft-blue); color: var(--primary); font-size: 13px; font-weight: 900; overflow-wrap: anywhere; }
.brand-item-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.small-btn { border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; background: #fff; color: var(--text); font-size: 12px; font-weight: 800; }
.small-btn.danger { color: var(--danger); }
.brand-help { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.empty-brand { color: var(--muted); font-size: 13px; padding: 8px 0; }
.preview-table { min-width: 1180px; }
.orders-table { min-width: 1120px; }
.daily-table { min-width: 1080px; }
.inline-brand-select { min-width: 126px; max-width: 180px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; background: #fff; color: var(--text); font-weight: 800; }
.brand-cell { min-width: 130px; }
.brand-breakdown { min-width: 180px; }
.breakdown-line { display: block; white-space: nowrap; line-height: 1.65; color: var(--muted); }
.breakdown-line b { color: var(--text); }
.dashboard-grid .card { margin-bottom: 0; }

@media (max-width: 1180px) {
  .three-col { grid-template-columns: 1fr 1fr; }
  .dashboard-grid .card:last-child { grid-column: span 2; }
}

@media (max-width: 820px) {
  .source-picker-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .three-col { grid-template-columns: 1fr; }
  .dashboard-grid .card:last-child { grid-column: auto; }
  .brand-picker-row, .brand-add-row { flex-direction: column; }
  .brand-item { align-items: flex-start; flex-direction: column; }
  .brand-item-actions { justify-content: flex-start; }
}
