/* 고객 포털 (부록 C-2) — 경량, 라이트/다크 대응 */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --border: #e4e7ec; --text: #1a1d21; --muted: #6b7280;
  --accent: #2f6df6; --accent-ink: #ffffff; --ok: #178a4c; --err: #c0392b; --over: #d97706;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --surface: #171b22; --border: #2a2f3a; --text: #e6e8eb; --muted: #98a2b3;
    --accent: #4d84ff; --accent-ink: #0b0d10; --ok: #34d17f; --err: #ff6b5e; --over: #f2a33c;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
/* [hidden]가 항상 이긴다 — .screen/.pane의 display:flex/grid가 hidden을 덮어쓰는 것 방지 */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }

/* 화면 전환 */
.screen[data-screen="loading"], .screen[data-screen="login"] {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }

/* 로그인 */
.auth-card { width: 100%; max-width: 380px; text-align: center; padding: 32px 28px; }
.auth-card .brand { font-weight: 700; letter-spacing: .04em; color: var(--accent); font-size: 13px; text-transform: uppercase; }
.auth-card h1 { margin: 6px 0 4px; font-size: 22px; }
#login-form { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
input[type="email"], input[type="text"] {
  padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--text); font-size: 15px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
button {
  cursor: pointer; border: 0; border-radius: 9px; padding: 11px 14px; font-size: 15px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink);
}
button:disabled { opacity: .55; cursor: default; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); font-weight: 500; padding: 7px 12px; font-size: 13px; }
.msg { margin: 14px 0 0; font-size: 13.5px; padding: 10px; border-radius: 8px; }
.msg.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.msg.err { background: color-mix(in srgb, var(--err) 12%, transparent); color: var(--err); }

/* 앱 셸 */
.app-shell { display: block; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 20px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand-sm { font-weight: 700; color: var(--accent); }
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; color: var(--muted); font-weight: 600; padding: 7px 12px; border-radius: 8px; }
.tab.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pill { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; }

.pane { max-width: 960px; margin: 0 auto; padding: 20px; display: grid; gap: 16px; }

/* 사용량 stat */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-val { font-size: 24px; font-weight: 700; margin-top: 4px; }
.meter { height: 6px; background: var(--border); border-radius: 4px; margin-top: 10px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.meter-fill.over { background: var(--over); }

/* 테이블 */
h2 { font-size: 15px; margin: 0 0 12px; }
.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grid th, .grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.grid th { color: var(--muted); font-weight: 600; font-size: 12px; }
.grid td.num, .grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid tr:last-child td { border-bottom: 0; }
.empty { color: var(--muted); font-size: 13.5px; padding: 8px 2px 0; }
.hint { color: var(--muted); font-size: 12.5px; }

/* 선택 UI */
.pane-head { display: flex; align-items: center; justify-content: space-between; }
.pane-head h2 { margin: 0; }
.sel-list { display: grid; gap: 16px; }
/* 노션에서 딥링크로 열린 제품 — 어느 카드가 그 제품인지 바로 보이게 */
.product.deeplink, .card.deeplink { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.card.deeplink h3 { margin: 0 0 6px; font-size: 15px; }
.product-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.product-head h3 { margin: 0; font-size: 15px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photo { position: relative; cursor: pointer; border-radius: 10px; overflow: hidden; border: 2px solid var(--border); aspect-ratio: 1; }
.photo.picked { border-color: var(--accent); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo input { position: absolute; top: 8px; left: 8px; width: 18px; height: 18px; accent-color: var(--accent); }
.photo:not(.picked) img { opacity: .5; filter: grayscale(.3); }
.product-foot { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.var { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.var-input { width: 140px; padding: 7px 10px; font-size: 14px; }
.sel-count { color: var(--muted); font-size: 13px; margin-left: auto; }

/* 토스트 */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 20;
  padding: 11px 18px; border-radius: 10px; font-size: 14px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.18); color: #fff; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }

@media (max-width: 640px) {
  .stat-row { grid-template-columns: 1fr; }
  .who .muted { display: none; }
}
