:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface2: #eef4fb;
  --line: #e3eaf2;
  --text: #1a2233;
  --muted: #64748b;
  --accent: #2563eb;       /* 差し色：青 */
  --accent2: #38bdf8;      /* 差し色：水色 */
  --accent-soft: #e3edff;  /* 青の薄い背景 */
  --pos: #10b981;
  --neg: #ef4444;
  --shadow: 0 1px 3px rgba(20, 40, 80, .06), 0 6px 20px rgba(20, 40, 80, .04);
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; color: var(--accent); }
.tabs { display: flex; gap: 4px; }
.tab {
  background: none; border: none; color: var(--muted);
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 600;
}
.tab:hover { color: var(--text); background: var(--surface2); }
.tab.active { color: #fff; background: var(--accent); }

main { max-width: 1100px; margin: 0 auto; padding: 24px; }
.panel { display: none; }
.panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.cards { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 6px;
}
.card.big {
  flex: 1.6;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  border: none; color: #fff;
}
.card.big .label, .card.big .sub { color: rgba(255,255,255,.85); }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.card .sub { font-size: 12px; color: var(--muted); }
.value.pos { color: var(--pos); } .value.neg { color: var(--neg); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

.box {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.box h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; }
.box-head { display: flex; justify-content: space-between; align-items: center; }
canvas { max-height: 280px; }

.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-head h2, .panel h2 { font-size: 20px; margin: 0 0 16px; }

.btn {
  background: var(--accent); color: #fff; border: none;
  padding: 9px 16px; border-radius: 10px; cursor: pointer;
  font-weight: 600; font-size: 14px;
}
.btn:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 12px; font-size: 12px; }
.btn.ghost { background: var(--surface2); color: var(--text); }
.btn.danger { background: var(--neg); }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 10px; border-bottom: 1px solid var(--line); }
table.data td { padding: 12px 10px; border-bottom: 1px solid var(--line); }
table.data tr:hover td { background: var(--surface2); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.row-edit { cursor: pointer; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tag-income { color: var(--pos); } .tag-expense { color: var(--neg); }
.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.icon-btn:hover { color: var(--neg); }

/* simulation */
.sim-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
@media (max-width: 820px) { .sim-layout { grid-template-columns: 1fr; } }
.sim-controls { display: flex; flex-direction: column; gap: 12px; height: fit-content; }
.sim-controls label, .modal label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.sim-controls input, .modal input, .modal select {
  background: var(--surface2); border: 1px solid var(--line); color: var(--text);
  padding: 9px 11px; border-radius: 9px; font-size: 14px;
}
.hint { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 4px 0 0; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal[hidden] { display: none; }
.modal-body { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: 420px; max-width: 92vw; max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-body h3 { margin: 0 0 4px; }
.modal label.checkbox { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.modal label.checkbox input { width: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.modal-actions .btn.danger { margin-right: auto; }
