:root {
  color-scheme: dark;
  --bg: #0a0d12;
  --panel: #111822;
  --panel-2: #151f2b;
  --panel-3: #1b2735;
  --ink: #eef5f7;
  --muted: #8fa1b3;
  --line: #263545;
  --accent: #2dd4bf;
  --accent-2: #f59e0b;
  --accent-3: #60a5fa;
  --danger: #fb7185;
  --ok: #4ade80;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.68; }
.grecaptcha-badge {
  visibility: visible !important;
  opacity: 1 !important;
  z-index: 99999 !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
}

.auth-copy {
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(150deg, rgba(45, 212, 191, 0.15), transparent 38%),
    linear-gradient(20deg, rgba(96, 165, 250, 0.16), transparent 42%),
    #0d1219;
  border-right: 1px solid var(--line);
}

.logo { display: flex; align-items: center; font-size: 20px; font-weight: 800; }
.auth-copy h1 { max-width: 620px; margin: 0; font-size: clamp(36px, 5vw, 68px); line-height: 1.04; letter-spacing: 0; }
.auth-copy p { max-width: 620px; color: var(--muted); line-height: 1.8; }

.auth-panel { display: grid; place-items: center; padding: 32px; }
.auth-card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 24, 34, 0.92);
  box-shadow: var(--shadow);
}
.auth-card h2 { margin: 0 0 6px; font-size: 24px; }
.auth-card p { margin: 0 0 22px; color: var(--muted); }
.auth-footnote { margin: 14px 0 0; text-align: center; }
.auth-link-row {
  margin-top: 14px;
  text-align: center;
}
.auth-link-row button {
  color: #bfeee7;
  background: transparent;
  font-size: 12px;
}
.auth-link-row button:hover { text-decoration: underline; }
.auth-footer {
  width: min(460px, 100%);
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}
.auth-footer a,
.sidebar-footer a {
  color: #bfeee7;
  text-decoration: none;
}
.auth-footer a:hover,
.sidebar-footer a:hover { text-decoration: underline; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.tab {
  min-height: 38px; border-radius: 7px; background: var(--panel-3); color: var(--muted); font-weight: 700;
}
.tab.active { color: #06110f; background: var(--accent); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px; display: flex; flex-direction: column; gap: 24px;
  background: #0d1219; border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; padding: 0 6px; }
.brand h1 { margin: 0; font-size: 17px; line-height: 1.25; }
.brand span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.nav { display: grid; gap: 6px; }
.nav button {
  min-height: 44px; display: flex; align-items: center;
  border-radius: 8px; padding: 0 12px; color: #b7c4d1; background: transparent; text-align: left;
}
.nav button[aria-current="page"] { color: #07100f; background: var(--accent); font-weight: 800; }
.user-box {
  margin-top: auto; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
.user-box-button {
  width: 100%;
  color: inherit;
  text-align: left;
}
.user-box-button:hover {
  border-color: var(--accent);
  background: var(--panel-2);
}
.user-box strong { display: block; overflow-wrap: anywhere; }
.user-box span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.sidebar-footer {
  display: grid;
  gap: 5px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5; min-height: 76px; padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: rgba(10, 13, 18, 0.86); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.topbar h2 { margin: 0; font-size: 23px; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.top-actions, .button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.content { padding: 28px; display: grid; gap: 20px; }
.grid { display: grid; gap: 14px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.reports { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.two-col { grid-template-columns: minmax(340px, 0.85fr) minmax(420px, 1.4fr); align-items: start; }

.card, .metric {
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow);
}
.card { padding: 18px; }
.card h3 { margin: 0 0 14px; font-size: 17px; }
.metric { padding: 16px; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 8px; font-size: 25px; letter-spacing: 0; }
.metric small { display: block; margin-top: 6px; color: var(--muted); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.full { grid-column: 1 / -1; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px;
  color: var(--ink); background: #0c1219; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.14); }
textarea { min-height: 76px; resize: vertical; }
.checkbox-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink);
}
.checkbox-line input {
  width: 16px;
  min-height: 16px;
  margin-top: 2px;
  accent-color: var(--accent);
}
.checkbox-line a {
  color: #bfeee7;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  width: 30px;
  height: 30px;
  min-height: 30px;
  transform: translateY(-50%);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}

.password-toggle:hover {
  color: var(--ink);
  background: var(--panel-3);
}

.recaptcha-box,
.google-auth {
  display: flex;
  justify-content: center;
}

.google-auth {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.btn {
  min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 7px; padding: 0 13px; color: var(--ink); background: var(--panel-3); font-weight: 800;
}
.btn.primary { color: #04110f; background: var(--accent); }
.btn.warn { color: #161004; background: var(--accent-2); }
.btn.danger { color: #24070d; background: var(--danger); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.icon { width: 36px; padding: 0; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #0c1219; }
table { width: 100%; min-width: 800px; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; color: var(--muted); background: #111a24; font-size: 12px; }
.amount { text-align: right; font-variant-numeric: tabular-nums; }
.pill {
  display: inline-flex; align-items: center; min-height: 24px; border-radius: 999px; padding: 0 8px;
  color: var(--muted); background: var(--panel-3); font-size: 12px; font-weight: 800;
}
.pill.income { color: var(--ok); background: rgba(74, 222, 128, 0.12); }
.pill.expense { color: var(--accent-2); background: rgba(245, 158, 11, 0.12); }
.pill.transfer { color: var(--accent-3); background: rgba(96, 165, 250, 0.12); }
.report-list { display: grid; gap: 8px; }
.report-line { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.report-line.total { margin-top: 4px; border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 900; }
.journal { display: grid; gap: 8px; }
.journal-entry {
  display: grid; grid-template-columns: 112px 1fr 1fr 130px; gap: 10px; align-items: center;
  padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #0c1219;
}
.todo-list { display: grid; gap: 8px; }
.todo {
  display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 10px;
  padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #0c1219;
}
.todo input { min-height: auto; }
.empty { padding: 28px; color: var(--muted); text-align: center; }
.empty.compact { padding: 14px; text-align: left; }
.note, .error, .success { font-size: 12px; line-height: 1.7; }
.note { color: var(--muted); }
.error { color: var(--danger); }
.success { color: var(--ok); }
.hidden-input { display: none; }

.verify-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.12);
}

.verify-banner strong {
  display: block;
  color: #fde68a;
}

.verify-banner span {
  display: block;
  margin-top: 4px;
  color: #f8d79a;
  font-size: 12px;
  line-height: 1.5;
}

.ledger-layout {
  display: grid;
  gap: 16px;
}

.card-head,
.ledger-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.card-head h3,
.ledger-titlebar h3 {
  margin: 0;
}

.ledger-titlebar p {
  margin: 5px 0 0;
  color: #ff7878;
  font-size: 12px;
  font-weight: 800;
}

.entry-card {
  padding: 14px;
}

.quick-entry {
  display: grid;
  grid-template-columns: 150px 120px 150px 170px 130px minmax(150px, 1fr);
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.quick-entry label {
  min-width: 0;
}

.quick-entry .button-row {
  flex-wrap: nowrap;
}

.quick-entry .memo-field {
  grid-column: span 2;
}

.account-assist {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c131b;
}

.assist-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.assist-head strong {
  font-size: 14px;
}

.assist-head span {
  color: var(--muted);
  font-size: 12px;
}

.suggestion-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.suggestion {
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #101a24;
  text-align: left;
}

.suggestion:hover {
  border-color: var(--accent);
  background: #132331;
}

.suggestion span {
  display: block;
  font-weight: 900;
}

.suggestion small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.template-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.template-chip {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.12);
  color: #bfdbfe;
  border: 1px solid rgba(96, 165, 250, 0.28);
  font-size: 12px;
  font-weight: 800;
}

.template-chip:hover {
  background: rgba(96, 165, 250, 0.2);
}

.ledger-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.ledger-titlebar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #162130, #101821);
}

.help-dot {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  margin-left: 4px;
  background: var(--accent-3);
  color: #07111f;
  font-size: 12px;
}

.ledger-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #0f1721;
}

.ledger-filters {
  display: grid;
  grid-template-columns: 112px 150px 18px 150px 170px 160px minmax(220px, 1fr);
  gap: 8px;
  align-items: center;
}

.ledger-filters input,
.ledger-filters select,
.quick-entry input,
.quick-entry select {
  min-height: 34px;
  padding: 6px 9px;
}

.range-mark {
  color: var(--muted);
  text-align: center;
}

.ledger-actions,
.ledger-bulk {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.ledger-bulk {
  grid-column: 1 / 2;
  justify-content: flex-start;
}

.ledger-count {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--ink);
  font-weight: 800;
  font-size: 13px;
}

.pager {
  color: var(--muted);
  font-weight: 700;
}

.ledger-table-wrap {
  border: 0;
  border-radius: 0;
  max-height: calc(100vh - 340px);
}

.ledger-table {
  min-width: 1280px;
  font-size: 13px;
}

.ledger-table th,
.ledger-table td {
  padding: 6px 8px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

.ledger-table th {
  top: 0;
  z-index: 1;
  color: #e7eef6;
  background: #263344;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

.ledger-table tbody tr:nth-child(odd) {
  background: #101822;
}

.ledger-table tbody tr:nth-child(even) {
  background: #0c131b;
}

.ledger-table tbody tr:hover {
  background: #1b2d3a;
}

.ledger-table tbody tr:first-child {
  background: rgba(245, 158, 11, 0.2);
}

.check-col {
  width: 34px;
  text-align: center;
}

.check-col input,
.todo input {
  width: 14px;
  height: 14px;
  min-height: 14px;
  accent-color: var(--accent);
}

.date-cell {
  color: #c9ddff;
  font-weight: 900;
}

.flag-cell {
  color: var(--muted);
  text-align: center;
}

.memo-cell {
  min-width: 220px;
  white-space: normal;
}

.settings-stack {
  display: grid;
  gap: 16px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.settings-grid .card:nth-child(2) {
  grid-row: span 2;
}

.status-list {
  display: grid;
  gap: 10px;
}

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.status-list span {
  color: var(--muted);
}

.status-list strong {
  text-align: right;
}

.master-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}

.account-master-form {
  grid-template-columns: minmax(140px, 1fr) 150px minmax(140px, 1fr) auto;
}

.master-list {
  display: grid;
  gap: 8px;
}

.master-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1219;
}

.master-row strong,
.master-row span {
  display: block;
  overflow-wrap: anywhere;
}

.master-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.policy-body {
  background: var(--bg);
}

.policy-page {
  width: min(980px, calc(100% - 40px));
  margin: 0 auto;
  padding: 56px 0 72px;
}

.policy-hero {
  margin-bottom: 48px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.policy-back {
  display: inline-flex;
  margin-bottom: 28px;
  color: #bfeee7;
  text-decoration: none;
  font-weight: 800;
}

.policy-back:hover {
  text-decoration: underline;
}

.policy-link {
  color: #bfeee7;
  overflow-wrap: anywhere;
}

.policy-link:hover {
  text-decoration: none;
}

.policy-action {
  margin-bottom: 28px;
  text-decoration: none;
}

.policy-hero h1 {
  margin: 0 0 18px;
  font-size: 38px;
  letter-spacing: 0;
}

.policy-hero p,
.policy-section p,
.policy-section li,
.policy-footer p {
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 2;
}

.policy-hero p,
.policy-footer p {
  color: var(--muted);
  font-weight: 600;
}

.policy-date {
  margin-top: 16px;
}

.policy-section {
  margin: 0 0 52px;
}

.policy-section h2 {
  margin: 0 0 28px;
  padding-left: 20px;
  border-left: 5px solid var(--accent);
  font-size: 28px;
  line-height: 1.45;
  letter-spacing: 0;
}

.policy-section p {
  margin: 0;
  padding-left: 26px;
}

.policy-section ol {
  margin: 0;
  padding: 0 0 0 26px;
  list-style: none;
  counter-reset: policy-counter;
}

.policy-section li {
  position: relative;
  margin: 0 0 20px;
  padding-left: 34px;
  counter-increment: policy-counter;
}

.policy-section li::before {
  content: counter(policy-counter) ".";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 900;
}

.policy-footer {
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

@media (max-width: 1020px) {
  .auth-shell, .app-shell, .metrics, .reports, .two-col, .settings-grid { grid-template-columns: 1fr; }
  .auth-copy { padding: 32px; min-height: 360px; }
  .sidebar { position: static; height: auto; }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .user-box { margin-top: 0; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 16px; }
  .content { padding: 16px; }
  .quick-entry,
  .ledger-toolbar,
  .ledger-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ledger-titlebar,
  .card-head,
  .verify-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .ledger-bulk,
  .ledger-count {
    grid-column: 1 / -1;
  }

  .suggestion-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .master-form,
  .account-master-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 580px) {
  .auth-copy, .auth-panel { padding: 20px; }
  .nav, .form-grid, .quick-entry, .ledger-toolbar, .ledger-filters, .master-form, .account-master-form { grid-template-columns: 1fr; }
  .journal-entry { grid-template-columns: 1fr; }
  .metric strong { font-size: 21px; }
  .suggestion-list { grid-template-columns: 1fr; }
  .assist-head { align-items: flex-start; flex-direction: column; }
}
