/* data-web 공통 스타일 — 모든 화면이 이 파일 하나를 쓴다. 화면별 스타일은 그 폴더의 page.css로 */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #1d2330;
  --muted: #667085;
  --line: #e3e6eb;
  --accent: #2f6fde;
  --accent-ink: #ffffff;
  --danger: #c43d3d;
  --warn-bg: #fff6e0;
  --warn-ink: #8a5a00;
  --ok: #1f8a4c;
  --radius: 8px;
  --font: "Pretendard", "맑은 고딕", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light;
}
/* 화면 테마: <html data-theme="light|dark">. 없으면(시스템) Windows 설정을 따른다 — theme.js가 정함 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --surface: #1c2027; --ink: #e6e9ef; --muted: #9aa3b2; --line: #2c323c;
    --accent: #5b8ff0; --warn-bg: #3a2f14; --warn-ink: #f1c45a; --danger: #ef6b6b; --ok: #4cc27f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171c; --surface: #1c2027; --ink: #e6e9ef; --muted: #9aa3b2; --line: #2c323c;
  --accent: #5b8ff0; --warn-bg: #3a2f14; --warn-ink: #f1c45a; --danger: #ef6b6b; --ok: #4cc27f;
  color-scheme: dark;
}

/* 테마 바꾸기 단추 (layout.js) */
.theme-switch { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.theme-switch button { border: 0; background: var(--surface); color: var(--muted); padding: 4px 9px; cursor: pointer; font-size: 12px; }
.theme-switch button + button { border-left: 1px solid var(--line); }
.theme-switch button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.login-theme { position: fixed; top: 14px; right: 14px; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); background: var(--bg); color: var(--ink); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-outline { color: var(--danger); }
.btn-danger-outline:hover { border-color: var(--danger); }
.shell-main { min-height: 0; }

/* 대화 상자 (modal.js) */
dialog.modal { border: 0; border-radius: 12px; padding: 0; width: min(640px, 92vw); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
dialog.modal::backdrop { background: rgb(0 0 0 / .35); }
dialog.modal form { padding: 20px 22px 18px; display: grid; gap: 12px; }
dialog.modal h2 { margin: 0; font-size: 17px; }
.modal-body { font-size: 14px; max-height: 60vh; overflow: auto; }
.modal-body p { margin: 0 0 8px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
table.diff { border-collapse: collapse; width: 100%; font-size: 12px; margin-top: 6px; }
table.diff th, table.diff td { border: 1px solid var(--line); padding: 4px 6px; text-align: left; word-break: break-all; }
table.diff td:first-child { color: var(--muted); width: 40px; }

/* 잠깐 알림 (modal.js toast) */
#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 50; }
.toast { padding: 10px 14px; border-radius: var(--radius); background: var(--ink); color: var(--surface); font-size: 13px; box-shadow: 0 6px 20px rgb(0 0 0 / .2); max-width: 420px; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }

/* 실시간 변경 알림 (notify.js) — 오른쪽 위, 위쪽 막대 바로 아래 */
.dw-notes { position: fixed; top: 62px; right: 16px; display: grid; gap: 8px; z-index: 60; width: min(420px, calc(100vw - 32px)); }
.dw-note {
  display: block; padding: 9px 12px 9px 14px; border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none;
  border: 1px solid var(--line); border-left: 4px solid var(--c, var(--accent)); box-shadow: 0 8px 24px rgb(0 0 0 / .18); font-size: 13px;
  animation: dw-note-in .18s ease-out;
}
.dw-note:hover { border-color: var(--c, var(--accent)); }
.dw-note-h { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; padding-right: 18px; position: relative; }
.dw-note-src { color: var(--c, var(--accent)); }
.dw-note-s { margin-top: 3px; word-break: break-all; }
.dw-note ul { margin: 4px 0 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
.dw-note-x { position: absolute; right: -6px; top: -4px; border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; line-height: 1; }
@keyframes dw-note-in { from { opacity: 0; transform: translateY(-6px); } }
.dw-bell-wrap { position: relative; }
.dw-bell { position: relative; padding: 0 10px; }
.bell-n { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.dw-bell-pop {
  position: absolute; top: calc(100% + 6px); right: 0; width: min(440px, 90vw); max-height: 70vh; overflow: auto; z-index: 70;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgb(0 0 0 / .2); text-align: left;
}
.dw-bell-row { display: block; padding: 8px 12px; border-left: 3px solid var(--c, var(--accent)); border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 13px; }
.dw-bell-row:hover { background: var(--bg); }
.dw-bell-row .dim { word-break: break-all; }
.dw-bell-all { display: block; padding: 9px 12px; text-align: center; font-size: 13px; }

.field { display: grid; gap: 4px; }
.field label { font-size: 13px; color: var(--muted); }
.input {
  height: 38px; padding: 0 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
}
.input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }

.alert { padding: 10px 12px; border-radius: var(--radius); font-size: 13px; }
.alert-error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.alert-warn { background: var(--warn-bg); color: var(--warn-ink); }
[hidden] { display: none !important; }

/* ── 로그인 후 화면 틀 (layout.js가 그린다) ── */
.shell { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 52px 1fr; height: 100vh; }
.shell-top {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.shell-brand { font-weight: 700; letter-spacing: -.01em; }
.shell-left { display: flex; align-items: center; gap: 14px; }

/* ── 지금 데이터(5클/2클) 표시 — 색은 layout.js가 --src-color로 넣는다 ── */
:root { --src-color: var(--accent); }
.shell-top { border-top: 4px solid var(--src-color); }
.shell-nav a[aria-current="page"] { background: color-mix(in srgb, var(--src-color) 14%, transparent); color: var(--src-color); }
.src-badge {
  padding: 3px 12px; border-radius: 99px; font-weight: 700; font-size: 14px;
  background: var(--src-color); color: #fff; white-space: nowrap;
}
.src-badge.src-none { background: var(--danger); }
.src-switch { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.src-switch button {
  border: 0; background: var(--surface); padding: 5px 12px; cursor: pointer; font-size: 13px; color: var(--muted);
}
.src-switch button + button { border-left: 1px solid var(--line); }
.src-switch button:hover:not([aria-pressed="true"]):not(:disabled) { color: var(--c); }
.src-switch button[aria-pressed="true"] { background: var(--c); color: #fff; font-weight: 600; cursor: default; }
.src-switch button:disabled { opacity: .4; cursor: not-allowed; }
.shell-user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.shell-nav { background: var(--surface); border-right: 1px solid var(--line); padding: 10px 8px; overflow: auto; }
.shell-nav a {
  display: block; padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none;
}
.shell-nav a:hover { background: var(--bg); }
.shell-nav a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 600; }
.shell-nav .nav-group { margin: 14px 10px 4px; font-size: 12px; color: var(--muted); }
/* 데이터 툴 나무: 분류(펼치기) → 파일 */
.shell-nav .nav-section { margin-top: 10px; font-weight: 700; }
/* 큰 묶음 (데이터 툴 · 도구) — 펼치기/접기 */
.shell-nav .nav-top { margin-top: 10px; }
.shell-nav .nav-top > summary {
  list-style: none; cursor: pointer; padding: 8px 10px; border-radius: 6px; font-weight: 700; color: var(--ink); user-select: none;
}
.shell-nav .nav-top > summary::-webkit-details-marker { display: none; }
.shell-nav .nav-top > summary::before { content: '▸'; display: inline-block; width: 16px; color: var(--muted); transition: transform .1s; }
.shell-nav .nav-top[open] > summary::before { transform: rotate(90deg); }
.shell-nav .nav-top > summary:hover { background: var(--bg); }
.shell-nav .nav-tree { margin: 2px 0 0 6px; padding-left: 6px; border-left: 1px solid var(--line); }
.shell-nav .nav-cat > summary {
  list-style: none; cursor: pointer; padding: 6px 10px; border-radius: 6px; font-size: 13px; color: var(--ink); user-select: none;
}
.shell-nav .nav-cat > summary::-webkit-details-marker { display: none; }
.shell-nav .nav-cat > summary::before { content: '▸'; display: inline-block; width: 14px; color: var(--muted); transition: transform .1s; }
.shell-nav .nav-cat[open] > summary::before { transform: rotate(90deg); }
.shell-nav .nav-cat > summary:hover { background: var(--bg); }
.shell-nav .nav-cat > a { padding: 5px 10px 5px 26px; font-size: 13px; }
.shell-nav .nav-cat > a.nav-series-doc { color: var(--muted); font-style: italic; }
.shell-main { overflow: auto; padding: 24px; }
.page-title { margin: 0 0 16px; font-size: 20px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.muted { color: var(--muted); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); }
.tag-local { color: var(--warn-ink); background: var(--warn-bg); border-color: transparent; }
.tag-web { color: var(--accent); }

/* 변경 이력 항목 (historyView.js — 변경 이력 화면, 편집 화면 '이력') */
.hitems { padding: 4px 12px 12px 26px; font-size: 13px; }
.hitem { padding: 6px 0; border-top: 1px dashed var(--line); }
.hitem:first-child { border-top: 0; }
.hitem .k { display: inline-block; min-width: 34px; font-weight: 600; }
.hitem .k.added { color: var(--ok); } .hitem .k.deleted { color: var(--danger); } .hitem .k.modified { color: var(--accent); }
.hfields { border-collapse: collapse; margin: 4px 0 0 34px; font-size: 12px; }
.hfields td { border: 1px solid var(--line); padding: 3px 8px; word-break: break-all; max-width: 420px; vertical-align: top; }
.hfields td.o { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.hfields td.n { background: color-mix(in srgb, var(--ok) 10%, transparent); }
.hline { margin: 4px 0 0 34px; font: 12px ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all; padding: 3px 8px; border-radius: 4px; }
.hline.o { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.hline.n { background: color-mix(in srgb, var(--ok) 10%, transparent); }
.hrec { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.hrec .hitem { border-top: 0; padding: 2px 0 0; }
