/* ──────────────────────────────────────────────────────────────────────────
   CardAgent 어드민 — 디자인 토큰과 컴포넌트.
   내부 도구라 프레임워크 없이 한 파일로 둔다. 모든 색은 토큰으로만 쓴다(다크 모드가 그것을 덮는다).
   ────────────────────────────────────────────────────────────────────────── */

:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f4;
  --border: #e4e7ec;
  --border-strong: #cfd4dc;

  --text: #14171f;
  --text-2: #4a5160;
  --text-3: #8b92a1;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #3b34b3;

  --ok: #0f9d68;      --ok-soft: #e6f7f0;
  --warn: #d68b0a;    --warn-soft: #fff5e0;
  --bad: #d8342e;     --bad-soft: #fdeceb;
  --info: #2b6fdb;    --info-soft: #e9f1fd;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .12);

  --sidebar-w: 236px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard", "Noto Sans KR",
    "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #171a22;
    --surface-2: #1c2029;
    --surface-3: #232834;
    --border: #262b36;
    --border-strong: #353b48;

    --text: #e8eaf0;
    --text-2: #a8afbf;
    --text-3: #6b7383;

    --accent: #7c74f5;
    --accent-hover: #918af7;
    --accent-soft: #232449;
    --accent-text: #b8b3ff;

    --ok: #34c58b;      --ok-soft: #123526;
    --warn: #f0a93a;    --warn-soft: #3a2a0f;
    --bad: #f0605a;     --bad-soft: #3d1917;
    --info: #5b9bff;    --info-soft: #17273f;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, .6);
  }
}

/* ── 기본 ────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); }
code {
  font-size: 12.5px;
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text-2);
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; line-height: 1.3; }
h2 { font-size: 15px; }
p { margin: 0; }
small { font-size: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── 레이아웃 ────────────────────────────────────────────────────────────── */

.app { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px 14px;
  font-weight: 700; font-size: 15px; letter-spacing: -.01em;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: grid; place-items: center; color: #fff;
  box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 16px; height: 16px; }
.brand small { display: block; font-weight: 500; color: var(--text-3); font-size: 11px; margin-top: 1px; }

.nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  padding: 14px 10px 6px; font-size: 11px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .06em;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.nav a svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: .8; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); }
.nav a.active svg { opacity: 1; }
.nav .count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2);
  padding: 1px 7px; border-radius: 999px;
}
.nav a.active .count { background: var(--accent); color: #fff; }

.sidebar-footer { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); }
.sidebar-footer form { margin: 0; }
.sidebar-footer .btn { width: 100%; justify-content: flex-start; }

.content { flex: 1; min-width: 0; padding: 28px 36px 48px; }
.container { max-width: 1120px; margin: 0 auto; }

/* ── 페이지 헤더 ─────────────────────────────────────────────────────────── */

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 22px;
}
.page-header .lead { color: var(--text-2); margin-top: 4px; max-width: 720px; }
.page-header .eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-3); margin-bottom: 6px;
}
.page-header .eyebrow a { color: var(--text-3); }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── 알림 ────────────────────────────────────────────────────────────────── */

.flash, .alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  margin-bottom: 18px; font-size: 13.5px;
}
.flash svg, .alert svg { width: 17px; height: 17px; flex: 0 0 17px; margin-top: 1px; }
.flash { border-color: var(--ok); background: var(--ok-soft); color: var(--text); }
.flash svg { color: var(--ok); }
.flash.bad { border-color: var(--bad); background: var(--bad-soft); }
.flash.bad svg { color: var(--bad); }
.alert { border-color: transparent; background: var(--warn-soft); color: var(--text-2); }
.alert svg { color: var(--warn); }
.alert.info { background: var(--info-soft); }
.alert.info svg { color: var(--info); }
.alert b { color: var(--text); }

/* ── 지표 타일 ───────────────────────────────────────────────────────────── */

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat .label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.stat .value {
  font-size: 26px; font-weight: 700; letter-spacing: -.02em;
  margin-top: 6px; font-variant-numeric: tabular-nums;
}
.stat .value small { font-size: 14px; color: var(--text-3); font-weight: 500; margin-left: 2px; }
.stat .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.stat.accent .value { color: var(--accent-text); }
.stat.warn .value { color: var(--warn); }

/* ── 패널 ────────────────────────────────────────────────────────────────── */

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin-bottom: 20px; overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.panel-header .sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.panel-body { padding: 18px; }
.panel-body + .panel-body { border-top: 1px solid var(--border); }

/* ── 표 ──────────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
  font-size: 11.5px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .05em;
  background: var(--surface-2); white-space: nowrap;
}
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.muted { color: var(--text-3); }
td.nowrap { white-space: nowrap; }
td .sub { display: block; color: var(--text-3); font-size: 12px; margin-top: 1px; }
/* 표를 카드사로 나누는 머리 행. 열 머리글(th)보다 약하고 본문 행보다 강하게 둔다. */
tr.group-row th {
  text-align: left; background: var(--surface-2); color: var(--text);
  font-size: 12.5px; font-weight: 650; letter-spacing: 0; text-transform: none;
  padding: 7px 14px; border-top: 1px solid var(--border-strong);
}
tbody:first-of-type tr.group-row th { border-top: none; }
tr.group-row th a { color: inherit; text-decoration: none; }
tr.group-row th a:hover { color: var(--accent-text); text-decoration: underline; }
tr.group-row .muted { font-weight: 400; }
tr.group-row .count { float: right; font-weight: 500; color: var(--text-3); }

td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline-block; margin-left: 4px; }
.row-title { font-weight: 550; color: var(--text); }
a.row-title { text-decoration: none; }
/* 열 머리글의 작은 안내. 행 안에 또 버튼을 두면 동작 열이 넘쳐 표가 가로로 밀린다. */
.th-hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-3); font-size: 11px; }
a.row-title:hover { color: var(--accent-text); text-decoration: underline; }
.truncate { max-width: min(360px, 34vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
/* 첫 열(이름)은 접히면 읽기 나빠진다 — 최소 폭을 주고, 대신 표 전체는 가로 스크롤을 허용한다. */
th.title, td.title { min-width: 200px; }
/* 제목 칸 안의 URL 줄. 제목 자체보다 넓어지면 표의 균형이 무너진다. */
td.title a.sub.truncate { max-width: min(420px, 30vw); display: inline-flex; align-items: center; gap: 4px; }
td.title a.sub.truncate:hover { color: var(--accent-text); }
/* `0 4 * * 1` 처럼 공백이 든 코드 값은 줄바꿈되면 다른 값으로 보인다. */
td code, .sub code { white-space: nowrap; }

/* ── 카드 썸네일 ─────────────────────────────────────────────────────────── */

/* 실물 카드 비율(1.586:1). 이미지가 없으면 카드의 `color` 를 배경으로 두어 앱의 자리표시자와
   같은 인상을 준다 — 목록에서 "이미지 없음" 이 빈칸으로 보이지 않게 하기 위함이다. */
.card-thumb {
  display: inline-block; width: 56px; height: 35px; border-radius: 5px;
  background: var(--surface-3) center / cover no-repeat; vertical-align: middle;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); flex: 0 0 56px;
}
.card-thumb.lg { width: 168px; height: 106px; border-radius: 10px; box-shadow: var(--shadow); }
.card-cell { display: flex; align-items: center; gap: 12px; }
.card-cell > div { min-width: 0; }

/* ── 배지 ────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px 2px 7px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok   { background: var(--ok-soft);   color: var(--ok); }
.badge.bad  { background: var(--bad-soft);  color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--surface-3); color: var(--text-3); }

/* ── 버튼 ────────────────────────────────────────────────────────────────── */

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 550; font-size: 13.5px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; line-height: 1.4;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn svg, button svg { width: 15px; height: 15px; }
.btn:hover, button:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary, button.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover, button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger, button.danger { color: var(--bad); border-color: var(--border-strong); }
.btn-danger:hover, button.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-ghost, button.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover, button.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm, button.sm { padding: 4px 10px; font-size: 12.5px; }
/* 아이콘만 있는 버튼. 정사각형으로 두어 여러 개가 나란히 설 때 높이·간격이 흔들리지 않는다. */
.btn-icon { padding: 5px; width: 28px; height: 28px; gap: 0; }
.btn-icon svg { width: 14px; height: 14px; }
.btn-icon.is-on { color: var(--ok); border-color: var(--border-strong); }
.btn-icon.is-on:hover { background: var(--ok-soft); border-color: var(--ok); }
.btn-block { width: 100%; }

/* ── 폼 ──────────────────────────────────────────────────────────────────── */

/* 격자는 **위쪽 기준**으로 맞춘다. 아래 기준(end)으로 두면 힌트가 달린 칸만 키가 커져서
   같은 줄의 라벨과 입력창이 서로 다른 높이에 놓인다(실측: 카드사 칸이 카드 칸보다 내려앉았다).
   라벨 높이가 일정하니 위를 맞추면 입력창도 한 줄에 놓이고, 힌트는 그 아래로만 늘어난다. */
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px 18px; align-items: start;
}
.form-grid .wide { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.field label { display: block; font-size: 12.5px; font-weight: 550; color: var(--text-2); margin-bottom: 6px; line-height: 18px; }
.field .hint { display: block; font-size: 12px; color: var(--text-3); margin-top: 6px; }
/* 체크박스 줄은 **폼 전체 폭**을 쓴다. 입력창과 같은 한 칸(최소 220px)에 두면 체크박스·라벨·힌트가
   그 폭을 나눠 갖느라 "검수 없 / 이 자동 / 반영" 처럼 접힌다. 한 줄을 통째로 주면 셋이 나란히 선다. */
.field.check {
  grid-column: 1 / -1;
  display: flex; align-items: baseline; flex-wrap: wrap;
  gap: 4px 10px; padding: 2px 0;
}
.field.check input[type=checkbox] { align-self: center; flex: none; }
.field.check label { margin: 0; font-weight: 550; color: var(--text); line-height: 1.5; white-space: nowrap; }
.field.check .hint { margin: 0; flex: 1 1 260px; line-height: 1.5; }
input[type=text], input[type=url], input[type=password], input[type=number], select { height: 36px; }
input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
  font: inherit; width: 100%;
  padding: 7px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--text-3); }
select { appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b92a1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
textarea { min-height: 380px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; resize: vertical; }

/* ── 빈 상태 ─────────────────────────────────────────────────────────────── */

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 40px 20px; text-align: center; color: var(--text-3);
}
.empty svg { width: 32px; height: 32px; opacity: .5; }
.empty b { color: var(--text-2); font-weight: 600; }

/* ── 코드/원문 ───────────────────────────────────────────────────────────── */

pre.payload {
  margin: 0; padding: 16px 18px;
  background: #0d1220; color: #d6dbe8;
  font-size: 12.5px; line-height: 1.55;
  overflow: auto; max-height: 600px;
  border-radius: 0 0 var(--radius) var(--radius);
}
@media (prefers-color-scheme: dark) { pre.payload { background: #0a0d16; } }

/* ── 분할 ────────────────────────────────────────────────────────────────── */

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* ── 상세 키/값 ──────────────────────────────────────────────────────────── */

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-3); font-weight: 500; }
.kv dd { margin: 0; word-break: break-all; }

/* ── 로그인 ──────────────────────────────────────────────────────────────── */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  width: 100%; max-width: 360px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px 28px 28px;
  box-shadow: var(--shadow-lg);
}
.login .brand { padding: 0 0 18px; justify-content: center; flex-direction: column; text-align: center; }
.login .brand-mark { width: 44px; height: 44px; border-radius: 12px; }
.login .brand-mark svg { width: 24px; height: 24px; }
.login h1 { font-size: 18px; text-align: center; }
.login .lead { text-align: center; color: var(--text-3); font-size: 13px; margin: 6px 0 22px; }
.login .field { margin-bottom: 14px; }

/* ── 반응형 ──────────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { position: static; height: auto; width: auto; flex: none; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { flex-direction: row; flex-wrap: wrap; padding: 0 12px 10px; }
  .nav-label { display: none; }
  .sidebar-footer { border-top: none; padding: 0 12px 12px; margin: 0; }
  .sidebar-footer .btn { width: auto; }
  .content { padding: 20px 16px 40px; }
  .split { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 4px; }
  .form-grid .wide { grid-column: auto; }
}

/* 추출 정보 — 근거 인용과 미매칭 브랜드 칩 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; background: var(--surface-3); color: var(--text-2);
}
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip { white-space: nowrap; }                 /* 칩 안에서 이름이 두 줄로 꺾이지 않게 — 줄바꿈은 칩 사이에서만 */
.chip.limit { border: 1px dashed var(--border-strong); background: transparent; }
.chip.more { cursor: pointer; font: inherit; font-size: 12px; background: transparent; border: 1px dashed var(--border-strong); color: var(--accent-text); padding: 3px 9px; }
.chip.more:hover { background: var(--accent-soft); }

/* 혜택 목록 — 열이 여덟이던 표를 항목 블록으로. 대상 브랜드가 17곳이면 표에서는 한 행이 화면을 다 먹는다. */
.benefit-list { display: flex; flex-direction: column; }
.benefit { padding: 14px 18px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 7px; }
.benefit:last-child { border-bottom: none; }
.benefit.expired { opacity: .72; }
.benefit-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12.5px; }
.benefit-holder { color: var(--text-2); font-weight: 550; }
.benefit-holder small { color: var(--text-3); font-weight: 400; margin-left: 4px; }
.benefit-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-3); }
.benefit-meta a.muted:hover { color: var(--accent-text); }
.benefit-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.benefit-reward { color: var(--accent-text); font-weight: 700; white-space: nowrap; font-size: 14px; }
.benefit-row { display: flex; align-items: flex-start; gap: 10px; }
.benefit-row .k { flex: 0 0 30px; font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding-top: 5px; }
.benefit-row .chips { flex: 1 1 auto; min-width: 0; }
.benefit-stores { flex: 0 0 auto; font-size: 12.5px; color: var(--text-2); padding-top: 4px; white-space: nowrap; }
.benefit-stores b { font-weight: 650; }
.benefit-stores.bad { color: var(--bad); }
.benefit-id { font-size: 11px; color: var(--text-3); }
.benefit-id code { background: transparent; padding: 0; }
.merchant-map { height: 480px; width: 100%; border-radius: 0 0 var(--radius) var(--radius); background: var(--surface-2); }
.maplibregl-popup-content { color: #1b1f24; font: 13px/1.45 inherit; padding: 10px 12px; border-radius: 8px; }
.maplibregl-ctrl-attrib { font-size: 11px; }
/* 행에서 여는 모달. 팝오버로 두면 표의 가로 스크롤이 만드는 잘림 영역에 걸려 아래가 잘린다(실측). */
dialog.sheet {
  /* 텍스트 속성은 물려받지 않는다 — 어느 칸 안에서 열리든 모달은 같아야 한다. */
  text-align: left; white-space: normal; letter-spacing: normal;
  width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, .45); }
.sheet-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.sheet-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; }
.sheet-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-2); }
.sheet-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; text-align: left; }
.sheet-body .field { display: flex; flex-direction: column; gap: 5px; }
.sheet-body .field input, .sheet-body .field select { width: 100%; }
.sheet-body hr { border: none; border-top: 1px solid var(--border); margin: 2px 0; }
.sheet-actions { display: flex; gap: 8px; margin-top: 10px; }
.sheet-actions .btn { flex: 0 0 auto; }

/* `auto-fit`: 국가가 하나면 카드가 패널 폭을 다 쓴다. `auto-fill` 은 빈 열을 남겨 카드 하나가 1/3 폭에 갇혔다(실측 2026-09-21). */
.locate-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 12px; }
/* `min-width: 0` 둘은 진행 상자 때문이다. 상자의 한 줄짜리 설명(nowrap)이 카드와 그 안의 칸을 제 폭만큼 넓히려 들어,
   막지 않으면 버튼 열이 카드 밖으로 뻗고 옆 칸이 한 글자 폭이 된다(실측 2026-09-21). 상자는 `flex-wrap` 으로 카드
   아래 한 줄을 통째로 쓴다(`base.html` 의 `data-job-slot`). */
.locate-card { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.locate-card > div:first-child { flex: 1 1 140px; min-width: 0; }
.locate-card > .job-row { flex: 0 0 100%; min-width: 0; padding: 10px 0 0 !important; border-top: 1px solid var(--border); background: transparent; }
.locate-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; flex: 0 0 auto; }
.locate-actions form { margin: 0; }
.locate-actions .btn { width: 100%; }
.menu-form input[type=text] { width: 100%; margin-bottom: 6px; }
.menu-form .hint { display: block; margin: -2px 0 6px; }
.locate-card .sub { display: block; color: var(--text-3); font-size: 12px; margin-top: 3px; }
.ref + .ref { margin-top: 6px; }
.ref > a { font-weight: 500; }
a.stat { text-decoration: none; color: inherit; }
a.stat:hover { border-color: var(--accent); text-decoration: none; }
blockquote.evidence {
  margin: 0; padding: 8px 12px; border-left: 3px solid var(--info);
  background: var(--surface-2); border-radius: 0 8px 8px 0; font-size: 13.5px; line-height: 1.55;
}

/* 조회 화면: 필터 바 · 페이지 이동 · 좌표 분포 */
.filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px 16px; align-items: start;
}
.filters .form-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.pager {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 14px 18px; border-top: 1px solid var(--border); font-size: 13px;
}
.scatter {
  display: block; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); fill: var(--accent); fill-opacity: .55;
}
@media (prefers-color-scheme: dark) { .scatter { fill-opacity: .7; } }
/* 칩이 링크이기도 하다(브랜드 → 그 브랜드의 매장 목록). */
a.chip { text-decoration: none; }
a.chip:hover { background: var(--accent-soft); color: var(--accent-text); }

/* 오래 걸리는 작업(수집·추출·적재)의 진행 표시. 버튼 자리에서 도는 작은 스피너다. */
.spinner {
  display: inline-block; width: 12px; height: 12px; vertical-align: -1px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn:disabled { opacity: .65; cursor: progress; }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* 일괄 검수 — 선택 열과 헤더의 동작 묶음 */
th.pick, td.pick { width: 34px; padding-right: 0; }
th.pick input, td.pick input { display: block; }
.bulk-actions { display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* 대상 브랜드 — 장소 안의 매장은 장소 행 아래 들여쓴다 */
.store-row td.title { padding-left: 28px; }
.store-row .store-mark { color: var(--text-3); margin-right: 6px; }

/* AI 검수 문제 목록 */
.alert ul.issues { margin: 6px 0 0; padding-left: 18px; }
.alert ul.issues li { margin: 3px 0; }

/* 오래 걸리는 버튼의 진행 표시 — 누른 자리 바로 아래 한 줄(app/admin/progress.py) */
.job-row > td, .job-row { padding: 10px 14px !important; background: var(--surface-2); border-top: 0; }
.job { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.job b { font-weight: 600; }
.job .spinner { flex: none; }
.job-check { color: var(--ok); font-weight: 700; }
.job-detail { color: var(--text-3); font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-time { margin-left: auto; flex: none; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.job-steps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.job-step { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
            background: var(--surface-3); color: var(--text-3); font-size: 12px; }
.job-step.now { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.job-step i { font-style: normal; opacity: .75; font-variant-numeric: tabular-nums; }

/* 브랜드 행의 "앱 미리보기" — 아이콘 색이 상태다. 모달은 앱 화면을 흉내 낸 작은 목업이다. */
.app-peek { opacity: .75; vertical-align: middle; margin-left: 2px; }
.app-peek:hover { opacity: 1; }
.app-peek-own { color: var(--ok); }
.app-peek-venue { color: var(--info); }
.app-peek-none, .app-peek-no-benefit { color: var(--text-3); }
.app-mock { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.app-mock-pin { display: flex; align-items: center; gap: 6px; font-weight: 650; }
.app-mock-pin .sub { margin-left: 4px; font-weight: 400; }
.app-mock-pin-own { color: var(--ok); }
.app-mock-pin-venue { color: var(--info); }
.app-mock-pin-none, .app-mock-pin-no-benefit { color: var(--text-3); }
.app-mock-benefit { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px; display: flex; flex-direction: column; gap: 2px; }
.app-mock-benefit b { font-size: 13.5px; }
.app-mock-benefit span { font-size: 12.5px; color: var(--text-2); }
.app-mock-benefit small { font-size: 11.5px; color: var(--text-3); }
.app-mock-benefit.muted b { color: var(--text-3); font-weight: 500; }
