/* moai-finance design tokens — m-oai.com mint-dark base */
:root {
  --mint: #4FCBA0;
  --mint-dark: #2EAB80;
  --mint-darker: #1B7A5A;
  --bg: #fafdfc;
  --surface: #ffffff;
  --border: #d8e6e0;
  --text: #1a2e26;
  --text-mute: #5d6f68;
  --danger: #c0392b;
  --warn: #e08e0b;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 14px rgba(46,171,128,0.08);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--mint-darker);
  color: #fff;
  padding: 8px 14px;
  z-index: 9999;
  text-decoration: none;
  border-radius: 0 0 6px 0;
  transform: translateY(-200%);
  transition: transform 0.15s;
}
.skip-link:focus { transform: translateY(0); text-decoration: none; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--mint-darker); text-decoration: none; }
a:hover { text-decoration: underline; }

header.app-header {
  background: var(--mint-darker);
  color: white;
  padding: 12px 24px;
  display: flex; gap: 24px; align-items: center;
  box-shadow: var(--shadow);
}
header.app-header .brand-text {
  font-size: 18px; font-weight: 800; margin: 0;
  letter-spacing: 0.04em; line-height: 1;
}
header.app-header .brand-text .ai-mark { color: #ffd84d; }
/* page-level h1 (was h2 before a11y polish 2026-05-09 — promoted for proper heading hierarchy) */
main h1, h1.page-title { font-size: 22px; font-weight: 800; margin: 0 0 16px; color: #1a1a1a; letter-spacing: 0.005em; }
header.app-header nav { display: flex; gap: 16px; }
header.app-header nav a {
  color: rgba(255,255,255,0.85);
  font-weight: 600;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
}
header.app-header nav a.active,
header.app-header nav a:hover {
  background: rgba(255,255,255,0.12);
  color: white;
  text-decoration: none;
}
header.app-header .spacer { flex: 1; }
header.app-header .who { font-size: 12px; opacity: 0.85; }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }
h2 { font-size: 20px; font-weight: 700; margin: 0 0 16px; color: var(--mint-darker); }
h3 { font-size: 15px; font-weight: 700; margin: 0 0 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.kpi .label { font-size: 11px; color: var(--text-mute); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.kpi .value { font-size: 22px; font-weight: 800; color: var(--mint-darker); margin-top: 4px; }
.kpi .kpi-sub { font-size: 11px; margin-top: 4px; }
.kpi.income .value { color: var(--mint-darker); }
.kpi.expense .value { color: var(--warn); }
.kpi.net.positive .value { color: var(--mint-darker); }
.kpi.net.negative .value { color: var(--danger); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table th {
  text-align: left;
  padding: 8px 10px;
  background: #eef7f3;
  border-bottom: 2px solid var(--border);
  font-weight: 700;
  color: var(--mint-darker);
  font-size: 12px;
  letter-spacing: 0.02em;
}
table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table tr:hover td { background: #fafdfc; }
table td.num { text-align: right; font-variant-numeric: tabular-nums; }
table td.muted { color: var(--text-mute); }
.income-cell { color: var(--mint-darker); font-weight: 700; }
.expense-cell { color: var(--warn); font-weight: 700; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  background: var(--mint-darker);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.btn:hover { background: var(--mint); text-decoration: none; }
.btn.secondary { background: white; color: var(--mint-darker); border: 1px solid var(--mint-darker); }
.btn.secondary:hover { background: #eef7f3; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #a52e21; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; min-width: 120px; }
.field label {
  font-size: 11px;
  color: var(--text-mute);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.field input, .field select, .field textarea {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: white;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--mint);
  box-shadow: 0 0 0 3px rgba(79,203,160,0.18);
}
.field textarea { resize: vertical; min-height: 60px; }
.field.grow { flex: 1; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.spacer { flex: 1; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--mint-darker);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-mute);
  font-size: 13px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tag.income { background: #d8f0e6; color: var(--mint-darker); }
.tag.expense { background: #fce8c5; color: var(--warn); }

dialog.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 600px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
dialog.modal::backdrop { background: rgba(0,0,0,0.4); }
dialog.modal .modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 700;
  color: var(--mint-darker);
  display: flex; align-items: center;
}
dialog.modal .modal-header .close {
  margin-left: auto;
  background: none; border: none;
  font-size: 18px; cursor: pointer; color: var(--text-mute);
  padding: 4px 8px;
}
dialog.modal .modal-body { padding: 20px; }
dialog.modal .modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}

.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 0; font-size: 12px; color: var(--text-mute); }
.pagination .btn { padding: 4px 10px; font-size: 12px; }

@media (max-width: 720px) {
  main { padding: 12px; }
  header.app-header { flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
  header.app-header nav { font-size: 12px; gap: 8px; }
  table { font-size: 12px; }
  table th, table td { padding: 6px 6px; }
}
