/* 공용 바탕 스타일 (고객 화면·관리 화면) */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --text: #1d1d1b;
  --muted: #64625d;
  --line: #dedcd6;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --accent-soft: #e3ece8;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --danger: #a23b2a;
  --danger-soft: #f8e4e0;
  --ok: #2b6b3f;
  --ok-soft: #e1f0e5;
  --info: #2d5486;
  --info-soft: #e2eaf5;
  --add: #e3f3e6;
  --add-ink: #1f5e2e;
  --del: #fae6e3;
  --del-ink: #8d2c1d;
  --focus: #1f6feb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 2px 8px rgba(0, 0, 0, .04);
  --font: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "D2Coding", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161716;
    --surface: #1f201f;
    --surface-2: #272927;
    --text: #ecebe7;
    --muted: #a5a39d;
    --line: #3a3c39;
    --accent: #7fc0aa;
    --accent-ink: #0f1a16;
    --accent-soft: #23362f;
    --warn: #e6b95c;
    --warn-soft: #3a2f17;
    --danger: #f0907e;
    --danger-soft: #3d2420;
    --ok: #8fd1a2;
    --ok-soft: #1f3526;
    --info: #9cbcec;
    --info-soft: #1e2b3d;
    --add: #1d3524;
    --add-ink: #a9e0b6;
    --del: #3d2420;
    --del-ink: #f3b1a5;
    --focus: #79a8ff;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  overflow-x: hidden;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

h1, h2, h3 { line-height: 1.3; margin: 0; }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }

.skip {
  position: absolute; left: 8px; top: -60px; z-index: 50;
  background: var(--surface); padding: 8px 12px; border-radius: 6px;
}
.skip:focus { top: 8px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.empty { color: var(--muted); padding: 12px 0; margin: 0; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: .9375rem; text-decoration: none; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn-danger.btn-primary { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { min-height: 34px; padding: 4px 10px; font-size: .875rem; }
.link-btn {
  background: none; border: 0; padding: 0; color: var(--accent); font: inherit;
  text-decoration: underline; cursor: pointer;
}
.icon-btn {
  background: none; border: 0; font-size: 1.6rem; line-height: 1; width: 40px; height: 40px;
  border-radius: 8px; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

/* 입력 */
label { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .875rem; margin-top: 2px; }
input[type="text"], input[type="password"], input[type="search"], textarea, select {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 88px; resize: vertical; }
.field { margin-bottom: 16px; }

/* 배지 */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .8125rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.badge-live { background: var(--ok-soft); color: var(--ok); }
.badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-rejected, .badge-failed { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.chip {
  display: inline-block; font-size: .75rem; padding: 0 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); margin-left: 8px; white-space: nowrap;
}
.chip-added, .chip-add, .chip-a, .chip-new { background: var(--add); color: var(--add-ink); }
.chip-deleted, .chip-removed, .chip-d { background: var(--del); color: var(--del-ink); }

/* 카드·구역 */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.section { margin: 28px 0; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.section-head h2 { font-size: 1.25rem; }
.section-desc { margin: -4px 0 12px; color: var(--muted); font-size: .9375rem; }

.notice {
  border-radius: var(--radius); padding: 12px 14px; margin: 12px 0;
  background: var(--info-soft); color: var(--text); border: 1px solid transparent;
}
.notice-error { background: var(--danger-soft); }
.notice-warn { background: var(--warn-soft); }

/* 대화 상자 */
.dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px); background: var(--surface); color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
.dialog-wide { width: min(980px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(20, 20, 18, .45); }
.dialog form { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.dialog-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 12px 8px 20px; border-bottom: 1px solid var(--line);
}
.dialog-head h2 { font-size: 1.125rem; }
.dialog-body { padding: 16px 20px; overflow: auto; }
.dialog-body > p:first-child { margin-top: 0; }
.dialog-actions {
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px 16px; border-top: 1px solid var(--line);
}
.dialog-error { color: var(--danger); margin: 12px 0 0; }

/* 알림 */
.toasts {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 100;
  width: min(480px, calc(100vw - 32px));
}
.toast {
  background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}
.toast-error { background: var(--danger); color: #fff; }

/* diff */
.diff-summary { margin: 0 0 12px; color: var(--muted); font-size: .9375rem; }
.diff-file {
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; background: var(--surface);
  overflow: hidden;
}
.diff-file > summary {
  cursor: pointer; padding: 10px 12px; background: var(--surface-2);
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
}
.diff-path { font-family: var(--mono); font-size: .875rem; word-break: break-all; }
.diff-note { padding: 8px 12px; margin: 0; }
.diff-lines { font-family: var(--mono); font-size: .8125rem; line-height: 1.55; }
.dl { display: flex; }
.dl-sign { flex: 0 0 24px; text-align: center; user-select: none; color: var(--muted); }
.dl-text { flex: 1; white-space: pre-wrap; word-break: break-word; padding-right: 8px; min-width: 0; }
.dl-add { background: var(--add); color: var(--add-ink); }
.dl-add .dl-sign { color: var(--add-ink); }
.dl-del { background: var(--del); color: var(--del-ink); }
.dl-del .dl-sign { color: var(--del-ink); }
.dl-hunk { color: var(--muted); background: var(--surface-2); font-style: italic; }

/* 표 (관리 화면 중심) */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .875rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.spinner {
  display: inline-block; width: .9em; height: .9em; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
