:root {
  --blue: #2a78d6;
  --blue-light: #eaf1fb;
  --orange: #eb6834;
  --border: #dfe3ea;
  --text: #0b0b0b;
  --muted: #6b7280;
  --bg: #f5f7fa;
  --good: #006300;
  --critical: #d03b3b;
  --warning: #fab219;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
}
.topbar .brand { font-weight: 700; color: var(--blue); font-size: 17px; white-space: nowrap; }
.nav { display: flex; gap: 18px; white-space: nowrap; }
.nav a { color: var(--text); font-size: 14px; padding: 6px 4px; }
.nav a.active { color: var(--blue); font-weight: 700; border-bottom: 2px solid var(--blue); }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); white-space: nowrap; }

.container { max-width: 1100px; width: 96%; margin: 24px auto; padding: 0 20px; }

.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 18px; }
.card h2 { margin-top: 0; font-size: 16px; }
.card h3 { font-size: 13px; color: var(--muted); margin: 0 0 14px; font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.stat { background: var(--blue-light); border-radius: 8px; padding: 16px; }
.stat .num { font-size: 24px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.stat .label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.stat .num.good { color: var(--good); }
.stat .num.bad { color: var(--critical); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
th { background: var(--blue-light); font-weight: 600; }
tbody tr:hover { background: #fafbfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="file"], input[type="month"], select, textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  width: 100%;
  font-family: inherit;
}
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }

button, .btn {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
}
button:hover { opacity: 0.9; }
button.secondary { background: #fff; color: var(--blue); border: 1px solid var(--blue); }
button.danger { background: #fff; color: var(--critical); border: 1px solid var(--critical); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.chip.expense { background: #fce9e9; color: var(--critical); }
.chip.income { background: #e6f6ea; color: var(--good); }
.chip.critical { background: #fce9e9; color: var(--critical); font-weight: 600; }

.msg { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.msg.error { background: #fce9e9; color: var(--critical); }
.msg.success { background: #e6f6ea; color: var(--good); }

.list-actions { display: flex; gap: 8px; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px 0; }
.login-box { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 340px; }
.login-box h1 { font-size: 18px; color: var(--blue); margin-top: 0; text-align: center; }
.login-links { text-align: center; margin-top: 14px; font-size: 13px; }

/* ---- 차트 ---- */
.barlist-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.barlist-label { width: 96px; flex-shrink: 0; font-size: 12px; color: var(--text); text-align: right; }
.barlist-track { flex: 1; background: #f0f1f3; border-radius: 5px; height: 18px; position: relative; overflow: hidden; }
.barlist-fill { height: 100%; background: var(--blue); border-radius: 5px; min-width: 3px; }
.barlist-value { width: 92px; flex-shrink: 0; font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

.trend-chart { display: flex; align-items: flex-end; gap: 18px; height: 180px; padding-top: 10px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.trend-bars { display: flex; align-items: flex-end; gap: 4px; height: 100%; width: 100%; justify-content: center; }
.trend-bar { width: 16px; border-radius: 3px 3px 0 0; min-height: 2px; }
.trend-bar.income { background: var(--blue); }
.trend-bar.expense { background: var(--orange); }
.trend-label { font-size: 11px; color: var(--muted); margin-top: 6px; }

.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.meter-row { margin-bottom: 16px; }
.meter-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.meter-track { background: #f0f1f3; border-radius: 6px; height: 12px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--blue); border-radius: 6px; }
.meter-fill.over { background: var(--critical); }

/* ---- 공용 모달 ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 11, 11, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; padding: 0; line-height: 1; }
.modal-body { padding: 20px; font-size: 14px; }
.modal-body p { margin-top: 0; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

.code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--blue-light);
  border-radius: 8px;
  padding: 14px 16px;
}
.code-box-text { font-size: 22px; font-weight: 700; letter-spacing: 3px; color: var(--blue); font-variant-numeric: tabular-nums; }

.viz-tooltip {
  position: fixed;
  background: #0b0b0b;
  color: #fff;
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 200;
  display: none;
  white-space: nowrap;
}
