/*
  デザイン方針: 「帳面（ledger）」がモチーフ。
  紙のような落ち着いた背景に、藍色がかったインク色の文字。
  数字は等幅数字（tabular-nums）で桁を揃え、帳簿らしい実直さを出す。
  見出しは明朝（Zen Old Mincho）、本文はゴシック（Zen Kaku Gothic New）。
*/

@import url("https://fonts.googleapis.com/css2?family=Zen+Old+Mincho:wght@500;700&family=Zen+Kaku+Gothic+New:wght@400;500;700&family=JetBrains+Mono:wght@400;600&display=swap");

:root {
  --bg: #f3f2ee;
  --paper: #fbfaf7;
  --ink: #23282b;
  --ink-soft: #6b7178;
  --line: #dfdcd3;
  --line-strong: #c7c3b7;
  --accent: #2f6f5e;       /* 帳簿の緑インク：収入・プラス */
  --accent-soft: #e4ede9;
  --expense: #8a4a2e;      /* 支出：落ち着いた赤茶インク */
  --expense-soft: #f1e6de;
  --alert: #b3261e;        /* 未分類アラート */
  --alert-soft: #fbe9e7;
  --gold: #b8860b;         /* アクセント（signature） */
  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(35,40,43,0.06), 0 1px 12px rgba(35,40,43,0.04);
  --font-display: "Zen Old Mincho", serif;
  --font-body: "Zen Kaku Gothic New", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
}

a { color: inherit; }

/* ---------- レイアウト ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 0 4px 4px;
  color: var(--ink);
}

.brand-sub {
  font-size: 11px;
  color: var(--ink-soft);
  margin: 0 0 28px 4px;
  letter-spacing: 0.08em;
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-list a:hover { background: var(--accent-soft); color: var(--ink); }
.nav-list a.active { background: var(--accent); color: #fff; }

.nav-icon { width: 16px; text-align: center; opacity: 0.85; }

.main {
  padding: 32px 40px 80px;
  max-width: 1080px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  margin: 0;
}

.page-desc {
  color: var(--ink-soft);
  font-size: 13px;
  margin-top: 4px;
}

/* ---------- カード / パネル ---------- */

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
}

.panel + .panel { margin-top: 18px; }

.panel-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  text-transform: uppercase;
  margin: 0 0 14px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .main { padding: 20px; }
}

/* ---------- 数字・金額 ---------- */

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.amount-expense { color: var(--expense); }
.amount-income { color: var(--accent); }

.stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.2;
}

.stat-label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

/* ---------- フォーム ---------- */

label {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 5px;
  font-weight: 500;
}

input, select, textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

button, .btn {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

button:hover { background: var(--bg); }
button:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #285e50; }

.btn-danger { color: var(--alert); border-color: var(--alert); background: #fff; }
.btn-danger:hover { background: var(--alert-soft); }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- 帳簿テーブル ---------- */

table.ledger {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.ledger th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  text-transform: uppercase;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong);
}

table.ledger td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.ledger tbody tr:hover { background: var(--bg); }

table.ledger td.amount { text-align: right; }

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.category-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-right: 4px;
  white-space: nowrap;
}

.alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--alert-soft);
  color: var(--alert);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-soft);
}

.empty-state .empty-icon { font-size: 28px; margin-bottom: 10px; }

.bar-row-link {
  display: block;
  margin-bottom: 12px;
  padding: 6px 8px;
  margin-left: -8px;
  margin-right: -8px;
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: background 0.12s ease;
}
.bar-row-link:hover { background: var(--bg); }
.bar-row-link:last-child { margin-bottom: 0; }

/* ---------- モーダル ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(35,40,43,0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  z-index: 50;
  overflow-y: auto;
}

.modal {
  background: var(--paper);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 26px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ---------- ユーティリティ ---------- */

.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.muted { color: var(--ink-soft); }
.small { font-size: 12px; }
.hidden { display: none !important; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
  z-index: 100;
  max-width: 320px;
}
.toast.error { background: var(--alert); }
