@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700&family=Noto+Sans+KR:wght@400;500;600;700&family=Noto+Serif+KR:wght@500;600;700&display=swap");

:root {
  font-family: "DM Sans", "Noto Sans KR", sans-serif;
  color: #151a22;
  background: #f4f7fb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --green: #e0503f;
  --green-dark: #c33f30;
  --muted: #8b94a5;
  --line: #e1e7f0;
  --ink: #151a22;
  --blue: #2f7cd6;
  --blue-soft: #e4effc;
  --red-soft: #fce7e3;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #f4f7fb; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #2f7cd6;
  outline-offset: 2px;
}

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 216px; padding: 22px 10px 14px;
  background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 0 8px 22px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border: 1.5px solid var(--green); color: var(--green); font-family: "Noto Serif KR", serif; font-size: 12px; font-weight: 700; letter-spacing: .5px; transform: rotate(-3deg); }
.brand strong { display: block; font-size: 14px; letter-spacing: .2px; }
.brand small { display: block; margin-top: 2px; color: #7c8798; font-size: 10px; letter-spacing: .2px; font-weight: 500; }
.nav-label, .eyebrow { color: #8b94a5; font-size: 10px; font-weight: 700; letter-spacing: 1.15px; }
.nav-label { margin: 16px 0 8px 12px; }
.sidebar .nav-item { width: 100%; padding: 9px 12px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 3px; background: transparent; color: #5a6474; text-align: left; font-size: 12px; font-weight: 500; position: relative; }
.nav-item span { width: 16px; color: #8793a3; text-align: center; font-family: "DM Mono", monospace; font-size: 13px; }
.nav-item.active { background: #eaf2ff; color: #173a66; font-weight: 700; }
.nav-item.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; background: var(--green); }
.nav-item.active span { color: var(--green); }
.sidebar-note { margin-top: auto; padding: 13px 8px 0; color: #7c8798; font-size: 10px; border-top: 1px solid var(--line); }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #2d9d70; }

.main { max-width: none; min-height: 100vh; margin-left: 216px; padding: 0 34px 52px; }
.topbar { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin: 0 -34px 20px; padding: 23px 34px 17px; background: white; border-bottom: 1px solid var(--line); }
.top-actions { display: flex; align-items: center; gap: 9px; }
.topbar .eyebrow { margin: 0 0 5px; }
.topbar .eyebrow span { color: var(--green); }
h1 { margin: 0; font-family: "Noto Serif KR", serif; font-size: 21px; letter-spacing: -.5px; }
.primary-button, .secondary-button { min-height: 42px; border: 1px solid var(--line); border-radius: 2px; padding: 8px 13px; font-size: 12px; font-weight: 600; }
.primary-button { background: var(--ink); color: white; border-color: var(--ink); box-shadow: none; }
.primary-button:hover { background: var(--green-dark); }
.primary-button:disabled { opacity: .6; cursor: wait; }
.secondary-button { background: #fff; color: #3e4b5c; }
.welcome { min-height: 112px; padding: 20px 23px; border: 1px solid var(--line); background: linear-gradient(105deg, #edf4fc, #f9fbfe); display: flex; align-items: center; justify-content: space-between; }
.welcome .eyebrow { margin: 0 0 7px; color: var(--green); }
.welcome h2 { margin: 0 0 5px; font-family: "Noto Serif KR", serif; font-size: 18px; letter-spacing: -.4px; }
.welcome p:not(.eyebrow) { margin: 0; color: #728096; font-size: 12px; }
.welcome-date { display: flex; flex-direction: column; gap: 3px; color: #8b94a5; font-size: 10px; text-align: right; }
.welcome-date strong { color: #173a66; font-family: "DM Mono", monospace; font-size: 14px; font-weight: 500; }
.summary-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; margin: 16px 0; border: 1px solid var(--line); background: #fff; }
.summary-card { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: center; gap: 8px; padding: 15px 17px; min-height: 88px; }
.card-title { display: flex; justify-content: space-between; align-items: center; color: #7c8798; font-size: 11px; }
.icon { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid var(--line); color: #748196; font-family: "DM Mono", monospace; font-size: 9px; }
.count-icon { color: #657187; background: #f1f4f8; }
.summary-card strong { grid-column: 2; grid-row: 1 / 3; display: block; margin: 0; font-family: "DM Mono", monospace; font-size: 24px; font-weight: 500; letter-spacing: -.7px; }
.summary-card small { color: #8b94a5; font-size: 10px; }
.panel { overflow: hidden; margin-bottom: 16px; background: white; border: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px 12px; border-bottom: 1px solid #edf2f9; }
.panel-heading h2 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-heading p { margin: 4px 0 0; color: #8b94a5; font-size: 10px; }
.text-button { padding: 7px; border: 0; background: transparent; color: #173a66; font-size: 11px; font-weight: 600; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: 11px; }
th { padding: 9px 12px; background: #f1f6fc; color: #4c5666; text-align: left; font-size: 10px; font-weight: 600; }
td { padding: 8px 12px; border-top: 1px solid #edf2f9; color: #4c5666; }
th:first-child, td:first-child { padding-left: 17px; }
.amount { text-align: right; font-family: "DM Mono", monospace; font-variant-numeric: tabular-nums; }
.row-actions { width: 1%; }
.row-action-buttons { display: flex; gap: 5px; }
.edit-record-button { min-height: 34px; padding: 5px 10px; white-space: nowrap; }
.delete-record-button { min-height: 34px; padding: 5px 10px; color: #b6382b; white-space: nowrap; }
.positive { color: #0e8a5f !important; }
.negative { color: #e0503f !important; }
.pill { display: inline-block; min-width: 39px; padding: 3px 7px; text-align: center; border-radius: 2px; font-size: 10px; }
.pill-income { color: #0e8a5f; background: #e3f5ed; }
.pill-expense { color: #e0503f; background: #fce7e3; }
.ledger-sale td, .cash-income { color: #0e8a5f !important; }
.ledger-purchase td, .cash-expense { color: #e0503f !important; }
.invoice-sale td.amount { color: #0e8a5f !important; }
.invoice-purchase td.amount { color: #e0503f !important; }
.bank-credit { color: #0e8a5f !important; }
.bank-debit { color: #e0503f !important; }
.empty-state { padding: 36px 16px; color: #8b94a5; text-align: center; font-size: 12px; line-height: 1.8; }
.hidden { display: none !important; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 20%, #edf4fc, #f4f7fb 62%); }
.auth-screen.hidden { display: none; }
.auth-card { width: min(420px, 100%); padding: 30px; border: 1px solid var(--line); background: #fff; box-shadow: 0 16px 48px #173a6610; }
.auth-brand { padding: 0 0 24px; }
.auth-card > .eyebrow { margin: 0 0 7px; color: var(--green); }
.auth-card h1 { margin-bottom: 8px; }
.auth-card > p:not(.eyebrow) { color: #728096; font-size: 12px; line-height: 1.7; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin: 22px 0 18px; border-bottom: 1px solid var(--line); }
.auth-tabs button { padding: 11px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #7c8798; }
.auth-tabs button.active { border-bottom-color: var(--blue); color: #173a66; font-weight: 700; }
#auth-form label { display: block; margin: 14px 0; color: #627087; font-size: 11px; font-weight: 600; }
#auth-form input { display: block; width: 100%; min-height: 44px; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); color: var(--ink); font-size: 14px; }
#auth-submit { width: 100%; margin-top: 12px; }
.auth-hint, .auth-footnote { color: #8b94a5; font-size: 10px; line-height: 1.7; }
.signed-in-user { color: #627087; font-size: 11px; }
.pending-user { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.pending-user:last-child { border-bottom: 0; }
.pending-user-actions { display: flex; gap: 6px; }
.approve-user-button { color: #0e8a5f; }
.reject-user-button { color: #b6382b; }
#pending-users-dialog { width: min(900px, calc(100% - 32px)); }
.member-row { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(130px, 0.8fr) minmax(130px, 0.7fr) auto; align-items: end; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.member-info { align-self: center; min-width: 0; }
.member-info strong, .member-info small { display: block; overflow-wrap: anywhere; }
.member-info small { margin-top: 5px; color: #8b94a5; font-size: 10px; }
.member-field { color: #627087; font-size: 10px; }
.member-field input, .member-field select { display: block; width: 100%; min-height: 38px; margin-top: 5px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 2px; color: #3e4b5c; background: white; font: inherit; font-size: 12px; }
.member-user-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.member-user-actions button { padding: 8px 10px; font-size: 10px; }
.filters { display: flex; align-items: end; gap: 12px; margin-bottom: 14px; padding: 14px 16px; }
.filters label { flex: 1; min-width: 120px; color: #788398; font-size: 10px; }
.type-filter { flex: 0 0 auto; color: #788398; font-size: 10px; }
.filter-switch { margin-top: 6px; }
.filter-switch button { min-height: 42px; padding: 8px 13px; font-size: 12px; }
.filter-switch button.active { color: #173a66; font-weight: 700; }
.filters input, .filters select { display: block; width: 100%; min-height: 44px; margin-top: 6px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 2px; color: #3e4b5c; background: white; font-size: 14px; }
.result-count { color: #7c8798; font-size: 10px; }
.panel-tools, .pagination { display: flex; align-items: center; gap: 8px; }
.pagination .secondary-button { padding: 8px 11px; font-size: 11px; }
.pagination .secondary-button:disabled { opacity: .45; cursor: default; }
 .mode-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 2px; background: #f4f7fb; }
.mode-switch button { padding: 7px 10px; border: 0; border-radius: 1px; background: transparent; color: #738078; font-size: 10px; }
.mode-switch button.active { background: white; color: #173a66; box-shadow: 0 1px 3px #163a2818; }
.recent-panel { margin-top: 16px; }
dialog { width: min(520px, calc(100% - 32px)); max-height: 90dvh; overflow-y: auto; padding: 25px; border: 1px solid var(--line); border-radius: 2px; box-shadow: 0 18px 70px #14271e30; }
dialog::backdrop { background: #16231d70; backdrop-filter: blur(2px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 22px; }
.dialog-heading .eyebrow { margin: 0 0 5px; color: var(--green); }
.dialog-heading h2 { margin: 0; font-size: 20px; }
.close-button { border: 0; background: transparent; color: #718078; font-size: 25px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid label { color: #627068; font-size: 11px; font-weight: 600; }
.form-grid input, .form-grid select, .form-grid textarea { display: block; width: 100%; min-height: 44px; margin-top: 6px; padding: 10px; border: 1px solid #e1e7e3; border-radius: 4px; outline-color: #82bca3; color: #27372f; font-size: 14px; }
.form-grid textarea { resize: vertical; }
.full-width { grid-column: 1 / -1; }
.optional { color: #a5aea9; font-weight: 400; }
.dialog-actions { display: flex; justify-content: end; gap: 9px; margin-top: 21px; }
.dialog-actions button { min-width: 92px; min-height: 44px; }
.form-error { padding: 10px; margin: 14px 0 0; border-radius: 7px; background: #fff0eb; color: #a84c34; font-size: 11px; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: calc(100% - 48px); padding: 13px 18px; border-radius: 9px; background: #233b30; color: white; box-shadow: 0 8px 24px #17231f30; font-size: 12px; }

@media (max-width: 1000px) {
  .sidebar { width: 205px; }
  .main { margin-left: 205px; padding: 0 22px 40px; }
  .topbar { margin-right: -22px; margin-left: -22px; padding-right: 22px; padding-left: 22px; }
}
@media (max-width: 650px) {
  .sidebar { position: static; width: 100%; height: auto; padding: 12px 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: center; gap: 5px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { grid-column: 1 / -1; }
  .brand small, .nav-label, .sidebar-note { display: none; }
  .sidebar .nav-item { width: 100%; min-height: 42px; padding: 8px 3px; margin: 0; justify-content: center; gap: 5px; font-size: 11px; white-space: nowrap; }
  .sidebar .nav-item + .nav-item { margin: 0; }
  .main { margin: 0; padding: 0 12px 35px; }
  .topbar { margin: 0 -12px 14px; padding: 16px 12px 13px; align-items: center; }
  .top-actions { flex-wrap: wrap; justify-content: end; gap: 5px; }
  .top-actions .primary-button, .top-actions .secondary-button { min-height: 42px; padding: 7px 8px; font-size: 11px; }
  .topbar .eyebrow { font-size: 8px; letter-spacing: .7px; }
  h1 { font-size: 17px; }
  .welcome { min-height: 100px; padding: 15px; }
  .welcome-date { display: none; }
  .summary-grid { margin: 12px 0; }
  .summary-card { padding: 12px; min-height: 82px; }
  .summary-card strong { font-size: 19px; }
  .filters { flex-wrap: wrap; }
  .filters label { flex: 1 1 40%; }
  .type-filter { flex: 1 1 100%; }
  .filter-switch { width: 100%; }
  .filter-switch button { flex: 1; }
  .filters button { flex: 1 1 100%; }
  dialog { padding: 18px; }
  #pending-users-dialog .member-row { grid-template-columns: 1fr 1fr; }
  #pending-users-dialog .member-info, #pending-users-dialog .member-user-actions { grid-column: 1 / -1; }
  #pending-users-dialog .member-user-actions { justify-content: flex-end; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .full-width { grid-column: auto; }
  .dialog-actions { position: sticky; bottom: -18px; padding: 12px 0 0; background: #fff; }
  .panel-heading { padding: 12px; }
  .panel-tools { align-items: end; flex-direction: column; }
  .pagination { flex-wrap: wrap; justify-content: end; }
  th, td { padding-right: 11px; padding-left: 11px; }
  th:first-child, td:first-child { padding-left: 12px; }
}
