/* 중앙동아리 회계 — 중앙대학교 UI 전용색상 (cau.ac.kr 대학상징 > UI)
   CAU BLUE  Pantone 2945C  RGB 33·85·164
   CAU RED   Pantone 032C   RGB 255·0·0
   CAU GRAY  Cool Gray 8    RGB 102·102·102 */
:root {
  --brand: #2155a4;        /* CAU BLUE */
  --brand-700: #1b4688;
  --brand-800: #13315f;
  --brand-100: #d9e3f3;
  --brand-50: #edf2fa;
  --accent: #ff0000;       /* CAU RED (아주 적게 사용) */

  --ink: #141c2b;
  --ink-2: #475467;
  --ink-3: #6b7689;
  --line: #e3e8ef;
  --line-2: #cfd7e3;
  --bg: #f4f6fa;
  --surface: #ffffff;

  --good: #17804a;
  --good-bg: #e8f6ee;
  --warn: #9a5b00;
  --warn-bg: #fff6e0;
  --danger: #c4282d;
  --danger-bg: #fdecec;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 8px rgba(16, 24, 40, 0.06);
  --sidebar: 248px;
  --tabbar: 64px;

  color-scheme: light;
  font-family: "Pretendard", "Pretendard Variable", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); min-height: 100vh; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 16px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.issue-list { margin: 6px 0 0; padding-left: 16px; font-size: 12.5px; color: var(--ink-2); }
.issue-list li.danger { color: var(--danger); font-weight: 600; }
.issue-list li.warn { color: var(--warn); }
.table .req-text { color: #1d4ed8; font-weight: 600; }
.table tfoot td { border-top: 2px solid var(--line-2); border-bottom: 0; font-weight: 800; padding-top: 12px; }
.kpis.compact { margin-bottom: 0; }
.kpis.compact .kpi { box-shadow: none; }
details.card > summary { list-style: none; cursor: pointer; margin-bottom: 0; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "+"; margin-left: auto; font-size: 20px; color: var(--ink-3); }
details.card[open] > summary { margin-bottom: 14px; }
details.card[open] > summary::after { content: "−"; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--brand-50); border-color: var(--brand-100); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn.danger { color: var(--danger); border-color: #f1c4c6; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--brand-50); }
.btn.sm { min-height: 34px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.icon-btn { min-height: 36px; width: 36px; padding: 0; }

/* ---------- 폼 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface); font-size: 16px; /* 16px: iOS 확대 방지 */
}
textarea.input { min-height: 72px; resize: vertical; }
.input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-100); }
.input.amount { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--ink-3); }
.error-text { color: var(--danger); font-size: 14px; min-height: 1em; }
.error-text:empty { display: none; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--ink-2); }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); }

.segmented { display: inline-flex; padding: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.segmented button { min-height: 36px; padding: 0 14px; border: 0; background: transparent; border-radius: 8px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

/* ---------- 카드 / 배지 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card h2, .card h3 { margin: 0 0 4px; font-size: 16px; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .sub { color: var(--ink-3); font-size: 13px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--brand-50); color: var(--brand-700); white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.gray { background: var(--bg); color: var(--ink-2); }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--brand-50); color: var(--brand-800); font-size: 14px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.danger { background: var(--danger-bg); color: var(--danger); }
.notice.good { background: var(--good-bg); color: var(--good); }
.notice .icon { margin-top: 1px; }
.notice ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- 레이아웃 ---------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 20;
  background: var(--brand-800); color: #fff; display: flex; flex-direction: column; padding: 20px 14px;
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 4px 8px 22px; }
.brand-logo { width: 150px; height: auto; }
.brand-name { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; line-height: 1.2; opacity: 0.85; padding-left: 2px; }
.brand-sub { font-size: 12px; opacity: 0.7; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px;
  color: rgba(255, 255, 255, 0.78); text-decoration: none; font-weight: 600;
}
.nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.14); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.07); font-size: 13px; }
.sidebar-foot .who { font-weight: 700; }
.sidebar-foot .btn { margin-top: 10px; width: 100%; background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.sidebar-foot .btn:hover { background: rgba(255, 255, 255, 0.1); }

.topbar { display: none; }
.tabbar { display: none; }
.main { margin-left: var(--sidebar); padding: 28px 32px 48px; }
.page { max-width: 1120px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }

/* ---------- 필터 ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; margin-bottom: 18px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.range { display: flex; align-items: center; gap: 6px; }
.range select, .filters select.input, .filters input.input { min-height: 38px; padding: 6px 10px; font-size: 14px; width: auto; }
.filters .search { min-width: 200px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 18px 20px; }
.kpi .label { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .value .unit { font-size: 15px; font-weight: 700; margin-left: 2px; color: var(--ink-2); }
.kpi .foot { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.kpi.hero { background: var(--brand); border-color: var(--brand); color: #fff; }
.kpi.hero .label, .kpi.hero .foot, .kpi.hero .value .unit { color: rgba(255, 255, 255, 0.8); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
details.table-view { margin-top: 12px; }
details.table-view summary { cursor: pointer; font-size: 13px; color: var(--ink-2); font-weight: 600; }

/* ---------- 표 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 700; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table .right { text-align: right; }
.table .amount { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.income { color: var(--good); }
.table .actions { text-align: right; white-space: nowrap; }
.table .desc { max-width: 280px; }
.table .desc .vendor { font-weight: 700; }
.table .desc .sub { color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.table-summary { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; padding: 12px 14px; background: var(--brand-50); border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 14px; }
.table-summary b { font-variant-numeric: tabular-nums; }

/* ---------- 업로드 ---------- */
.dropzone {
  border: 2px dashed var(--line-2); border-radius: var(--radius); background: var(--surface);
  padding: 32px 20px; text-align: center; transition: border-color 0.15s, background 0.15s;
}
.dropzone.over { border-color: var(--brand); background: var(--brand-50); }
.dropzone .big-icon { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; }
.dropzone .big-icon .icon { width: 28px; height: 28px; }
.dropzone h2 { margin: 0 0 4px; font-size: 18px; }
.dropzone p { margin: 0 0 16px; color: var(--ink-3); }
.dropzone .row { justify-content: center; }
.dropzone .lock-hint { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 14px 0 0; text-align: left; }
.only-touch { display: none; }
@media (pointer: coarse) { .only-touch { display: inline-flex; } }

.queue { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.up-card { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 18px; }
.thumb { width: 168px; height: 220px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; display: grid; place-items: center; cursor: zoom-in; padding: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .icon { width: 40px; height: 40px; color: var(--ink-3); }
.up-status { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 12px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--brand-100); border-top-color: var(--brand); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.up-card .notice { margin-bottom: 12px; }
.items-table { margin-top: 12px; font-size: 13px; }
.items-table summary { cursor: pointer; color: var(--ink-2); font-weight: 600; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.saved-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.saved-line .icon { color: var(--good); }

/* ---------- 로그인 ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth-hero {
  background: linear-gradient(155deg, var(--brand-800) 0%, var(--brand) 100%); color: #fff;
  padding: 56px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden;
}
.auth-hero::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 360px; height: 360px; border-radius: 50%; border: 48px solid rgba(255, 255, 255, 0.06); }
.hero-logo { width: 213px; height: auto; margin-bottom: 36px; position: relative; z-index: 1; }
.auth-hero h1 { font-size: 32px; line-height: 1.25; margin: 0 0 10px; letter-spacing: -0.02em; position: relative; z-index: 1; }
.auth-hero p.lead { font-size: 16px; opacity: 0.8; margin: 0; max-width: 440px; position: relative; z-index: 1; }
.terms { margin: 4px 0 0 26px; font-size: 12px; color: var(--ink-3); }
.terms summary { cursor: pointer; }
.terms p { margin: 6px 0 0; line-height: 1.5; }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 20px; }
.auth-card .tabs button { min-height: 40px; }
.auth-card h2 { margin: 0 0 4px; font-size: 20px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card form > p { margin: -8px 0 4px; }

/* ---------- 모달 ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 16px; width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3); }
dialog.modal::backdrop { background: rgba(15, 23, 42, 0.5); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h3 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 18px; }
.modal-body .viewer { background: var(--bg); border-radius: 12px; display: grid; place-items: center; min-height: 200px; }
.modal-body .viewer img { max-height: 70vh; object-fit: contain; }
.secret-box { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 20px; font-weight: 700; letter-spacing: 0.04em; background: var(--brand-50); color: var(--brand-800); padding: 14px; border-radius: 10px; text-align: center; user-select: all; word-break: break-all; }

/* ---------- 토스트 ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 100; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.empty { text-align: center; padding: 36px 16px; color: var(--ink-3); }
.empty .icon { width: 36px; height: 36px; margin: 0 auto 8px; color: var(--line-2); }

/* ---------- 태블릿 ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 모바일 ---------- */
@media (max-width: 900px) {
  :root { --sidebar: 0px; }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    background: var(--brand-800); color: #fff; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  }
  .topbar .brand { flex-direction: row; align-items: center; gap: 10px; padding: 0; }
  .topbar .brand-logo { width: 112px; }
  .topbar .brand-name { font-size: 13px; padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, 0.3); }
  .topbar .btn { color: #fff; border-color: rgba(255, 255, 255, 0.25); background: transparent; min-height: 34px; padding: 0 10px; font-size: 13px; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabbar); color: var(--ink-3); text-decoration: none; font-size: 11px; font-weight: 700; }
  .tabbar a[aria-current="page"] { color: var(--brand); }
  .tabbar a .icon { width: 22px; height: 22px; }
  .tabbar a.cta .icon { width: 26px; height: 26px; }
  .main { margin-left: 0; padding: 16px 16px calc(var(--tabbar) + 28px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 21px; }
  .card { padding: 16px; }
  .kpi .value { font-size: 21px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .filters { gap: 8px; }
  .filters .search { min-width: 0; flex: 1 1 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .up-card { grid-template-columns: minmax(0, 1fr); }
  .thumb { width: 100%; height: 180px; }
  .toast { bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); }

  /* 표 → 카드 목록 */
  table.table.responsive thead { display: none; }
  table.table.responsive, table.table.responsive tbody, table.table.responsive tr, table.table.responsive td { display: block; width: 100%; }
  table.table.responsive tr { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: var(--surface); }
  table.table.responsive td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.table.responsive td::before { content: attr(data-label); color: var(--ink-3); font-size: 13px; font-weight: 600; text-align: left; flex: none; }
  table.table.responsive td.desc { display: block; text-align: left; max-width: none; }
  table.table.responsive td.desc::before { display: none; }
  table.table.responsive td.actions { justify-content: flex-end; padding-top: 8px; }
  table.table.responsive td.actions::before { display: none; }
  table.table.responsive tbody tr:hover td { background: transparent; }
  table.table.responsive tfoot, table.table.responsive tfoot tr { display: block; }
  table.table.responsive tfoot tr { background: var(--brand-50); }
  table.table.responsive tfoot td { display: inline-block; width: auto; border: 0; padding: 4px 8px 4px 0; }

  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { padding: 28px 20px 24px; padding-top: calc(28px + env(safe-area-inset-top)); }
  .auth-hero h1 { font-size: 24px; }
  .auth-hero p.lead { font-size: 15px; margin-bottom: 0; }
  .hero-logo { width: 150px; margin-bottom: 18px; }
  .auth-panel { padding: 20px 16px 40px; align-items: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  .sidebar, .topbar, .tabbar, .filters, .actions, .btn { display: none !important; }
  .main { margin: 0; padding: 0; }
}
