:root {
  --bg: #F2F4F3;
  --surface: #FFFFFF;
  --surface-2: #F7F8F7;
  --ink: #16201D;
  --ink-2: #2D3834;
  --muted: #5B6763;
  --line: #E1E5E3;
  --line-2: #E8ECEA;
  --accent: #1F5F4F;
  --accent-ink: #16463A;
  --accent-soft: #E3EEE9;
  --warn: #8A4A0F;
  --warn-bg: #FFF4E5;
  --warn-icon: #FBD9A8;
  --danger: #B42318;
  --danger-bg: #FDECEA;
  --radius: 18px;
  --font: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
svg { flex-shrink: 0; }

/* ---------- 공통 컴포넌트 ---------- */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--ink); background: #CFE5DA;
  flex-shrink: 0;
}
.avatar.sm { width: 22px; height: 22px; font-size: 10px; border: 2px solid var(--surface); }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar + .avatar { margin-left: -7px; }

.tile {
  width: 42px; height: 42px; border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700; flex-shrink: 0;
  background: #E4E9E7;
}
.tile.lg { width: 60px; height: 60px; border-radius: 18px; font-size: 26px; }
.cat-스트리밍 { background: #F6D5D2; }
.cat-금융 { background: #D9E4F2; }
.cat-쇼핑 { background: #FBE3C4; }
.cat-공공·행정 { background: #DCE9E3; }
.cat-통신 { background: #E6DEF1; }
.cat-기타 { background: #EFE6D3; }

.tag { font-size: 12px; padding: 3px 9px; border-radius: 10px; background: var(--surface); color: #3F4A46; font-style: normal; }
.tag.accent { background: #D5E8DF; color: var(--accent-ink); font-weight: 500; }
.tag.warn { background: var(--warn-bg); color: var(--warn); font-weight: 500; }
.tag.danger { background: var(--danger-bg); color: var(--danger); font-weight: 500; }

.btn {
  height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid #DCE1DF;
  background: var(--surface); font-size: 15px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; color: var(--ink);
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.primary:hover { background: var(--accent-ink); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { height: 36px; padding: 0 12px; border-radius: 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 0; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink); text-decoration: none;
}
.icon-btn.filled { background: var(--surface); }
.icon-btn.soft { background: var(--bg); width: 40px; height: 40px; border-radius: 10px; }

.card { background: var(--surface); border-radius: var(--radius); }
.field-list { padding: 4px 16px; }
.field { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.field:last-child { border-bottom: 0; }
.field-body { flex: 1; min-width: 0; }
.field-label { margin: 0; font-size: 12px; color: var(--muted); }
.field-value { margin: 2px 0 0; font-size: 15px; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); letter-spacing: .3px; }
.memo { white-space: pre-wrap; padding: 14px 16px; margin: 0; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.section-title { margin: 24px 0 10px; font-size: 14px; font-weight: 700; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; height: 36px; padding: 0 14px; border-radius: 18px;
  border: 1px solid #DCE1DF; background: var(--surface); font-size: 13px;
}
.chip.on, .chip-radio input:checked + span {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700;
}
.chip-radio { position: relative; }
.chip-radio input { position: absolute; opacity: 0; pointer-events: none; }
.chip-radio span {
  display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 18px;
  border: 1px solid #DCE1DF; background: var(--surface); font-size: 13px; cursor: pointer;
}
.chip-radio input:focus-visible + span { outline: 2.5px solid var(--accent); outline-offset: 2px; }

.search {
  display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px;
  background: var(--surface); border-radius: 14px; color: var(--muted); border: 1px solid transparent;
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 15px; color: var(--ink); }

.list { display: flex; flex-direction: column; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line-2);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); color: var(--ink); }
.row.active { background: var(--accent-soft); }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; font-size: 15px; font-weight: 500; }
.row-sub { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.stale { font-size: 11px; font-weight: 500; color: var(--warn); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 14px; }

.banner {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px;
  background: var(--warn-bg); color: var(--ink); text-decoration: none; border: 0; width: 100%; text-align: left;
}
.banner-icon {
  width: 36px; height: 36px; border-radius: 12px; background: var(--warn-icon); color: #7A3E12;
  display: flex; align-items: center; justify-content: center;
}
.banner strong { display: block; font-size: 14px; }
.banner small { display: block; font-size: 12px; color: #6B4A1F; }

/* ---------- 폼 ---------- */
.form { display: flex; flex-direction: column; gap: 18px; }
fieldset.form-field { border: 0; padding: 0; margin: 0; min-width: 0; }
.form-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: #3F4A46; }
.input, .select, .textarea {
  height: 48px; padding: 0 14px; border: 1px solid #DCE1DF; border-radius: 12px;
  background: var(--surface); font-size: 15px; color: var(--ink); font-weight: 400; width: 100%;
}
.textarea { height: auto; padding: 12px 14px; resize: vertical; min-height: 88px; font-size: 14px; }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--accent); }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }
.input-row .icon-btn { width: 48px; height: 48px; border: 1px solid #DCE1DF; background: var(--surface); border-radius: 12px; }
.strength { display: flex; align-items: center; gap: 8px; }
.strength-bars { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.strength-bars span { height: 5px; border-radius: 3px; background: #DCE1DF; }
.strength-bars span.on { background: var(--accent); }
.strength-label { font-size: 12px; font-weight: 700; color: var(--accent); min-width: 56px; text-align: right; }
.gen {
  background: var(--surface); border-radius: 14px; padding: 12px 14px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; font-size: 13px; font-weight: 400; color: var(--ink);
}
.gen label { display: flex; align-items: center; gap: 6px; }
.gen input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.gen input[type="number"] { width: 64px; height: 36px; padding: 0 8px; border: 1px solid #DCE1DF; border-radius: 8px; }
.share-list { display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; padding: 4px 14px; }
.share-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-weight: 400; color: var(--ink); }
.share-row:last-child { border-bottom: 0; }
.share-row span.name { flex: 1; font-size: 14px; }
.share-row .select { width: auto; height: 38px; font-size: 13px; padding: 0 10px; }
.hint { margin: 0; font-size: 12px; color: var(--muted); font-weight: 400; }
.error-text { margin: 0; min-height: 20px; font-size: 13px; color: var(--danger); text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   모바일 금고 (index.html)
   ============================================================ */
.phone {
  max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; position: relative;
}
.top { padding: 24px 20px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.top.compact { padding: 12px 8px 0; }
.top-actions { display: flex; gap: 6px; flex-shrink: 0; }
.top h1 { margin: 2px 0 0; font-size: 22px; font-weight: 700; letter-spacing: -.4px; }
.top p { margin: 0; font-size: 13px; color: var(--muted); }
.top .title { margin: 0; font-size: 18px; font-weight: 700; flex: 1; }
.pad { padding: 0 20px; }
.scroll { flex: 1; padding: 6px 20px 120px; }
.banner-wrap { margin-top: 12px; }
.chips-bar { padding-top: 16px; padding-bottom: 6px; }
.detail-fields { margin-top: 20px; }
.count-label { margin: 8px 0; font-size: 12px; font-weight: 500; color: var(--muted); }
.fab {
  position: fixed; right: max(20px, calc(50% - 220px)); bottom: calc(24px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(22, 32, 29, .22);
}
.fab:hover { color: #fff; background: var(--accent-ink); }
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line);
}
.bottom-bar-inner { max-width: 440px; margin: 0 auto; display: flex; gap: 10px; }
.bottom-bar .btn { height: 52px; }
.bottom-bar .grow { flex: 1; }

.lock { display: flex; flex-direction: column; align-items: center; padding: 56px 28px 32px; min-height: 100vh; min-height: 100dvh; }
.brand-mark { width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; }
.lock h1 { margin: 18px 0 6px; font-size: 24px; letter-spacing: -.4px; }
.lock > p { margin: 0; font-size: 14px; }
.lock-label { margin: 36px 0 14px !important; font-size: 13px !important; font-weight: 500; color: var(--muted); }
.who { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.who-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; background: transparent; border: 0; padding: 4px; min-width: 60px; font-size: 12px; }
.who-btn .avatar { opacity: .75; }
.who-btn.on .avatar { opacity: 1; outline: 2.5px solid var(--accent); outline-offset: 3px; }
.who-btn em { display: block; font-style: normal; font-size: 10px; color: var(--muted); }
.lock-prompt { margin: 32px 0 14px !important; font-size: 14px; }
.dots { display: flex; gap: 14px; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #9AA5A1; }
.dot.on { background: var(--accent); border-color: var(--accent); }
.lock .error-text { margin-top: 14px; }
.keypad { margin-top: auto; padding-top: 24px; width: 100%; max-width: 340px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.key { height: 60px; border: 0; border-radius: 18px; background: var(--surface); font-size: 24px; font-weight: 500; }
.key:active { background: var(--line); }
.key.ghost { background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.key:disabled { opacity: .4; }

.detail-head { display: flex; align-items: center; gap: 14px; }
.detail-head h1 { margin: 0; font-size: 22px; letter-spacing: -.4px; }
.detail-head .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.people { padding: 6px 16px; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.person .name { flex: 1; }
.person small { font-size: 12px; color: var(--muted); }
.log { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: #3F4A46; margin: 0; padding: 0; list-style: none; }

/* ============================================================
   관리자 (admin.html)
   ============================================================ */
.admin { min-height: 100vh; display: flex; flex-wrap: wrap; align-items: stretch; }
.side {
  flex: 1 1 220px; max-width: 100%; padding: 24px 16px; background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; font-size: 17px; font-weight: 700; }
.side-brand .brand-mark { width: 36px; height: 36px; border-radius: 12px; }
.nav-link {
  height: 44px; padding: 0 12px; border-radius: 12px; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; font-size: 14px; color: var(--ink); text-decoration: none; border: 0; background: transparent; width: 100%;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.nav-link .count { font-weight: 500; color: var(--muted); }
.side-sep { height: 1px; background: var(--line-2); margin: 12px 4px; }
.side-foot { margin-top: auto; padding: 12px 8px 0; font-size: 12px; color: var(--muted); }
.main { flex: 999 1 560px; min-width: 0; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.main-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.main-head h1 { margin: 0; font-size: 22px; flex: 1 1 auto; }
.main-head .search { flex: 1 1 280px; border-color: var(--line); height: 46px; }
.split { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.split > .list-pane { flex: 1 1 320px; min-width: 0; }
.panel { padding: 24px; }
.split > .panel { flex: 999 1 440px; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 22px; }
.panel-head .grow { flex: 1; min-width: 160px; }
.panel-head p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.grid-2 { margin-top: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-2 .box { background: var(--surface-2); border-radius: 14px; padding: 14px; min-width: 0; }
.actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 10px; }
.panel .form .gen, .panel .form .share-list { background: var(--surface-2); }
.filter-row { display: flex; gap: 8px; padding: 0 0 10px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .who-cell { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { display: block; width: 36px; height: 36px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch input:checked + span { border-color: var(--ink); box-shadow: inset 0 0 0 3px var(--surface); }
.swatch input:focus-visible + span { outline: 2.5px solid var(--accent); outline-offset: 2px; }

.activity { list-style: none; margin: 0; padding: 4px 16px; }
.activity li { display: flex; gap: 12px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.activity li:last-child { border-bottom: 0; }
.activity time { font-size: 12px; color: var(--muted); min-width: 120px; }

@media (max-width: 860px) {
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-brand { padding: 0 8px 0 0; width: 100%; }
  .side .nav-link { width: auto; }
  .side-sep, .side-foot { display: none; }
  .main { padding: 16px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
