:root {
  --ink: #16201f;
  --muted: #5d6865;
  --line: #d8dedc;
  --surface: #ffffff;
  --page: #eef3f1;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #d99f2b;
  --danger: #b83b46;
  --ok: #23724d;
  --shadow: 0 12px 32px rgba(20, 35, 32, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family:
    "Yu Gothic UI", "Meiryo", "Microsoft YaHei UI", "Noto Sans JP", Arial,
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: white;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--primary-dark);
}

button.secondary {
  background: #e6ecea;
  color: var(--ink);
}

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(rgba(238, 243, 241, 0.9), rgba(238, 243, 241, 0.9)),
    url("https://images.unsplash.com/photo-1554224155-6726b3ff858f?auto=format&fit=crop&w=1800&q=75")
      center/cover;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(460px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-head {
  display: grid;
  gap: 16px;
  margin-bottom: 22px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

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

.sidebar {
  background: #f8fbfa;
  border-right: 1px solid var(--line);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand img {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

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

.nav-item {
  width: 100%;
  background: transparent;
  color: var(--ink);
  text-align: left;
  border: 1px solid transparent;
}

.nav-item.active,
.nav-item:hover {
  background: #dcefeb;
  border-color: #b8d9d2;
  color: var(--primary-dark);
}

.sidebar-note {
  margin-top: auto;
  background: #fff7df;
  border: 1px solid #ead48e;
  border-radius: 8px;
  padding: 14px;
}

.sidebar-note span {
  color: var(--muted);
  font-size: 13px;
}

.sidebar-note strong {
  display: block;
  margin-top: 6px;
}

.main {
  padding: 26px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--muted);
  margin: 0 0 6px;
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

.top-actions,
.bank-tools,
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}

.language-switch {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.language-switch button {
  padding: 7px 10px;
}

.language-switch button.active {
  background: var(--primary);
  color: white;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi {
  padding: 18px;
  min-height: 112px;
}

.kpi span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.kpi strong {
  display: block;
  font-size: 26px;
  margin-top: 12px;
}

.kpi.warn strong {
  color: var(--danger);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
  gap: 18px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

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

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

.bar-chart {
  display: grid;
  gap: 10px;
}

.month-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.month-row:last-child {
  border-bottom: 0;
}

.month-row > strong {
  font-variant-numeric: tabular-nums;
}

.month-bars {
  display: grid;
  gap: 6px;
}

.mini-bar {
  display: grid;
  grid-template-columns: 44px minmax(90px, 1fr) 112px;
  gap: 8px;
  align-items: center;
}

.mini-bar span,
.mini-bar em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.mini-bar em {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  background: #edf2f0;
  border-radius: 6px;
  overflow: hidden;
  height: 22px;
}

.bar-fill {
  background: var(--primary);
  height: 100%;
  min-width: 2px;
}

.bar-fill.income {
  background: var(--ok);
}

.bar-fill.expense {
  background: var(--accent);
}

.bar-fill.negative {
  background: var(--danger);
}

.compact-list,
.master-list {
  display: grid;
  gap: 10px;
}

.compact-item,
.master-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.compact-item strong,
.master-item strong {
  display: block;
}

.compact-item span,
.master-item span {
  color: var(--muted);
  font-size: 13px;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: white;
  color: var(--ink);
}

textarea {
  resize: vertical;
  margin-top: 12px;
}

.entry-grid button {
  align-self: end;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  background: white;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #e8f1ef;
  font-size: 13px;
}

td.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.status.pending {
  color: #8a4f00;
  background: #fff2cc;
}

.status.confirmed {
  color: var(--ok);
  background: #dff4e8;
}

.status.hold {
  color: var(--danger);
  background: #f8d7da;
}

.import-preview {
  margin-top: 12px;
  color: var(--muted);
}

.journal-summary {
  margin: 12px 0;
  color: var(--muted);
  font-weight: 700;
}

.total-row td {
  background: #f1f6f4;
  font-weight: 800;
}

dialog {
  border: 0;
  border-radius: 8px;
  width: min(460px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}

dialog form {
  display: grid;
  gap: 12px;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  margin: 8px 0 0;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .topbar,
  .split {
    display: grid;
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .kpi-grid,
  .entry-grid,
  .nav-list {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .month-row,
  .mini-bar {
    grid-template-columns: 1fr;
  }

  .mini-bar em {
    text-align: left;
  }
}
