:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #1d2129;
  --muted: #6b7280;
  --accent: #4f6bed;
  --accent-soft: #e8ecfd;
  --in: #1f8a5b;
  --out: #d6453d;
  --sun: #d6453d;
  --sat: #3b6fd6;
  /* 차트 */
  --series: #2a78d6;
  --series-soft: #9ec5f4;
  --payday: #fff3dc;      /* 카드값 나가는 날 바탕 */
  --payday-line: #f3d9a4;
  --grid: #eceef2;
  --axis: #c9cdd4;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f24;
    --surface-2: #252930;
    --border: #2e333b;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --accent: #7b93ff;
    --accent-soft: #262d4a;
    --in: #4cc38a;
    --out: #ff6b62;
    --sun: #ff7a72;
    --sat: #7aa2ff;
    --series: #3987e5;
    --series-soft: #1c5cab;
    --payday: #3a2f1a;
    --payday-line: #6b5426;
    --grid: #2a2e35;
    --axis: #3a404a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 레이아웃 ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 14px;
}

.brand { font-size: 18px; font-weight: 700; padding: 0 12px 20px; }

#nav { display: flex; flex-direction: column; gap: 4px; }
#nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
#nav a:hover { background: var(--surface-2); }
#nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.nav-group {
  margin: 16px 12px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.soon {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 999px;
}

.main-col { min-width: 0; display: flex; flex-direction: column; }
.view { padding: 8px 32px 28px; min-width: 0; } /* 모든 화면이 가로 폭을 꽉 채움 */

/* 오른쪽 위 사용자 표시 + 로그아웃 */
.userbar { display: flex; align-items: center; gap: 10px; }
.userbar-desktop { justify-content: flex-end; padding: 16px 32px 0; }
.userbar-mobile { display: none; }
.ub-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.ub-user:hover, .ub-user.active { border-color: var(--accent); }
.ub-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--oc, var(--accent));
  flex: none;
}
.ub-avatar.has-img { background: var(--surface-2); overflow: hidden; padding: 0; }
.ub-avatar.has-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ub-avatar.lg { width: 44px; height: 44px; font-size: 18px; }
.ub-avatar.xl { width: 72px; height: 72px; font-size: 28px; }
.avatar-cell { white-space: nowrap; }
.avatar-cell .ub-avatar { vertical-align: middle; }
.avatar-actions { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; margin-left: 8px; vertical-align: middle; }
.account-avatar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.ub-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ub-role { font-size: 11px; color: var(--muted); background: var(--surface-2); padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.ub-logout { padding: 6px 12px; font-size: 13px; color: var(--muted); }
.ub-logout:hover { color: var(--out); border-color: var(--out); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
}
.card-head h2 { font-size: 16px; margin: 0; }

.muted { color: var(--muted); font-size: 13px; }

.more {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.more:hover { color: var(--accent); }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}
.page-title { font-size: 22px; margin: 0; }
.page-desc { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.month-nav { display: flex; align-items: center; gap: 8px; }
.month-title { font-size: 22px; margin: 0 4px; min-width: 130px; text-align: center; }

/* ---------- 버튼 ---------- */
.btn {
  font: inherit;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.small { font-size: 12px; padding: 5px 10px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.sm { width: 26px; height: 26px; font-size: 13px; }

.link-btn {
  background: none;
  border: 0;
  padding: 2px;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.link-btn:hover { color: var(--text); text-decoration: underline; }
.link-btn.danger:hover { color: var(--out); }

.in { color: var(--in); }
.out { color: var(--out); }

/* ---------- 요약 ---------- */
.summary { display: flex; gap: 10px; }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
}
.stat span { font-size: 12px; color: var(--muted); }
.stat strong { font-size: 17px; font-variant-numeric: tabular-nums; }

/* ---------- 달력 + 패널 ---------- */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.calendar.card { padding: 12px; }

.cal-week, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.cal-week div { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0 8px; }
.cal-week .sun { color: var(--sun); }
.cal-week .sat { color: var(--sat); }

.cal-cell {
  min-height: 96px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.selected { border-color: var(--accent); background: var(--accent-soft); }
.cal-cell.other { opacity: .35; }

.day-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.cal-cell .day {
  font-size: 13px;
  font-weight: 600;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
}
.cal-cell.sun .day { color: var(--sun); }
.cal-cell.sat .day { color: var(--sat); }
.cal-cell.today .day { background: var(--accent); color: #fff; border-radius: 999px; }
.clip { font-size: 12px; }

.cal-cell .amt {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 2px;
}

/* 가계부 달력 항목: 1줄 = 항목명 (남은/할부), 2줄 = 금액 */
.li-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 11px;
  line-height: 1.35;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.li-item .nm { display: flex; gap: 2px; min-width: 0; color: var(--text); white-space: nowrap; }
.li-item .nm-text { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.li-item .nm em { flex: none; font-style: normal; color: var(--accent); font-weight: 600; } /* 항목명이 잘려도 (남은/할부)는 항상 보임 */
.li-item .am { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; font-weight: 600; }
.li-item .pr { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.li-item.in .am { color: var(--in); }
.li-item.out .am { color: var(--out); }
.cal-cell.selected .li-item { background: var(--surface); }

/* 날짜 아래 그날 총지출 */
.day-sum em { font-style: normal; font-weight: 500; font-size: 0.9em; color: var(--muted); }
.day-sum {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text); /* 내역 금액(빨강)과 구분되도록 진한 기본 글씨 */
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: -2px 0 3px 2px;
}

/* 카드값 나가는 날 (매달 12일) */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--muted);
  padding: 0 4px 6px;
}
.payday-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--payday);
  border: 1px solid var(--payday-line);
}
.cal-cell.payday { background: var(--payday); border-color: var(--payday-line); }
.cal-cell.payday:hover { filter: brightness(0.98); }
.cal-cell.payday.selected { border-color: var(--accent); }

/* 등록한 사람별 색 (oc0 ~ oc5). 금액 글씨(빨강/초록)와 겹치지 않게 빨강 · 초록 계열 제외 */
.oc0 { --oc: #2a78d6; }
.oc1 { --oc: #e87ba4; }
.oc2 { --oc: #1baf7a; }
.oc3 { --oc: #eb6834; }
.oc4 { --oc: #6250d6; }
.oc5 { --oc: #eda100; }
@media (prefers-color-scheme: dark) {
  .oc0 { --oc: #3987e5; }
  .oc1 { --oc: #d55181; }
  .oc2 { --oc: #199e70; }
  .oc3 { --oc: #d95926; }
  .oc4 { --oc: #9085e9; }
  .oc5 { --oc: #c98500; }
}
/* 연한 바탕 + 왼쪽 진한 띠 (색만으로 구분하지 않도록) */
.li-item[class*=" oc"],
.cal-cell.selected .li-item[class*=" oc"] {
  background: color-mix(in srgb, var(--oc) 16%, var(--surface));
  box-shadow: inset 3px 0 0 var(--oc);
  padding-left: 6px;
}
.entry[class*=" oc"]:not(.gi) {
  background: color-mix(in srgb, var(--oc) 11%, var(--surface));
  box-shadow: inset 4px 0 0 var(--oc);
}
.owner-legend { display: flex; flex-wrap: wrap; gap: 10px; }
.owner-chip { display: inline-flex; align-items: center; gap: 4px; color: var(--text); }
.owner-chip::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--oc) 30%, var(--surface));
  border: 1px solid var(--oc);
}
.payday-note { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.payday-note .billed {
  background: var(--payday);
  border: 1px solid var(--payday-line);
  border-radius: 999px;
  padding: 1px 9px;
  color: var(--text);
}
.payday-note .billed b { font-variant-numeric: tabular-nums; }

/* 가계부 검색 */
.ledger .page-head { flex-wrap: wrap; }
.search-toggle.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.search-card { padding: 14px; margin-bottom: 14px; }
.search-form { display: grid; grid-template-columns: minmax(160px, 1.4fr) auto repeat(3, minmax(110px, 1fr)); gap: 8px; align-items: center; }
.search-form input, .search-form select {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
}
.search-range { display: flex; align-items: center; gap: 4px; }
.search-range input { width: 140px; }
.search-range span { color: var(--muted); }
.search-quick { grid-column: 1 / -1; display: flex; gap: 12px; flex-wrap: wrap; }
.search-sum { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; margin: 12px 2px 8px; font-size: 13px; color: var(--muted); }
.search-sum > b { color: var(--text); font-size: 14px; }
.search-sum .out { color: var(--out); }
.search-sum .in { color: var(--in); }
.search-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 420px; overflow-y: auto; }
.search-row {
  width: 100%;
  display: grid;
  grid-template-columns: 70px 72px minmax(0, 1fr) auto 100px;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.search-row:hover { outline: 1px solid var(--accent); }
.search-row[class*=" oc"] { background: color-mix(in srgb, var(--oc) 10%, var(--surface)); box-shadow: inset 3px 0 0 var(--oc); }
.sr-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.sr-cat { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); justify-self: start; white-space: nowrap; }
.sr-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-name em { font-style: normal; color: var(--accent); font-weight: 600; }
.sr-pay { font-size: 11px; color: var(--muted); white-space: nowrap; }
.sr-amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sr-amt.out { color: var(--out); }
.sr-amt.in { color: var(--in); }
.search-more { margin-top: 8px; width: 100%; }
@media (max-width: 1100px) {
  .search-form { grid-template-columns: 1fr 1fr 1fr; }
  .search-form input[name="sq"], .search-range { grid-column: 1 / -1; }
  .search-range input { flex: 1; width: auto; }
}
@media (max-width: 560px) {
  .search-form { grid-template-columns: 1fr 1fr; }
  .search-form input, .search-form select { font-size: 16px; }
  .search-row { grid-template-columns: 56px minmax(0, 1fr) auto; row-gap: 2px; }
  .sr-cat { display: none; }
  .sr-pay { grid-column: 2; grid-row: 2; }
  .sr-amt { grid-row: 1 / span 2; grid-column: 3; }
}

/* 날짜별 상세내역 페이지 넘김 */
.pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin: -6px 0 16px; font-size: 13px; font-variant-numeric: tabular-nums; }
.pay.cash { color: var(--in); font-weight: 600; }

/* 할부 묶음 ("8월 할부 (2/3)") */
.li-item.grp { background: var(--accent-soft); }
.cal-cell.selected .li-item.grp { background: var(--surface); }
.inst-group .cat { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.inst-tag { font-style: normal; color: var(--accent); font-weight: 600; font-size: 13px; }
.group-items { grid-column: 1 / -1; margin-top: 2px; }
.group-items summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  list-style: none;
  padding: 2px 0;
}
.group-items summary::-webkit-details-marker { display: none; }
.group-items summary::before { content: "▸ "; }
.group-items[open] summary::before { content: "▾ "; }
.group-items ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.entry.gi {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface);
  border-radius: 6px;
  font-size: 13px;
}
.gi-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gi-name small { font-size: 11px; }
.gi-amt { font-weight: 600; color: var(--out); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 가계부 요약: 달력 위 한 줄 (할부 · 일시불 · 합계 · 오빠입금) */
.cal-col { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.ledger-summary { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.ledger-summary .stat { min-width: 0; padding: 8px 10px; }
.ledger-summary .stat strong { font-size: 14px; letter-spacing: -0.3px; }
/* 화면이 좁은 PC에서는 7칸이 잘리지 않도록 두 줄 (4칸 + 3칸) */
@media (max-width: 1440px) {
  .ledger-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.ledger-summary .stat.fixed { background: var(--surface-2); }
.ledger-summary .stat.total { border-color: var(--text); }
.ledger-summary .stat strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 달력 아래: 생활비 · 식비 할부/일시불 (항상 4칸 한 줄) */
.ledger-summary.cat-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cat-summary-note { margin: -6px 2px 0; font-size: 11px; color: var(--muted); text-align: right; }

/* 관리자: 접속자 */
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--in); margin-right: 4px; vertical-align: middle; box-shadow: 0 0 0 3px color-mix(in srgb, var(--in) 25%, transparent); }
.online-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.online-user { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.online-info { min-width: 0; font-size: 14px; }
.online-session { font-size: 13px; color: var(--muted); margin-top: 3px; }
.online-session b { color: var(--text); font-weight: 600; }
.status-on { color: var(--in); font-weight: 600; white-space: nowrap; }

/* 오빠입금 */
.stat-btn { font: inherit; color: inherit; text-align: left; cursor: pointer; }
.stat-btn:hover { border-color: var(--accent); }
.stat-btn.on { border-color: var(--accent); background: var(--accent-soft); }
.deposit-card { padding: 16px 18px; margin-bottom: 20px; }
.deposit-card .card-head { margin-bottom: 10px; }
.dep-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dep {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 14px;
}
.dep-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.dep-memo { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dep-form {
  display: grid;
  grid-template-columns: 140px 150px 160px minmax(0, 1fr) auto auto;
  grid-auto-flow: dense;
  gap: 8px;
  align-items: center;
}
.dep-img-btn { padding: 8px 12px; font-size: 14px; }
.dep .actions { display: flex; gap: 6px; align-items: center; }
.dep-files { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; }
.dep-thumb { position: relative; }
.dep-thumb a {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none;
}
.dep-thumb img { width: 100%; height: 100%; object-fit: cover; }
.dep-thumb-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  line-height: 20px;
  padding: 0;
  cursor: pointer;
}
.dep-form input {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.dep-form .amount-input input { padding-right: 30px; }
.dep-seg button { padding: 6px 8px; }
.dep-seg button.on[data-dsign="+"] { color: var(--in); }
.dep-seg button.on[data-dsign="-"] { color: var(--out); }
.dep-error { margin: 8px 0 0; }
.deposit-card .hint { margin-top: 8px; font-size: 12px; }
.menu-icon { margin-right: 4px; }
.menu-icon + .code-name { width: calc(100% - 28px); display: inline-block; }

.form-note { margin: -4px 0 0; font-size: 12px; color: var(--accent); }
.inst-preview {
  margin: -4px 0 0;
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 6px 8px;
}

.ev {
  font-size: 11px;
  line-height: 1.5;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  padding: 0 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ev b { font-weight: 600; }
.ev-more { font-size: 11px; color: var(--muted); padding-left: 4px; }

.panel { padding: 20px; position: sticky; top: 20px; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
}
.panel-head h2 { font-size: 18px; margin: 0; }
.panel-head small { font-size: 14px; color: var(--muted); font-weight: 400; }
.day-total { display: flex; gap: 8px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.day-total .in { color: var(--in); }
.day-total .out { color: var(--out); }

.empty { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

/* 가계부 내역 */
.entry-list, .sched-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.entry {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
}
.entry.editing, .sched.editing { outline: 2px solid var(--accent); }
.entry .cat {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.entry .memo { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .amt { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry .meta { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.entry .actions, .sched .actions { display: flex; gap: 6px; }

.pay { font-size: 11px; color: var(--muted); }
.pay.install {
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}

/* 일정 목록 */
.sched {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
}
.sched-time { font-size: 13px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; padding-top: 1px; }
.sched-body strong { font-size: 14px; display: block; word-break: break-all; }
.sched-body p { margin: 2px 0 0; font-size: 13px; color: var(--muted); white-space: pre-wrap; word-break: break-all; }

/* ---------- 입력 폼 ---------- */
.entry-form {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-title { font-size: 13px; font-weight: 600; color: var(--muted); }

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 3px;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 7px 8px;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.seg button.on[data-value="expense"] { color: var(--out); }
.seg button.on[data-value="income"] { color: var(--in); }

.pay-row { display: flex; gap: 8px; }
.pay-row .seg { flex: 1; }
.pay-row select { width: 110px; flex: none; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea, .pay-row select, .code-add input, .code-name {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
}
.field textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.amount-input { position: relative; }
.amount-input input { padding-right: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.amount-input em {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-style: normal;
  color: var(--muted);
}

.form-error { margin: -4px 0 0; font-size: 13px; color: var(--out); }
.form-actions { display: flex; gap: 8px; }
.form-actions .primary { flex: 1; }

/* ---------- 증빙파일 ---------- */
.files {
  margin-top: 18px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  transition: background .15s, border-color .15s;
}
.files.drag { border-color: var(--accent); background: var(--accent-soft); }
.files-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.files-head h3 { font-size: 14px; margin: 0; }
.files-hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
}
.thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  text-decoration: none;
  font-size: 18px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-info { min-width: 0; display: flex; flex-direction: column; }
.file-name {
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-name:hover { text-decoration: underline; }
.file-size { font-size: 11px; color: var(--muted); }
.file-empty { font-size: 13px; color: var(--muted); }

/* ---------- 대시보드 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.stat-tile span { font-size: 13px; color: var(--muted); }
.stat-tile strong { font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-tile small { font-size: 12px; color: var(--muted); }
.stat-tile .repay { color: var(--text); }
.stat-tile .repay .dday { color: var(--accent); font-weight: 700; }
.stat-tile .repay em { font-style: normal; color: var(--muted); }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.dash-side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.cal-card, .chart-card { padding: 18px; }
.cal-card .cal-cell { min-height: 88px; }
.chart-card .more { display: inline-block; margin-top: 12px; }

/* ---------- 차트 ---------- */
.viz { position: relative; }
.viz-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: nowrap;
}
.viz-tip strong { font-size: 12px; color: var(--muted); font-weight: 500; }
.viz-tip span { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

.vbars-plot { position: relative; height: 180px; margin: 8px 0 0 44px; }
.gl { position: absolute; left: 0; right: 0; border-top: 1px solid var(--grid); }
.gl.base { border-color: var(--axis); }
.gl span {
  position: absolute;
  right: 100%;
  margin-right: 8px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.cols { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: grid; }
.col {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
}
.col:hover { background: var(--surface-2); }
.col .bar {
  width: min(60%, 22px);
  background: var(--series-soft);
  border-radius: 4px 4px 0 0;
}
.col.sel .bar { background: var(--series); }
.col .val {
  position: absolute;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.vbars-x {
  display: grid;
  margin-left: 44px;
  padding-top: 6px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.vbars-x .sel { color: var(--text); font-weight: 600; }

.hbars { display: flex; flex-direction: column; }
.hrow {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}
.hlabel { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.htrack { height: 14px; }
.hbar { display: block; height: 100%; min-width: 2px; background: var(--series); border-radius: 0 4px 4px 0; }
.hval { font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; min-width: 96px; }
.hval em { font-style: normal; color: var(--muted); font-size: 12px; margin-left: 6px; display: inline-block; min-width: 30px; }
.chart-empty { margin: 24px 0; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- 환경관리 ---------- */
.settings-card { padding: 20px; margin-bottom: 20px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs button {
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.table-wrap { overflow-x: auto; }
.code-table { width: 100%; border-collapse: collapse; }
.code-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.code-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.code-table td.order { white-space: nowrap; width: 72px; }
.code-table td.count { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.code-table tr.inactive .code-name { color: var(--muted); text-decoration: line-through; }
.code-name { padding: 6px 10px; font-size: 14px; min-width: 120px; border-color: transparent; background: transparent; }
.code-name:hover { border-color: var(--border); }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: var(--axis);
  border-radius: 999px;
  transition: background .15s;
  pointer-events: none;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

.code-add { display: flex; gap: 8px; margin-top: 14px; }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }
.backup-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- 스터디 ---------- */
.nav-empty { font-size: 13px; color: var(--muted) !important; }

.tag {
  font: inherit;
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 2px 9px;
  cursor: pointer;
  white-space: nowrap;
}
.tag small { color: var(--muted); font-size: 11px; margin-left: 2px; }
.tag:hover { border-color: var(--accent); }
.tag.on { background: var(--accent); color: #fff; }
.tag.on small { color: rgba(255, 255, 255, .8); }
.tags, .tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.study-search { padding: 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.study-search input[type="search"] {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
}

.topic-list ul { list-style: none; margin: 0; padding: 0; }
.topic-list .empty { padding: 24px; margin: 0; text-align: center; }
.topic-row { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.topic-row:last-child { border-bottom: 0; }
.topic-link { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; color: var(--text); text-decoration: none; }
.topic-link strong { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-link:hover strong { color: var(--accent); text-decoration: underline; }
.topic-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }

.topic-form, .note-form { padding: 18px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.note-form textarea, .note-form input {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.6;
}
.form-actions.end { justify-content: flex-end; }
.form-actions.end .primary { flex: none; }

.crumb { display: inline-block; font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 12px; }
.crumb:hover { color: var(--accent); }

.topic-head { padding: 20px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.topic-head h1 { font-size: 22px; margin: 0 0 10px; word-break: break-all; }
.topic-head .muted { margin: 10px 0 0; }
.topic-head .actions { display: flex; gap: 6px; }

.note-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.note { padding: 16px 18px; }
.note .note-form { padding: 0; margin: 0; }
.note-num { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.note-content { white-space: pre-wrap; word-break: break-word; line-height: 1.7; font-size: 15px; }
.note-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.note-foot .tags { flex: 1; min-width: 0; }
.note-foot .actions { display: flex; gap: 6px; }

/* ---------- 권한 / 공개 범위 ---------- */
.vis, .owner {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
  vertical-align: middle;
}
.vis.public { background: var(--accent-soft); color: var(--accent); }
.vis.private { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.owner { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.owner::before { content: "✍ "; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 4px; }
.meta-left { display: flex; gap: 6px; align-items: center; min-width: 0; }
.vis-field .seg button.on[data-vis="public"] { color: var(--accent); }

/* 사이드바 사용자 */
.nav-user {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-logout {
  align-self: flex-start;
  margin-left: 12px;
  background: none;
  border: 0;
  padding: 2px 0;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.nav-logout:hover { color: var(--out); text-decoration: underline; }
.nav-empty { padding: 6px 12px; font-size: 13px; color: var(--muted); }
.nav-empty a { color: var(--muted); }

/* 로그인 */
body.locked .app { display: none; }
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-brand { font-size: 24px; font-weight: 700; }
.login-card .muted { margin: -8px 0 4px; }
.login-card .btn.primary { padding: 11px; margin-top: 4px; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

/* 내 정보 / 사용자관리 */
.info { display: grid; grid-template-columns: 80px 1fr; gap: 10px 12px; margin: 0; font-size: 14px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; }
.pw-form { display: flex; flex-direction: column; gap: 12px; max-width: 480px; }

.user-add-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.role-select {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .link-btn + .link-btn { margin-left: 8px; }

/* ---------- 준비중 페이지 ---------- */
.placeholder { max-width: 420px; margin: 60px auto; padding: 40px; text-align: center; }
.placeholder-icon { font-size: 40px; }
.placeholder h1 { margin: 12px 0 4px; font-size: 22px; }
.placeholder p { margin: 0; color: var(--muted); }

/* ---------- 공지 (대시보드 상단 줄) ---------- */
.ub-notice {
  margin-right: auto;
  min-width: 0;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.ub-notice:hover .ub-notice-title { text-decoration: underline; }
.ub-notice-tag { flex: none; font-weight: 700; color: var(--accent); }
.ub-notice-title { min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ub-notice-meta { flex: none; color: var(--muted); font-size: 12px; white-space: nowrap; }
.ub-notice-more { flex: none; font-style: normal; font-size: 12px; color: var(--accent); }
.notice-strip { display: none; }

/* ---------- 공지사항 화면 ---------- */
.notice-card { padding: 4px 0; }
.notice-empty { padding: 16px 20px; margin: 0; }
.notice-list { list-style: none; margin: 0; padding: 0; }
.notice + .notice { border-top: 1px solid var(--border); }
.notice summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  list-style: none;
}
.notice summary::-webkit-details-marker { display: none; }
.notice summary:hover { background: var(--surface-2); }
.notice-title { min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice-meta { flex: none; font-size: 12px; color: var(--muted); }
.pin-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 7px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: 1px;
}
.notice-body { padding: 4px 20px 16px; white-space: pre-wrap; word-break: break-word; line-height: 1.6; font-size: 14px; }
.notice-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 0 20px 14px; }
.notice-form { padding: 20px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px; }
.check-field { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check-field input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- To-Do ---------- */
.todo-card { padding: 18px; }
.todo-quick { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.todo-quick input {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
}
.todo-quick-row { display: flex; gap: 6px; }
.todo-quick-row input { flex: 1; }
.todo-quick-row .btn { flex: none; }
.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.todo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
}
.todo.editing { outline: 2px solid var(--accent); }
.todo-check { display: flex; align-items: center; gap: 8px; min-width: 0; cursor: pointer; }
.todo-check input { flex: none; width: 17px; height: 17px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.todo-title { min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo.done .todo-title { text-decoration: line-through; color: var(--muted); }
.todo-due { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.todo-due.soon { color: var(--accent); font-weight: 600; }
.todo-due.late { color: var(--out); font-weight: 600; }
.todo-due.none { opacity: .7; }
.todo-count { margin: 10px 0 0; font-size: 12px; }
.todo-more { display: inline-block; margin-top: 8px; font-size: 13px; }
.todo-card .empty { margin: 4px 0 0; }
/* 전체 화면 */
.todo-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.todo-main { padding: 16px; }
.todo-tabs { grid-template-columns: repeat(3, 1fr); max-width: 320px; margin-bottom: 14px; }
.todo-list.full .todo { grid-template-columns: minmax(0, 1fr) auto auto auto; padding: 10px 12px; }
.todo-meta { display: flex; gap: 4px; align-items: center; }
.todo-page .panel .entry-form { border-top: 0; padding-top: 0; }

/* ---------- 자소서 ---------- */
.rs-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rs-head-actions a.btn { text-decoration: none; }
.rs-filter { display: grid; grid-template-columns: 120px minmax(0, 1fr) 120px; gap: 8px; padding: 12px; margin-bottom: 12px; }
.rs-filter select, .rs-filter input, .rs-pv-org {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.rs-count { margin: 0 0 8px 2px; }
.rs-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rs-row { display: block; padding: 14px 18px; color: var(--text); text-decoration: none; }
.rs-row:hover { border-color: var(--accent); }
.rs-row-head { display: flex; align-items: center; gap: 8px; }
.rs-org { font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-row-meta { margin-top: 4px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rs-snippet { margin: 8px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; word-break: break-all; }
.rs-snippet b { color: var(--text); }
.rs-snippet mark, .rs-org mark { background: #ffe58a; color: inherit; border-radius: 2px; padding: 0 1px; }
.rs-badge { flex: none; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; vertical-align: middle; }
.rs-badge.pass { color: var(--in); background: color-mix(in srgb, var(--in) 14%, var(--surface)); }
.rs-badge.fail { color: var(--out); background: color-mix(in srgb, var(--out) 12%, var(--surface)); }
.page-title .rs-badge { font-size: 13px; margin-left: 6px; }
.rs-empty { padding: 20px; }
.rs-empty .empty { margin: 0; }
/* 엑셀 미리보기 */
.rs-preview { padding: 18px; margin-bottom: 14px; }
.rs-pv-list { list-style: none; margin: 10px 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rs-pv { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.rs-pv.off { opacity: .55; }
.rs-pv-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rs-pv-head input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.rs-pv-org { max-width: 260px; font-weight: 600; }
.rs-warn { font-size: 12px; color: var(--out); }
.rs-pv details { margin-top: 6px; font-size: 13px; }
.rs-pv summary { cursor: pointer; color: var(--muted); }
.rs-pv-items { margin: 6px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.rs-pv-items li span { display: block; color: var(--muted); }
/* 등록 · 수정 */
/* 목록 | 상세 2단 (한 건을 고르면 목록은 왼쪽으로 좁아지고 오른쪽에 상세) */
.rs-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.rs-layout.has-detail { grid-template-columns: 380px minmax(0, 1fr); }
.rs-detail:empty { display: none; }
.rs-layout.has-detail .rs-filter { grid-template-columns: 1fr 1fr; }
.rs-layout.has-detail .rs-filter input { grid-column: 1 / -1; grid-row: 1; }
.rs-layout.has-detail .rs-list { max-height: calc(100vh - 260px); overflow-y: auto; padding-right: 2px; }
.rs-layout.has-detail .rs-row { padding: 10px 14px; }
.rs-layout.has-detail .rs-org { font-size: 14px; }
.rs-layout.has-detail .rs-snippet { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rs-row.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.rs-layout.has-detail .rs-detail { position: sticky; top: 16px; }
.rs-detail-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.rs-detail-head h2 { margin: 0; font-size: 18px; min-width: 0; overflow-wrap: anywhere; }
.rs-detail-head .rs-badge { font-size: 12px; margin-left: 4px; }
@media (max-width: 1100px) {
  .rs-layout.has-detail { grid-template-columns: minmax(0, 1fr); }
  .rs-layout.has-detail .rs-detail { position: static; order: -1; } /* 좁은 화면: 상세를 위에, 목록은 아래 */
  .rs-layout.has-detail .rs-list { max-height: 50vh; }
}
.rs-form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.rs-form-top { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 12px; align-items: end; }
.rs-form-top .vis-field { grid-column: 1 / -1; max-width: 320px; }
.rs-items { display: flex; flex-direction: column; gap: 12px; }
.rs-item { border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.rs-item-head { display: flex; justify-content: space-between; align-items: center; }
.rs-item-tools { display: flex; align-items: center; gap: 4px; }
.rs-item textarea { line-height: 1.6; }
.rs-item textarea[readonly] { background: var(--surface); }
.rs-chars { margin: -4px 0 0; font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.rs-add { align-self: flex-start; }
.rs-actions { align-items: center; }
.rs-actions .primary { flex: none; }
.rs-actions .spacer { flex: 1; }
.rs-actions a.btn { text-decoration: none; }
.danger-text { color: var(--out); }
@media (max-width: 560px) {
  .rs-filter { grid-template-columns: 1fr 1fr; }
  .rs-filter input { grid-column: 1 / -1; grid-row: 1; font-size: 16px; }
  .rs-form { padding: 14px; }
  .rs-form-top { grid-template-columns: 1fr; }
  .rs-head-actions { width: 100%; }
  .rs-head-actions .btn { flex: 1; text-align: center; }
}

/* ---------- 대시보드 To-Do 칸 ---------- */
.dash-todo:empty { display: none; }
/* 넓은 화면: 대시보드는 폭 제한 없이 [달력 | 차트 | To-Do] 3칸 */
@media (min-width: 1500px) {
  /* [To-Do | 달력 | 차트], To-Do는 옆 칸들과 같은 높이 (내용이 많으면 안에서 스크롤) */
  .dash-grid { grid-template-columns: 300px minmax(0, 1.35fr) minmax(0, 1fr); align-items: stretch; }
  .dash-todo { order: -1; align-self: stretch; position: relative; min-height: 420px; }
  .dash-todo > .todo-card { position: absolute; inset: 0; display: flex; flex-direction: column; }
  .dash-todo .todo-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; align-content: start; }
  .dash-todo .todo-list + .todo-more, .dash-todo .todo-count { flex: none; }
}
/* 중간 화면: 2칸일 때 To-Do는 달력 아래 */
@media (min-width: 1181px) and (max-width: 1499px) {
  .dash-todo { grid-column: 1; }
  .dash-side { grid-row: span 2; } /* 차트 칸 높이 때문에 달력과 To-Do 사이가 벌어지지 않게 */
}

/* ---------- 반응형 ---------- */
.topbar, .nav-backdrop { display: none; }
.cal-cell .short { display: none; }

/* 태블릿 이하: 대시보드 1단 */
@media (max-width: 1180px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}

/* 휴대폰 · 작은 태블릿: 상단 바 + 서랍 메뉴, 달력/패널 1단 */
@media (max-width: 900px) {
  .app { display: block; }

  .topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 20;
    align-items: center;
    gap: 6px;
    height: 52px;
    padding: 0 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .menu-btn {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
  }
  .menu-btn:active { background: var(--surface-2); }
  .topbar-title { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  /* 사용자 표시는 상단 바 오른쪽으로 */
  .userbar-desktop { display: none; }
  .userbar-mobile { display: flex; margin-left: auto; gap: 6px; flex: none; }
  .userbar-mobile .ub-user { padding: 2px 8px 2px 2px; gap: 6px; }
  .userbar-mobile .ub-avatar { width: 26px; height: 26px; font-size: 12px; }
  .userbar-mobile .ub-name { font-size: 13px; max-width: 72px; }
  .userbar-mobile .ub-role { display: none; }
  .userbar-mobile .ub-logout { padding: 5px 9px; font-size: 12px; }

  /* 왼쪽에서 열리는 메뉴 */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: 270px;
    max-width: 84vw;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .22s ease;
    padding: 20px 14px calc(20px + env(safe-area-inset-bottom));
  }
  body.nav-open .sidebar { transform: none; box-shadow: 6px 0 28px rgba(0, 0, 0, .22); }
  .nav-backdrop {
    display: block;
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 30;
    background: rgba(0, 0, 0, .38);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
  }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  #nav a { padding: 12px; }

  .view { padding: 16px 12px calc(24px + env(safe-area-inset-bottom)); overflow-x: hidden; }
  .main-col { display: block; }
  .dash-side, .cal-card, .chart-card, .card { min-width: 0; }
  .split { grid-template-columns: 1fr; gap: 14px; }
  .ledger-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dep-form { grid-template-columns: 1fr 1fr 1fr; }
  .dep-form input[name="dmemo"] { grid-column: span 2; }
  .dep-form .btn.primary { grid-column: 1 / -1; }
  .panel { position: static; scroll-margin-top: 64px; }
  .user-add-grid { grid-template-columns: 1fr; }
  .todo-layout { grid-template-columns: 1fr; gap: 14px; }
  .todo-layout .panel { order: -1; }
  .notice-strip:not([hidden]) { display: block; padding: 10px 12px 0; }
  .notice-strip .ub-notice { display: flex; border-radius: 10px; flex-wrap: wrap; row-gap: 2px; }
  .notice-strip .ub-notice-title { flex: 1; }
  .todo-quick input, .todo-form input { font-size: 16px; }

  /* 아이폰에서 입력할 때 화면이 확대되지 않도록 16px 이상 */
  .field input, .field select, .field textarea, .pay-row select, .code-add input,
  .code-name, .study-search input[type="search"], .note-form textarea, .note-form input, .role-select {
    font-size: 16px;
  }

  /* 손가락으로 누르기 쉽게 */
  .link-btn { padding: 6px 4px; font-size: 13px; }
  .icon-btn { width: 38px; height: 38px; }
  .icon-btn.sm { width: 32px; height: 32px; }
  .seg button { padding: 9px 8px; }
  .btn { padding: 10px 14px; }
}

/* 휴대폰 */
@media (max-width: 560px) {
  body { font-size: 14px; }

  .page-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 14px; }
  .page-head .btn.primary { align-self: stretch; }
  .month-nav { justify-content: space-between; }
  .month-title { font-size: 19px; min-width: 0; flex: 1; }
  .summary { width: 100%; gap: 6px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; } /* 휴대폰: 3칸 × 2줄 */
  .ledger-summary .stat { padding: 7px 6px; }
  .ledger-summary .stat span { font-size: 11px; }
  .ledger-summary .stat strong { font-size: 12px; letter-spacing: -0.3px; }
  .cal-col { gap: 8px; }
  .deposit-card { padding: 14px; margin-bottom: 14px; }
  .dep { grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: 6px; padding: 8px; font-size: 13px; }
  .dep-form { grid-template-columns: 1fr 1fr; }
  .dep-form input { font-size: 16px; }
  .dep-form .btn.primary { grid-column: 1 / -1; }
  .dep-form input[name="dmemo"] { grid-column: 1 / -1; }
  .stat { flex: 1; min-width: 0; padding: 8px 10px; }
  .stat strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* 대시보드 요약: 3칸 한 줄로 압축 */
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 14px; }
  .stat-tile { padding: 10px; gap: 2px; }
  .stat-tile span { font-size: 11px; }
  .stat-tile strong { font-size: 15px; }
  .stat-tile small { font-size: 10px; line-height: 1.3; }
  .dash-grid, .dash-side { gap: 14px; }
  .cal-card, .chart-card, .todo-card { padding: 12px; }
  .todo-list.full .todo { grid-template-columns: minmax(0, 1fr) auto; }
  .todo-list.full .todo-meta { grid-column: 1; }
  .notice summary { flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px 14px; }
  .notice-title { white-space: normal; }
  .notice-body { padding: 4px 14px 14px; }
  .notice-actions { padding: 0 14px 12px; flex-wrap: wrap; }
  .payday-note .billed { margin-left: 0; }

  /* 달력 */
  .calendar.card, .cal-card { padding: 6px; }
  .cal-week, .cal-grid { gap: 1px; }
  .cal-week div { font-size: 11px; padding: 4px 0 6px; }
  .cal-cell, .cal-card .cal-cell { min-height: 58px; padding: 3px 2px; border-radius: 6px; }
  .cal-cell .day { width: 22px; height: 22px; font-size: 12px; }
  .cal-cell .amt { font-size: 10px; padding-left: 1px; letter-spacing: -0.2px; }
  .cal-cell .full { display: none; }
  .cal-cell .short { display: inline; }
  /* 가계부 달력 항목: 항목명 위, 금액 아래 */
  .li-item { padding: 1px 2px; font-size: 10px; letter-spacing: -0.3px; }
  .day-sum { font-size: 10px; margin: -2px 0 2px 1px; letter-spacing: -0.3px; }
  .li-item[class*=" oc"], .cal-cell.selected .li-item[class*=" oc"] { box-shadow: inset 2px 0 0 var(--oc); padding-left: 4px; }
  .li-item .nm { gap: 1px; }
  .li-item .pr { display: none; } /* 휴대폰 달력 칸은 좁아서 원금은 아래 상세내역에서 */
  .clip { font-size: 10px; }
  .ev { font-size: 10px; padding: 0 3px; line-height: 1.45; }
  .ev b { display: none; }
  .ev-more { font-size: 10px; padding-left: 2px; }

  /* 패널 · 목록 */
  .panel { padding: 16px 14px; }
  .entry { padding: 10px; }
  .file { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .file > .link-btn:not(.danger) { display: none; } /* 휴대폰은 파일 이름을 눌러 열기/저장 */
  .files-hint { display: none; } /* 끌어다 놓기는 휴대폰에서 안 되므로 */
  .topic-row { padding: 12px 14px; }
  .topic-link { flex-direction: column; gap: 4px; }
  .topic-link strong { white-space: normal; }
  .topic-head { flex-direction: column; padding: 16px; }
  .topic-head h1 { font-size: 19px; }
  .note { padding: 14px; }
  .topic-form, .note-form { padding: 14px; }

  /* 차트 */
  .vbars-plot, .vbars-x { margin-left: 34px; }
  .vbars-plot { height: 150px; }
  .vbars-x { font-size: 9px; }
  .hrow { grid-template-columns: 60px minmax(0, 1fr) auto; gap: 8px; }
  .hval { min-width: 0; font-size: 12px; }
  .hval em { min-width: 0; }

  /* 환경관리 표 */
  .settings-card { padding: 14px; }
  .code-table th, .code-table td { padding: 6px 4px; }
  .code-table td.order { width: auto; }
  .code-name { min-width: 90px; }
  .row-actions { white-space: normal; }
  .row-actions .link-btn { display: block; margin: 0 0 0 auto; }
  .row-actions .link-btn + .link-btn { margin-left: auto; }
  .code-add { flex-direction: column; }
  .info { grid-template-columns: 64px 1fr; }
  .login-card { padding: 28px 20px; }
}
