/* 형제 프로젝트(브랜드별 매출 현황 · 월간 SF 점검 · 브랜드별 이슈 클리핑)와 동일한 레이아웃 비율/토큰.
   값을 바꿀 때는 ../../브랜드별 매출 현황/web_deploy/index.html 의 <style>과 먼저 대조할 것. */
@font-face {
  font-family: 'NanumBarunGothic';
  font-weight: 100 500;
  font-style: normal;
  font-display: swap;
  src: url('fonts/나눔바른고딕.ttf') format('truetype');
}
@font-face {
  font-family: 'NanumBarunGothic';
  font-weight: 600 900;
  font-style: normal;
  font-display: swap;
  src: url('fonts/나눔바른고딕Bold.ttf') format('truetype');
}
:root {
  color-scheme: light;
  --page: #f4f5fa;
  --surface-1: #ffffff;
  --surface-2: #ffffff;
  --text-primary: #0c1220;
  --text-secondary: #565f72;
  --text-muted: #8891a6;
  --grid: #e8e9f1;
  --border: rgba(15,23,42,0.09);
  --good: #0fa968;
  --good-text: #0c8a57;
  --critical: #e1444b;
  --series-1: #14a19b;
  --series-2: #7c5cfc;
  --series-3: #f5a524;
  --series-1-wash: rgba(20,161,155,0.10);
  --accent-chip-bg: rgba(20,161,155,0.10);
  --accent-chip-bg-soft: rgba(20,161,155,0.05);
  --accent-chip-border: #14a19b;
  --target-color: #f0990a;
  --good-bg: rgba(15,169,104,0.13);
  --critical-bg: rgba(225,68,75,0.12);
  --amber-bg: rgba(245,165,36,0.15);
  --amber-text: #93600a;
  --card-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 18px 36px -22px rgba(15,23,42,0.16);
  --zebra-bg: rgba(15,23,42,0.022);
  --font-disp: 'NanumBarunGothic', 'Malgun Gothic', system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: 'NanumBarunGothic', 'Malgun Gothic', system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: 'NanumBarunGothic', 'Malgun Gothic', system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #12151d;
    --surface-1: #191d28;
    --surface-2: #1e2330;
    --text-primary: #f2f3f8;
    --text-secondary: #a9b0c3;
    --text-muted: #767f95;
    --grid: #2a3040;
    --border: rgba(255,255,255,0.10);
    --good: #22c98b;
    --good-text: #3ddb9c;
    --critical: #ff6b71;
    --series-1: #2bd4cc;
    --series-2: #9c85ff;
    --series-3: #ffb74a;
    --series-1-wash: rgba(43,212,204,0.14);
    --accent-chip-bg: rgba(43,212,204,0.14);
    --accent-chip-bg-soft: rgba(43,212,204,0.07);
    --accent-chip-border: #2bd4cc;
    --target-color: #ffb74a;
    --good-bg: rgba(34,201,139,0.18);
    --critical-bg: rgba(255,107,113,0.18);
    --amber-bg: rgba(255,183,74,0.16);
    --amber-text: #ffb74a;
    --card-shadow: 0 1px 2px rgba(0,0,0,0.35), 0 18px 36px -22px rgba(0,0,0,0.55);
    --zebra-bg: rgba(255,255,255,0.028);
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body {
  background:
    radial-gradient(900px 480px at 6% -8%, rgba(20,161,155,0.07), transparent 60%),
    radial-gradient(900px 480px at 98% -4%, rgba(124,92,252,0.08), transparent 60%),
    var(--page);
  background-attachment: fixed;
}
.wrap { max-width: 1320px; margin: 0 auto; padding: 28px 20px 60px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---- 헤더 ---- */
header.topbar { margin-bottom: 26px; position: relative; padding-right: 340px; min-height: 113px; }
.ci-logo-wrap { position: absolute; top: 28px; right: 20px; }
.ci-logo-wrap img { display: block; height: 113px; width: auto; }
.header-user-row { position: absolute; top: 0; right: 20px; display: flex; align-items: center; gap: 8px; }
.project-switch { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.switch-btn {
  font-family: var(--font-body); font-size: 12px; font-weight: 700; padding: 6px 13px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-secondary); text-decoration: none; cursor: pointer; transition: all .15s ease;
}
.switch-btn:hover { border-color: var(--accent-chip-border); color: var(--series-1); }
header.topbar h1 {
  font-family: var(--font-disp); font-weight: 900; letter-spacing: -0.02em; line-height: 1.08;
  font-size: clamp(26px, 3.6vw, 36px); margin: 0 0 8px; color: var(--text-primary);
}
header.topbar p.sub { margin: 0; color: var(--text-secondary); font-size: 13.5px; white-space: nowrap; }
.user-label { font-size: 12px; color: var(--text-muted); }
@media (max-width: 720px) {
  .ci-logo-wrap { display: none; }
  header.topbar { padding-right: 0; min-height: 0; }
  header.topbar p.sub { white-space: normal; }
}

/* ---- 카드 ---- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: var(--card-shadow);
}
.card + .card { margin-top: 16px; }
.card h2 {
  font-family: var(--font-body); font-size: 15px; font-weight: 700; margin: 0 0 14px; letter-spacing: -0.005em;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.card h2 .sub { font-size: 12px; font-weight: 400; color: var(--text-muted); }

.note-banner { display: flex; gap: 12px; align-items: flex-start; background: var(--amber-bg); border-radius: 10px; padding: 13px 16px; margin-bottom: 16px; font-size: 12.5px; color: var(--text-secondary); }
.note-banner .ni { font-size: 16px; flex: none; line-height: 1.3; }
.note-banner b { color: var(--amber-text); }
.note-banner a { color: var(--amber-text); font-weight: 700; cursor: pointer; text-decoration: underline; margin-left: 6px; }

/* ---- KPI ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px 14px 18px; position: relative; overflow: hidden;
  transition: transform .22s cubic-bezier(.2,.7,.3,1), box-shadow .22s;
}
.kpi:hover { transform: translateY(-3px); box-shadow: 0 14px 26px -16px rgba(15,23,42,0.22); }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--series-1); opacity: .9; }
.kpi-grid .kpi:nth-child(1)::before { background: var(--target-color); }
.kpi-grid .kpi:nth-child(4)::before { background: var(--series-2); }
.kpi .label { font-size: 11.5px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.kpi .value { font-family: var(--font-mono); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.kpi .value .unit { font-size: 12px; color: var(--text-muted); margin-left: 2px; font-weight: 500; }
.kpi .value.warn { color: var(--amber-text); }
.kpi .delta { font-size: 11.5px; margin-top: 6px; font-weight: 600; color: var(--text-muted); }

/* ---- 버튼 ---- */
.btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary);
  border-radius: 999px; padding: 7px 14px; font-size: 12.5px; cursor: pointer; font-weight: 600;
  font-family: var(--font-body); transition: all .15s;
}
.btn:hover { border-color: var(--accent-chip-border); color: var(--series-1); background: var(--accent-chip-bg); }
.btn.small { padding: 4px 11px; font-size: 11.5px; font-weight: 500; }
.btn.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; font-weight: 700; }
.btn.primary:hover { opacity: .92; color: #fff; background: var(--series-1); }
.btn.ghost { background: none; border-color: transparent; }
.btn.ghost:hover { border-color: var(--accent-chip-border); background: var(--accent-chip-bg); }
.actions-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; align-items: center; flex-wrap: wrap; }
.actions-row .err { color: var(--critical); font-size: 12px; margin-right: auto; }

/* ---- 테이블 (형제 공통: 숫자 우측·모노, 첫 열/텍스트 열 좌측) ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: right; font-size: 11px; color: var(--text-muted); font-weight: 600; font-family: var(--font-mono); letter-spacing: .05em;
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
thead th:first-child, thead th.left { text-align: left; font-family: var(--font-body); letter-spacing: 0; }
tbody td {
  padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--grid); vertical-align: top;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap;
}
tbody td:first-child, tbody td.left { text-align: left; font-family: var(--font-body); font-variant-numeric: normal; color: var(--text-primary); }
tbody td.center, thead th.center { text-align: center; }
tbody tr:nth-of-type(even) { background: var(--zebra-bg); }
tbody tr.cancelled td { opacity: .45; }
tbody tr.inactive td:not(.use) { opacity: .45; }
tbody td.use { width: 56px; text-align: center; vertical-align: middle; }
.use-check { display: inline-flex; padding: 2px; cursor: pointer; }
.use-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--series-1); cursor: pointer; }
td .muted, .muted { color: var(--text-muted); font-size: 11.5px; font-family: var(--font-mono); }
td .line { display: block; line-height: 20px; }  /* 제품명·규격·수량 열의 줄 높이를 고정해 여러 품목도 가로로 정렬 */
td .line + .line { margin-top: 2px; }
td.strong { font-weight: 700; }
.empty-note { color: var(--text-muted); font-size: 13px; padding: 24px 0; text-align: center !important; }

/* ---- 로딩 · 로그인 · 권한 없음 (형제 프로젝트와 동일) ---- */
#loadingOverlay { display: flex; position: fixed; inset: 0; background: var(--page); align-items: center; justify-content: center; z-index: 50; flex-direction: column; gap: 10px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--series-1); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loadingOverlay .msg { color: var(--text-secondary); font-size: 13px; font-family: var(--font-mono); }
.login-screen { display: none; position: fixed; inset: 0; z-index: 60; align-items: center; justify-content: center; background: var(--page); padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 18px; padding: 28px 26px; box-shadow: var(--card-shadow); }
.login-card h2 { margin: 0 0 4px; font-size: 18px; font-weight: 800; }
.login-card .login-sub { margin: 0 0 20px; color: var(--text-muted); font-size: 12.5px; }
.login-field { margin-bottom: 12px; }
.login-field label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 5px; font-weight: 600; }
.login-field input { width: 100%; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary); border-radius: 10px; padding: 9px 12px; font-size: 13.5px; font-family: var(--font-body); }
.login-field input:focus { outline: none; border-color: var(--accent-chip-border); }
.login-submit { width: 100%; margin-top: 6px; border: none; border-radius: 10px; padding: 10px 0; background: var(--series-1); color: #fff; font-weight: 700; font-size: 13.5px; cursor: pointer; font-family: var(--font-body); }
.login-submit:hover { opacity: .92; }
.login-error { color: var(--critical); font-size: 12px; margin-top: 10px; min-height: 1.4em; }
.login-toggle { margin-top: 14px; font-size: 12px; color: var(--text-muted); text-align: center; }
.login-toggle a { color: var(--series-1); cursor: pointer; text-decoration: none; font-weight: 600; }

footer { margin-top: 32px; color: var(--text-muted); font-size: 11.5px; font-family: var(--font-mono); text-align: center; letter-spacing: .02em; }

@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr; }
  .brand-tab-sticky { padding: 12px 16px; }
}

/* ---- 마감 예측 전용 ---- */
.kpi-grid { margin-bottom: 18px; }
.kpi-grid.k6 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 800px) { .kpi-grid.k6 { grid-template-columns: repeat(2, 1fr); } }
.kpi-grid.k6 .kpi:nth-child(1)::before { background: var(--target-color); }
.kpi-grid.k6 .kpi:nth-child(4)::before { background: var(--series-1); }
.kpi-grid.k6 .kpi:nth-child(6)::before { background: var(--series-2); }
.ach { font-weight: 800; }
.note-bar { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; font-size: 12.5px; color: var(--text-secondary); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--accent-chip-bg); color: var(--series-1); }
.pill.warn { background: var(--amber-bg); color: var(--amber-text); }
.tbl-box { max-height: 74vh; overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
.ftable { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1400px; }
.ftable th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: right; padding: 9px 10px; font-size: 11.5px; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.ftable td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--grid); font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ftable th.left, .ftable td.left { text-align: left; font-family: var(--font-body); }
.ftable tr.brand { background: var(--zebra-bg); cursor: pointer; font-weight: 700; }
.ftable tr.brand:hover { background: var(--accent-chip-bg-soft); }
.ftable tr.brand td.left::before { content: '▸'; display: inline-block; width: 16px; color: var(--text-muted); transition: transform .12s; }
.ftable tr.brand.open td.left::before { transform: rotate(90deg); }
.ftable tr.item td.left { padding-left: 34px; font-weight: 400; color: var(--text-secondary); }
.ftable tr.item.zero td { color: var(--text-muted); }
.ftable tr.reason td { white-space: normal; text-align: left; font-family: var(--font-body); background: var(--series-1-wash); padding: 10px 16px 12px 34px; }
.ftable tr.reason ol { margin: 0; padding-left: 18px; line-height: 1.7; }
.ftable tr.reason li { margin-bottom: 2px; }
.ftable tr.reason .rt { font-size: 11.5px; font-weight: 700; color: var(--series-1); margin-bottom: 4px; }
.ftable tr.total td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 800; border-top: 2px solid var(--border); }
.rng { color: var(--text-muted); font-size: 11.5px; }
.up { color: var(--good-text); } .down { color: var(--critical); }
.foot { margin-top: 16px; font-size: 12px; color: var(--text-muted); line-height: 1.7; }
.empty { padding: 40px; text-align: center; color: var(--text-muted); }
/* ---- 상단 고정 탭 ---- */
.brand-tab-sticky {
  position: sticky; top: 0; z-index: 30; background: var(--page);
  padding: 12px 28px; margin: 0 0 16px; box-shadow: 0 8px 12px -8px rgba(0,0,0,0.12);
}
.brand-tab-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.brand-tab {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary);
  border-radius: 999px; padding: 7px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  user-select: none; font-family: var(--font-body); transition: all .15s; white-space: nowrap;
}
.brand-tab:hover { border-color: var(--accent-chip-border); color: var(--series-1); transform: translateY(-1px); }
.brand-tab.active {
  background: var(--series-1); border-color: var(--series-1); color: #fff;
  box-shadow: 0 2px 8px rgba(20,161,155,0.28);
}
.brand-tab .count { font-family: var(--font-mono); font-size: 11px; margin-left: 5px; opacity: .75; }
.panel { display: none; }
.panel.active { display: block; }

