/* ============================================================
   Metech 주주방 디자인 시스템
   - 브랜드 컬러는 로고(초록 로고.png) 실측값 #18544A 에서 파생
   - 폰트 Pretendard (self-host, CSP script-src/font-src 'self')
   - 숫자는 전부 tabular-nums 로 자릿수 정렬
   ============================================================ */

/* ---------- 1. 토큰 ---------- */
:root {
  /* 브랜드 (로고에서 추출) */
  --brand:        #18544A;
  --brand-dark:   #0F3B34;
  --brand-hover:  #14463D;
  --brand-soft:   #EDF3F1;   /* light green highlight */
  --brand-soft-2: #DCE9E5;
  --brand-line:   #C3D8D2;

  /* 중립 */
  --text:      #1B2422;      /* dark charcoal */
  --text-sub:  #66716E;      /* muted text */
  --text-dim:  #939C99;
  --line:      #E2E7E5;
  --line-strong: #CFD6D4;
  --bg:        #F6F8F7;
  --surface:   #FFFFFF;

  /* 상태 (경고/삭제만 red) */
  --danger:      #B3261E;
  --danger-soft: #FCECEA;
  --warn:        #8A6100;
  --warn-soft:   #FDF4E3;

  /* 타이포 스케일 */
  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px;
  --fs-15: 15px; --fs-16: 16px; --fs-17: 17px; --fs-19: 19px;
  --fs-22: 22px; --fs-26: 26px; --fs-32: 32px; --fs-38: 38px;

  /* 간격 스케일 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px;
  --s6: 24px; --s7: 32px; --s8: 40px;

  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 2px rgba(16, 40, 35, .06);
  --shadow-md: 0 4px 16px rgba(16, 40, 35, .08);

  --sidebar-w: 232px;
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont,
          system-ui, 'Malgun Gothic', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-16);
  line-height: 1.6;
  font-feature-settings: 'tnum';
  -webkit-font-smoothing: antialiased;
}

body, button, input, select, textarea, table {
  font-family: var(--font);
}

/* 숫자는 항상 자릿수 고정폭 */
.num, .figure, table.data td, table.data th, .stat .value, input[type="number"] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- 2. 회원 레이아웃 ---------- */
.shell {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 88px;
}

.appbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: var(--s3) var(--s4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
}
.appbar .logo { display: flex; align-items: center; gap: var(--s2); }
.appbar .logo img { height: 26px; width: auto; display: block; }
.appbar .divider { width: 1px; height: 16px; background: var(--line-strong); }
.appbar .page-name {
  font-size: var(--fs-15); font-weight: 600; color: var(--text-sub);
  letter-spacing: -0.01em;
}
.appbar .admin-link {
  font-size: var(--fs-13); font-weight: 600; color: var(--brand);
  border: 1px solid var(--brand-line); background: var(--brand-soft);
  padding: 5px 10px; border-radius: 999px;
}
.appbar .admin-link:hover { text-decoration: none; background: var(--brand-soft-2); }

.content { padding: var(--s4) var(--s4) var(--s6); }

/* ---------- 3. 카드 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s5);
  margin-bottom: var(--s3);
}
.card.flat { box-shadow: none; }
.card-label {
  font-size: var(--fs-14); font-weight: 600; color: var(--text-sub);
  letter-spacing: -0.01em; margin-bottom: var(--s1);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s3);
}
.card-head h2 { font-size: var(--fs-16); }
.card-head a { font-size: var(--fs-14); font-weight: 600; }

/* 숫자 표시 */
.figure {
  font-size: var(--fs-32); font-weight: 700; letter-spacing: -0.03em;
  line-height: 1.2; color: var(--text); word-break: keep-all;
}
.figure .unit {
  font-size: var(--fs-17); font-weight: 600; color: var(--text-sub); margin-left: 3px;
  letter-spacing: -0.01em;
}
.figure.hero { font-size: var(--fs-38); }
.figure.md   { font-size: var(--fs-26); }
.figure.sm   { font-size: var(--fs-19); }
.figure.muted { color: var(--text-dim); font-weight: 600; }

/* 강조 카드: 평가금액 */
.card.accent {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.card.accent .card-label { color: rgba(255, 255, 255, .78); }
.card.accent .figure { color: #fff; }
.card.accent .figure .unit { color: rgba(255, 255, 255, .8); }
.card.accent .hint { color: rgba(255, 255, 255, .72); }

.greeting {
  font-size: var(--fs-19); font-weight: 700; letter-spacing: -0.02em;
  margin: var(--s2) 0 var(--s4);
}
.greeting .name { color: var(--brand); }

.muted { color: var(--text-sub); font-size: var(--fs-15); }
.hint  { color: var(--text-sub); font-size: var(--fs-13); margin-top: var(--s1); }
.mt { margin-top: var(--s4); }
.right { text-align: right; }
.center { text-align: center; }
.inline { display: inline; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.split > .card { margin-bottom: 0; }

.notice {
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  color: var(--brand-dark);
  border-radius: var(--radius);
  padding: var(--s5);
  font-size: var(--fs-17); font-weight: 700; letter-spacing: -0.01em;
  margin-bottom: var(--s3);
}
.notice .sub {
  display: block; margin-top: var(--s2);
  font-size: var(--fs-14); font-weight: 500; color: var(--text-sub);
}

/* ---------- 4. 목록 / 표 ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: block; padding: var(--s3) 0; color: var(--text); }
.list a:hover { text-decoration: none; }
.list .item-title {
  font-weight: 600; font-size: var(--fs-16); letter-spacing: -0.01em;
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list .item-meta { color: var(--text-sub); font-size: var(--fs-13); margin-top: 2px; }

.kv { width: 100%; border-collapse: collapse; }
.kv th, .kv td {
  padding: var(--s3) 0; border-bottom: 1px solid var(--line);
  text-align: left; font-size: var(--fs-15);
}
.kv th { color: var(--text-sub); font-weight: 600; width: 42%; }
.kv td { font-weight: 600; }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: 0; }

/* 변동 이력 */
.moves { list-style: none; margin: 0; padding: 0; }
.moves li {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) 0;
}
.moves li + li { border-top: 1px solid var(--line); }
.moves .when { font-size: var(--fs-13); color: var(--text-sub); }
.moves .what { font-size: var(--fs-15); font-weight: 600; }
.moves .delta { font-size: var(--fs-17); font-weight: 700; font-variant-numeric: tabular-nums; }
.moves .delta.plus  { color: var(--brand); }
.moves .delta.minus { color: var(--danger); }
.moves .delta.void  { color: var(--text-dim); text-decoration: line-through; }

/* ---------- 5. 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  border-radius: var(--radius-sm);
  padding: 12px var(--s4);
  font-size: var(--fs-16); font-weight: 600; letter-spacing: -0.01em;
  cursor: pointer; font-family: inherit; line-height: 1.2;
  transition: background .12s ease;
}
.btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); text-decoration: none; color: #fff; }
.btn.block { display: flex; width: 100%; }
.btn.ghost { background: var(--surface); color: var(--brand); border-color: var(--brand-line); }
.btn.ghost:hover { background: var(--brand-soft); color: var(--brand-dark); }
.btn.subtle { background: var(--surface); color: var(--text-sub); border-color: var(--line-strong); }
.btn.subtle:hover { background: var(--bg); color: var(--text); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #E7C3BF; }
.btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn.sm { padding: 7px 11px; font-size: var(--fs-13); border-radius: 6px; }
.btn.lg { padding: 15px var(--s5); font-size: var(--fs-17); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; }

/* ---------- 6. 폼 ---------- */
.field { margin-bottom: var(--s4); }
.field > label {
  display: block; font-size: var(--fs-14); font-weight: 600;
  color: var(--text); margin-bottom: 6px;
}
.field input[type="text"], .field input[type="tel"], .field input[type="password"],
.field input[type="number"], .field input[type="search"], .field input[type="date"],
.field input[type="datetime-local"], .field select, .field textarea {
  width: 100%;
  padding: 12px var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: var(--fs-16);
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  line-height: 1.4;
}
.field textarea { min-height: 180px; resize: vertical; line-height: 1.7; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft-2);
}
.field input:disabled, .field input[readonly] { background: var(--bg); color: var(--text-sub); }
.field .row { display: flex; gap: var(--s2); }
.field .row input { flex: 1; min-width: 0; }
.field .err { color: var(--danger); font-size: var(--fs-13); margin-top: 5px; font-weight: 600; }
.field .desc { color: var(--text-sub); font-size: var(--fs-13); margin-top: 5px; }
.checkbox { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-15); }
.checkbox input { width: 19px; height: 19px; accent-color: var(--brand); }

/* ---------- 7. 알림 / 뱃지 ---------- */
.flash {
  border-radius: var(--radius-sm); padding: 12px var(--s3); margin-bottom: var(--s3);
  font-size: var(--fs-15); font-weight: 600; border: 1px solid transparent;
}
.flash.success { background: var(--brand-soft); color: var(--brand-dark); border-color: var(--brand-line); }
.flash.danger  { background: var(--danger-soft); color: var(--danger); border-color: #EFCBC7; }
.flash.warning { background: var(--warn-soft); color: var(--warn); border-color: #EEDCB4; }
.flash.info    { background: var(--brand-soft); color: var(--brand-dark); border-color: var(--brand-line); }

.badge {
  display: inline-block; font-size: var(--fs-12); font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg); color: var(--text-sub); border: 1px solid var(--line-strong);
  white-space: nowrap;
}
.badge.ok   { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-line); }
.badge.wait { background: var(--warn-soft); color: var(--warn); border-color: #EEDCB4; }
.badge.off  { background: var(--danger-soft); color: var(--danger); border-color: #EFCBC7; }
.badge.solid { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- 8. 하단 탭 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 560px; margin: 0 auto;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: flex; z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 10px; font-size: var(--fs-11); font-weight: 600;
  color: var(--text-dim); letter-spacing: -0.01em;
}
.tabbar a:hover { text-decoration: none; }
.tabbar a.active { color: var(--brand); }
.tabbar svg { width: 22px; height: 22px; display: block; }

/* ---------- 9. 인증 화면 ---------- */
.auth-wrap { max-width: 440px; margin: 0 auto; padding: var(--s8) var(--s4) var(--s8); }
.brand-block { text-align: center; margin-bottom: var(--s6); }
.brand-block img { height: 40px; width: auto; }
.brand-block .service {
  margin-top: var(--s3); font-size: var(--fs-19); font-weight: 700;
  letter-spacing: -0.02em; color: var(--text);
}
.brand-block .sub { color: var(--text-sub); font-size: var(--fs-14); margin-top: 2px; }

.post-body {
  font-size: var(--fs-16); line-height: 1.8; white-space: pre-wrap;
  word-break: break-word; color: var(--text);
}
.post-title { font-size: var(--fs-19); letter-spacing: -0.02em; margin-bottom: 4px; }

.pager { display: flex; gap: var(--s2); justify-content: center; margin: var(--s5) 0 0; }
.empty { padding: var(--s6) 0; text-align: center; color: var(--text-dim); font-size: var(--fs-15); }

/* ============================================================
   10. 관리자 레이아웃 — 사이드바 + 업무용 테이블
   ============================================================ */
body.admin { background: var(--bg); }

.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--brand-dark); color: #fff;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand {
  padding: var(--s5) var(--s4) var(--s4);
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.sidebar .brand img { height: 24px; width: auto; display: block; }
.sidebar .brand .role {
  margin-top: 7px; font-size: var(--fs-12); font-weight: 600;
  color: rgba(255, 255, 255, .58); letter-spacing: .04em;
}
.sidebar nav { padding: var(--s3) 0 var(--s6); flex: 1; }
.sidebar .group {
  padding: var(--s4) var(--s4) 5px;
  font-size: var(--fs-11); font-weight: 700; letter-spacing: .08em;
  color: rgba(255, 255, 255, .42); text-transform: uppercase;
}
.sidebar a.item {
  display: flex; align-items: center; gap: var(--s2);
  padding: 9px var(--s4); color: rgba(255, 255, 255, .8);
  font-size: var(--fs-14); font-weight: 500; border-left: 3px solid transparent;
}
.sidebar a.item:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.sidebar a.item.active {
  background: rgba(255, 255, 255, .1); color: #fff; font-weight: 700;
  border-left-color: #7FC5B2;
}
.sidebar .foot {
  padding: var(--s4); border-top: 1px solid rgba(255, 255, 255, .1);
  font-size: var(--fs-12); color: rgba(255, 255, 255, .55);
}
.sidebar .foot a { color: rgba(255, 255, 255, .8); }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-top {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: var(--s4) var(--s6);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  position: sticky; top: 0; z-index: 15;
}
.admin-top h1 { font-size: var(--fs-19); letter-spacing: -0.02em; }
.admin-top .sub { font-size: var(--fs-13); color: var(--text-sub); font-weight: 500; margin-top: 1px; }
.admin-top .who { display: flex; align-items: center; gap: var(--s3); font-size: var(--fs-13); color: var(--text-sub); }
.admin-body { padding: var(--s5) var(--s6) var(--s8); }

.sidebar-toggle, .sidebar-toggle-label { display: none; }

/* 관리자 통계 */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: var(--s3); margin-bottom: var(--s5);
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--s4);
}
.stat .label { font-size: var(--fs-13); color: var(--text-sub); font-weight: 600; }
.stat .value {
  font-size: var(--fs-26); font-weight: 700; letter-spacing: -0.03em;
  margin-top: 2px; line-height: 1.25;
}
.stat .value .unit { font-size: var(--fs-14); font-weight: 600; color: var(--text-sub); margin-left: 2px; }
.stat.primary { background: var(--brand); border-color: var(--brand); }
.stat.primary .label { color: rgba(255, 255, 255, .78); }
.stat.primary .value { color: #fff; }
.stat.primary .value .unit { color: rgba(255, 255, 255, .8); }
.stat.warn .value { color: var(--warn); }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: var(--s4);
}
.panel > .panel-head {
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
}
.panel > .panel-head h2 { font-size: var(--fs-16); }
.panel > .panel-body { padding: var(--s5); }
.panel.pad { padding: var(--s5); }

.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); align-items: start; }
.cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s4); align-items: start; }

/* 업무용 표 */
.table-wrap { width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-14); }
table.data th, table.data td {
  padding: 10px var(--s3); border-bottom: 1px solid var(--line);
  text-align: left; white-space: nowrap; vertical-align: middle;
}
table.data thead th {
  background: var(--bg); font-size: var(--fs-12); color: var(--text-sub);
  font-weight: 700; letter-spacing: .01em; position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--line-strong);
}
table.data tbody tr:hover { background: #FAFCFB; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.strong { font-weight: 700; }
table.data td.wrap { white-space: normal; }
table.data tfoot td {
  background: var(--brand-soft); font-weight: 700; border-top: 1px solid var(--brand-line);
}
table.data .rowlink { font-weight: 600; }
table.data td.actions { text-align: right; }
table.data td.actions > * + * { margin-left: 4px; }

.toolbar {
  display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center;
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line);
}
.toolbar input[type="search"], .toolbar input[type="date"], .toolbar select {
  padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px;
  font-size: var(--fs-14); font-family: inherit; background: var(--surface); color: var(--text);
}
.toolbar input[type="search"] { min-width: 210px; }
.toolbar .spacer { flex: 1; }
.toolbar label { font-size: var(--fs-13); color: var(--text-sub); font-weight: 600; }

.form-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--s6); max-width: 760px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s4); }
.form-grid .full { grid-column: 1 / -1; }

/* 거래 preview */
.preview-flow { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--s4); align-items: center; }
.preview-side { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); }
.preview-side .who { font-size: var(--fs-13); color: var(--text-sub); font-weight: 600; }
.preview-side .name { font-size: var(--fs-17); font-weight: 700; letter-spacing: -0.02em; margin-bottom: var(--s3); }
.preview-side .before { font-size: var(--fs-15); color: var(--text-sub); text-decoration: line-through; }
.preview-side .after { font-size: var(--fs-26); font-weight: 700; letter-spacing: -0.03em; }
.preview-side .after.plus  { color: var(--brand); }
.preview-side .after.minus { color: var(--text); }
.preview-arrow { font-size: 26px; color: var(--brand); font-weight: 700; }
.preview-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s4); margin-top: var(--s5); }
.preview-sum .cell { background: var(--brand-soft); border: 1px solid var(--brand-line); border-radius: var(--radius); padding: var(--s4); }
.preview-sum .cell .label { font-size: var(--fs-13); color: var(--brand-dark); font-weight: 600; }
.preview-sum .cell .value { font-size: var(--fs-22); font-weight: 700; letter-spacing: -0.02em; }

.warn-box {
  background: var(--warn-soft); border: 1px solid #EEDCB4; color: var(--warn);
  border-radius: var(--radius-sm); padding: var(--s3) var(--s4);
  font-size: var(--fs-13); font-weight: 600;
}

details.inline-form { display: inline-block; }
details.inline-form > summary {
  list-style: none; cursor: pointer; display: inline-flex;
}
details.inline-form > summary::-webkit-details-marker { display: none; }
details.inline-form > .pop {
  position: absolute; right: var(--s6); z-index: 20; margin-top: 6px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: var(--s4); width: 320px; text-align: left; white-space: normal;
}
details.inline-form > .pop .field { margin-bottom: var(--s3); }


/* ---------- 12. 관리자/주주 모드 전환 ---------- */
.mode-switch {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--line-strong); border-radius: 999px;
  overflow: hidden; background: var(--surface);
}
.mode-switch .seg {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-family: inherit; font-size: var(--fs-12); font-weight: 700;
  color: var(--text-sub); padding: 6px 12px; line-height: 1.5; white-space: nowrap;
}
.mode-switch .seg:hover { background: var(--brand-soft); color: var(--brand-dark); }
.mode-switch .seg.active {
  background: var(--brand); color: #fff; cursor: default;
}
.mode-switch form { display: inline-flex; }

/* 미리보기 배너 */
.preview-banner {
  background: var(--warn-soft); border: 1px solid #EEDCB4; color: var(--warn);
  border-radius: var(--radius); padding: var(--s3) var(--s4); margin-bottom: var(--s4);
  font-size: var(--fs-13); font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  flex-wrap: wrap;
}
.preview-frame {
  max-width: 560px; margin: 0 auto;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); padding: var(--s4); pointer-events: none;
}
.preview-frame .card:last-child { margin-bottom: 0; }

/* 유형별 필드 토글 */
.field.is-hidden, .form-grid > .is-hidden { display: none; }

/* 스냅샷 뱃지 */
.asof-bar {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  background: var(--brand-soft); border: 1px solid var(--brand-line);
  border-radius: var(--radius); padding: var(--s3) var(--s4); margin-bottom: var(--s4);
  font-size: var(--fs-13); font-weight: 600; color: var(--brand-dark);
}
.asof-bar form { display: flex; gap: var(--s2); align-items: center; }
.asof-bar select {
  padding: 6px 10px; border: 1px solid var(--brand-line); border-radius: 6px;
  font-family: inherit; font-size: var(--fs-13); background: var(--surface);
}

/* ---------- 11. 반응형 ---------- */
@media (max-width: 900px) {
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .preview-flow { grid-template-columns: 1fr; }
  .preview-arrow { text-align: center; transform: rotate(90deg); }
  .preview-sum { grid-template-columns: 1fr; }

  .admin-layout { display: block; }
  .sidebar {
    position: static; width: auto; height: auto; flex: none;
    max-height: 0; overflow: hidden; padding: 0;
  }
  .sidebar-toggle:checked ~ .admin-layout .sidebar { max-height: 100vh; overflow-y: auto; }
  .sidebar .brand { display: none; }
  .sidebar nav { padding: var(--s2) 0 var(--s4); }
  .mobile-bar {
    display: flex !important; align-items: center; justify-content: space-between;
    gap: var(--s3); background: var(--brand-dark); color: #fff; padding: var(--s3) var(--s4);
    position: sticky; top: 0; z-index: 40;
  }
  .mobile-bar img { height: 22px; }
  .sidebar-toggle-label {
    display: inline-flex !important; align-items: center; gap: 6px; cursor: pointer;
    border: 1px solid rgba(255, 255, 255, .35); border-radius: 6px;
    padding: 6px 10px; font-size: var(--fs-13); font-weight: 600; color: #fff;
  }
  .admin-top { padding: var(--s4); position: static; }
  .admin-body { padding: var(--s4) var(--s4) var(--s7); }
}

@media (min-width: 901px) { .mobile-bar { display: none; } }

@media (max-width: 380px) {
  .figure.hero { font-size: var(--fs-32); }
  .figure { font-size: var(--fs-26); }
  .split { grid-template-columns: 1fr; }
}

@media print {
  .tabbar, .sidebar, .admin-top, .toolbar, .mobile-bar, .btn { display: none !important; }
  body { background: #fff; }
  .panel, .card { border: 0; }
}

/* ============================================================
   11. 모바일 UX 1차 개선 (2026-08-28)
   원칙: 데스크톱 레이아웃은 그대로 두고 모바일에서만 덮어쓴다.
   ============================================================ */

/* ---------- 11-1. 하단 고정 탭바에 콘텐츠가 가리지 않게 ----------
   .tabbar 는 position:fixed 라 문서 흐름에서 빠진다. 하단 여백이 없으면
   키보드가 올라온 상태에서 제출 버튼이 탭바 뒤로 들어간다. */
:root { --tabbar-h: 63px; }
.content {
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s6));
}

/* ---------- 11-2. 한국어 제목 줄바꿈 ----------
   '가입회원' 이 '가입회 / 원' 으로 쪼개지던 문제. 어절 단위로 끊는다. */
h1, h2, h3, .card-label, .greeting, .admin-top h1, .admin-top .sub,
.panel > .panel-head h2, .stat .label, .brand-block .service, .brand-block .sub {
  word-break: keep-all;
  overflow-wrap: anywhere;
}

/* ---------- 11-3. 체크박스 터치 영역 ---------- */
.checkbox { min-height: 44px; gap: var(--s3); }
.checkbox input[type="checkbox"] {
  width: 24px; height: 24px; flex: 0 0 24px; margin: 0;
}
.checkbox label {
  display: flex; align-items: center; min-height: 44px;
  flex: 1; cursor: pointer; margin: 0;
}

/* ---------- 11-4. 비밀번호 표시/숨김 ---------- */
.pw-wrap { position: relative; display: block; }
.pw-wrap > input { width: 100%; padding-right: 52px; }
.pw-toggle {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  background: none; border: 0; border-radius: 8px; cursor: pointer;
  color: var(--text-dim); padding: 0;
}
.pw-toggle:hover { color: var(--text-sub); background: var(--bg); }
.pw-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.pw-toggle svg { width: 21px; height: 21px; display: block; pointer-events: none; }

/* ---------- 11-5. 금액 보조표기 (억/만 단위) ---------- */
.money-main { font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
.money-exact {
  display: block; margin-top: 4px;
  font-size: var(--fs-14); font-weight: 500; color: var(--text-sub);
  font-variant-numeric: tabular-nums; letter-spacing: 0;
}
.card.accent .money-exact { color: rgba(255, 255, 255, .78); }

/* ---------- 11-6. 관리자 총 거래금액 강조 ---------- */
.total-amount {
  background: var(--brand-soft); border: 1px solid var(--brand-line);
  border-radius: var(--radius-sm); padding: var(--s3) var(--s4);
}
.total-amount .money-main { font-size: var(--fs-26); color: var(--brand-dark); }
.total-amount .money-exact { color: var(--brand); }

/* ============================================================
   11-7. 모바일 전용 (<= 768px)
   ============================================================ */
@media (max-width: 768px) {

  /* iOS Safari 는 16px 미만 input 에 포커스하면 페이지를 강제 확대한다.
     확대 후 원래 배율로 돌아오지 않아 레이아웃이 틀어진다. */
  input, select, textarea,
  .toolbar input[type="search"], .toolbar input[type="date"], .toolbar select {
    font-size: 16px !important;
    min-height: 44px;
  }
  .toolbar input[type="search"] { min-width: 0; width: 100%; }
  .toolbar { gap: var(--s2); }
  .toolbar > * { flex: 1 1 140px; }
  .toolbar .spacer { display: none; }
  .checkbox input[type="checkbox"] { min-height: 24px; }

  /* 터치 타깃 44px */
  .btn, .pager a, .pager button, .toolbar .btn, .seg, .sidebar-toggle-label {
    min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .btn.sm { padding-top: 0; padding-bottom: 0; }
  .pager { gap: var(--s3); }
  .card-head a, .panel-head a { min-height: 44px; display: inline-flex; align-items: center; }
  .tabbar a { min-height: 52px; justify-content: center; }

  /* 관리자 사이드바 메뉴 */
  .sidebar a.item { min-height: 44px; font-size: var(--fs-15); }
  .sidebar .foot a { min-height: 44px; display: inline-flex; align-items: center; }

  /* 관리자 헤더: 1줄=제목 / 2줄=모드전환+로그아웃 */
  .admin-top { display: block; }
  .admin-top h1 { font-size: var(--fs-19); }
  .admin-top .who {
    margin-top: var(--s3);
    display: flex; align-items: center; gap: var(--s2);
    flex-wrap: nowrap; justify-content: flex-start;
  }
  .admin-top .who .mode-switch { flex: 0 1 auto; min-width: 0; }
  .admin-top .who > form { flex: 0 0 auto; }
  .mode-switch, .mode-switch .seg, .admin-top .who .btn {
    white-space: nowrap; flex-shrink: 0;
  }
  .mode-switch .seg { min-height: 44px; padding-left: 14px; padding-right: 14px; }

  /* 타이포 하한 */
  table.data thead th { font-size: var(--fs-13); }
  .badge { font-size: var(--fs-13); }
  .field label, label { font-size: var(--fs-14); }
  .hint, .desc { font-size: var(--fs-14); }

  /* ---------- 표 -> 카드 변환 ----------
     .table-wrap.cards 가 붙은 표만 카드가 된다.
     데스크톱 마크업(thead/td)을 그대로 두고 CSS 로만 바꾸므로
     템플릿이 이중화되지 않는다. 라벨은 td[data-label] 에서 읽는다. */
  .table-wrap.cards { overflow-x: visible; }
  .table-wrap.cards table.data,
  .table-wrap.cards table.data tbody,
  .table-wrap.cards table.data tfoot,
  .table-wrap.cards table.data tr,
  .table-wrap.cards table.data td { display: block; width: auto; }
  .table-wrap.cards table.data thead { display: none; }

  .table-wrap.cards table.data tbody tr {
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: var(--s4); margin: var(--s3) var(--s4);
    background: var(--surface);
  }
  .table-wrap.cards table.data tbody tr:hover { background: var(--surface); }
  .table-wrap.cards table.data td {
    white-space: normal; border-bottom: 0; padding: 5px 0;
    display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3);
    text-align: right; font-size: var(--fs-15);
  }
  .table-wrap.cards table.data td::before {
    content: attr(data-label);
    flex: 0 0 auto; text-align: left;
    font-size: var(--fs-13); font-weight: 600; color: var(--text-sub);
  }
  /* 카드 제목 (주주명 / 이름 등) */
  .table-wrap.cards table.data td.m-title {
    display: block; text-align: left; font-size: var(--fs-17); font-weight: 700;
    padding: 0 0 var(--s2); border-bottom: 1px solid var(--line); margin-bottom: var(--s2);
  }
  .table-wrap.cards table.data td.m-title::before { display: none; }
  /* 핵심 수치 (보유주식수 / 지분율) */
  .table-wrap.cards table.data td.m-key {
    padding: 7px 0; font-size: var(--fs-19); font-weight: 700; color: var(--text);
  }
  .table-wrap.cards table.data td.m-key::before {
    font-size: var(--fs-14); font-weight: 600; color: var(--text-sub);
  }
  /* 모바일에서 숨기고 상세로 넘기는 열 */
  .table-wrap.cards table.data td.m-hide { display: none; }
  /* 액션 버튼 줄 */
  .table-wrap.cards table.data td.actions {
    display: flex; gap: var(--s2);
    margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line);
    text-align: center;
  }
  .table-wrap.cards table.data td.actions::before { display: none; }
  .table-wrap.cards table.data td.actions > * { flex: 1; margin-left: 0 !important; }
  /* 빈 상태 / 합계 */
  .table-wrap.cards table.data td.empty { display: block; text-align: center; }
  .table-wrap.cards table.data td.empty::before { display: none; }
  .table-wrap.cards table.data tfoot tr {
    display: block; margin: var(--s3) var(--s4) 0; padding: var(--s4);
    background: var(--brand-soft); border: 1px solid var(--brand-line);
    border-radius: var(--radius-sm);
  }
  .table-wrap.cards table.data tfoot td { background: none; border-top: 0; }
  .table-wrap.cards table.data tfoot td:empty { display: none; }
}

@media (max-width: 380px) {
  /* 320px 에서 긴 금액이 카드 밖으로 밀리지 않도록 */
  .money-main { font-size: var(--fs-26); }
  .money-exact { font-size: var(--fs-13); }
}

/* ---------- 11-8. 모바일 잔여 터치/타이포 보정 (2차) ---------- */
@media (max-width: 768px) {
  /* 카드 안의 실제 이동 링크(주주명/회원명/뱃지 링크)는 44px 확보.
     문장 속 인라인 링크는 글 흐름을 깨므로 대상에서 제외한다. */
  .table-wrap.cards table.data td a,
  .table-wrap.cards table.data td.m-title a {
    min-height: 44px; display: inline-flex; align-items: center;
  }
  .table-wrap.cards table.data td.m-title a { width: 100%; }

  /* 단독 배치 링크 (로그인/회원가입 전환, 패널 액션) */
  .card.center a, .panel .center a {
    min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
    width: 100%;
  }

  /* 작은 버튼/라벨 타이포 하한 */
  .btn.sm { font-size: var(--fs-13); }
  .sidebar-toggle-label { font-size: var(--fs-14); min-height: 44px; }
  .stat .label { font-size: var(--fs-14); }
}

/* ---------- 11-9. 인라인 style 대체 유틸리티 ----------
   CSP 가 style-src 'self' 라 style="..." 속성은 브라우저가 차단한다
   ("Applying inline style violates ... style-src"). 지금까지 인라인으로
   적어둔 색/크기가 실제로는 적용된 적이 없었다.
   CSP 를 낮추지 않고(=보안 유지) 클래스로 옮긴다. */
.u-up   { color: var(--brand);  font-weight: 700; }
.u-down { color: var(--danger); font-weight: 700; }
.u-sm   { font-size: var(--fs-13); }
.u-md   { font-size: var(--fs-15); }
.u-17   { font-size: var(--fs-17); }
.u-19   { font-size: var(--fs-19); }
.u-mt0  { margin-top: 0; }
.u-mb0  { margin: 0 0 var(--s3); }
.u-selfcenter { align-self: center; }
.u-maxw-detail { max-width: 460px; }
.u-dashed { border-style: dashed; }
.u-rule { border: 0; border-top: 1px solid var(--line); margin: var(--s4) 0; }
h2.u-panel-title { font-size: var(--fs-16); margin-bottom: var(--s3); }

/* 주식수 초과 입력 경고 (admin.js 가 style 대신 클래스를 토글한다) */
input.over-limit { border-color: var(--danger) !important; }

/* ============================================================
   12. 폐쇄형 전환 — 계정관리 / 거래요청 / 가격이력
   ============================================================ */

/* ---------- 12-1. 로그인 화면 안내 문구 ----------
   회원가입 카드를 없앤 자리다. 카드로 만들면 버튼처럼 보여서
   "여기를 눌러 계정을 만드는 건가" 하는 오해가 생긴다. 문장으로만 둔다. */
.auth-note {
  margin-top: var(--s5);
  text-align: center;
  font-size: var(--fs-13);
  color: var(--text-sub);
  line-height: 1.6;
}

/* ---------- 12-2. 탭바 5개 대응 ----------
   거래 요청이 추가되어 탭이 5개가 됐다. 320px 에서 한 칸이 64px 이라
   글자가 두 줄로 접히면 높이가 흔들린다. 좁은 화면에서만 살짝 줄인다. */
@media (max-width: 360px) {
  .tabbar a { font-size: 10px; padding: 8px 2px 9px; letter-spacing: -0.03em; }
  .tabbar svg { width: 20px; height: 20px; }
}

/* ---------- 12-3. 최초 비밀번호 변경 ---------- */
.notice.warn {
  background: var(--warn-soft);
  border-color: #EEDCB4;
  color: var(--warn);
}
.btn.link {
  background: none; border: none; color: var(--text-sub);
  font-size: var(--fs-13); text-decoration: underline; padding: var(--s3);
}
.u-center { text-align: center; margin-top: var(--s4); }

/* ---------- 12-4. 거래 요청 입력 ---------- */
.choice-group { display: flex; gap: var(--s2); margin-top: var(--s2); }
.choice {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: var(--s4) var(--s2); border: 1.5px solid var(--line-strong);
  border-radius: var(--r3); cursor: pointer; background: var(--surface);
  font-size: var(--fs-15); font-weight: 600; color: var(--text-sub);
  text-align: center; line-height: 1.35;
}
/* 선택된 항목은 테두리+배경으로 바꾼다. 라디오 동그라미만으로는
   모바일에서 어느 쪽이 켜졌는지 한눈에 안 들어온다. */
.choice:has(input:checked) {
  border-color: var(--brand); background: var(--brand-soft); color: var(--brand);
}
.choice input { accent-color: var(--brand); width: 18px; height: 18px; }

/* ---------- 12-5. 거래 요청 목록 ---------- */
.req-list { list-style: none; margin: 0; padding: 0; }
.req { padding: var(--s4) 0; border-bottom: 1px solid var(--line); }
.req:last-child { border-bottom: 0; }
.req-top { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.req-top .when { margin-left: auto; color: var(--text-dim); font-size: var(--fs-12); }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: var(--r2);
  font-size: var(--fs-12); font-weight: 700; letter-spacing: -0.01em;
}
.tag.sell { background: var(--danger-soft); color: var(--danger); }
.tag.buy  { background: var(--brand-soft);  color: var(--brand); }

.req-line {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 3px 0; font-size: var(--fs-14); color: var(--text-sub);
}
.req-line b { color: var(--text); font-weight: 700; }
.req-line.total { border-top: 1px dashed var(--line); margin-top: var(--s2); padding-top: var(--s3); }
.req-line.total b { font-size: var(--fs-17); color: var(--brand); text-align: right; }
/* 억 단위 축약 아래에 정확한 원값을 작게 붙인다(모바일 가독성). */
.req-line.total .exact {
  display: block; font-size: var(--fs-12); font-weight: 500; color: var(--text-dim);
}
.req-memo {
  margin-top: var(--s3); padding: var(--s3); background: var(--bg);
  border-radius: var(--r2); font-size: var(--fs-13); color: var(--text-sub);
  white-space: pre-wrap; word-break: break-word;
}
.req-actions { margin-top: var(--s3); }

.legend {
  margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line);
  font-size: var(--fs-12); color: var(--text-sub); line-height: 1.7;
}
.legend p { margin: 0; }
.legend b { color: var(--text); }

/* ---------- 12-6. 주주용 가격 이력 ---------- */
.price-history { list-style: none; margin: 0; padding: 0; }
.price-history li { padding: var(--s4) 0; border-bottom: 1px solid var(--line); }
.price-history li:last-child { border-bottom: 0; }
.ph-top { display: flex; align-items: center; gap: var(--s2); margin-bottom: 2px; }
.ph-top .when { color: var(--text-sub); font-size: var(--fs-13); font-weight: 600; }
.ph-main { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.ph-price { font-size: var(--fs-19); font-weight: 700; color: var(--text); }
.ph-price .unit { font-size: var(--fs-13); font-weight: 600; color: var(--text-sub); margin-left: 2px; }
.ph-main .delta { font-size: var(--fs-13); font-weight: 600; color: var(--text-dim); }
.ph-main .delta.plus  { color: var(--brand); }
.ph-main .delta.minus { color: var(--danger); }
.ph-memo { margin-top: 4px; font-size: var(--fs-13); color: var(--text-sub); }

/* 관리자 가격 이력 표의 변동 컬럼 */
.data td.num.plus  { color: var(--brand); font-weight: 600; }
.data td.num.minus { color: var(--danger); font-weight: 600; }

/* ---------- 12-7. 임시 비밀번호 1회 노출 ----------
   한 번만 보여주는 값이라 놓치면 안 된다. 화면에서 가장 눈에 띄어야 한다. */
.panel.temp-pw { border: 2px solid var(--brand); }
.temp-pw .panel-head { background: var(--brand); }
.temp-pw .panel-head h2 { color: #fff; }
.temp-pw-row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.temp-pw-row code {
  flex: 1; min-width: 180px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 22px; font-weight: 700; letter-spacing: 0.06em;
  padding: var(--s3) var(--s4); background: var(--brand-soft);
  border: 1px dashed var(--brand-line); border-radius: var(--r2);
  color: var(--brand-dark); word-break: break-all;
  /* 어깨너머로 읽히기 쉬운 값이라 선택은 쉽게, 표시는 또렷하게 한다. */
  user-select: all;
}

/* ---------- 12-8. 계정 생성 폼 ---------- */
.panel.narrow { max-width: 620px; }
.input-row { display: flex; gap: var(--s2); align-items: stretch; }
.input-row input { flex: 1; min-width: 0; }
.form-actions { display: flex; gap: var(--s2); margin-top: var(--s5); }

/* ---------- 12-9. 관리자 거래요청 필터 ---------- */
.filters { display: flex; gap: var(--s2); flex-wrap: wrap; margin: var(--s4) 0; }
.filters select { min-width: 130px; }

/* 대시보드에서 클릭 가능한 통계 카드 */
a.stat.linkable { text-decoration: none; transition: border-color .15s, transform .15s; }
a.stat.linkable:hover { border-color: var(--brand); transform: translateY(-1px); }

/* ---------- 12-10. 가격 이력 무효 처리 ----------
   삭제 대신 '무효' 표시로 남긴다. 유효한 행과 한눈에 구분돼야 하지만
   기록 자체는 읽을 수 있어야 하므로 완전히 흐리게 만들지는 않는다. */
.data tr.is-void td { background: var(--bg); color: var(--text-dim); }
.data tr.is-void td.num.strong { text-decoration: line-through; font-weight: 600; }

.void-box { display: inline-block; }
.void-box summary { list-style: none; cursor: pointer; }
.void-box summary::-webkit-details-marker { display: none; }
.void-form {
  display: flex; gap: var(--s2); align-items: center;
  margin-top: var(--s2); min-width: 260px;
}
.void-form input { flex: 1; min-width: 0; }
.void-reason {
  margin-top: 4px; font-size: var(--fs-12); color: var(--text-sub);
  white-space: normal; word-break: break-word; line-height: 1.5;
}
.void-reason b { color: var(--danger); margin-right: 4px; }
