:root {
  --ink: #24303f;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #f6f8fb;
  --panel: #ffffff;
  --blue: #2f6fbd;
  --green: #1f8a5b;
  --coral: #d95c48;
  --gold: #c38b20;
  --violet: #6d5bd0;
  --soft-blue: #eaf2ff;
  --soft-green: #eaf8f1;
  --soft-coral: #fff0ed;
  --soft-gold: #fff6dd;
  --soft-violet: #f0eeff;
  --shadow: 0 16px 42px rgba(36, 48, 63, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #f3f7fb 0%, #fbfcff 46%, #f6f8fb 100%);
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  line-height: 1.6;
}

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
}

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

.brand {
  margin-bottom: 28px;
}

.brand strong {
  display: block;
  font-size: 1.35rem;
}

.brand span {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.nav-link,
.ghost-button,
.primary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
}

.nav-link {
  justify-content: flex-start;
  color: var(--muted);
}

.nav-link.active,
.primary-button {
  color: #fff;
  background: var(--blue);
}

.ghost-button {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.danger-button {
  color: #fff;
  background: var(--coral);
}

.logout-button {
  width: 100%;
  margin-top: 22px;
}

.content {
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
  padding: 34px 0 48px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.25rem;
}

.lead,
.muted {
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.panel {
  padding: 20px;
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.1;
}

.metric.income {
  background: var(--soft-green);
}

.metric.expense {
  background: var(--soft-coral);
}

.metric.balance {
  background: var(--soft-blue);
}

.metric.ratio {
  background: var(--soft-gold);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  color: var(--ink);
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.status {
  min-height: 24px;
  margin-top: 10px;
  color: var(--muted);
}

.status.error {
  color: var(--coral);
  font-weight: 700;
}

.status.success {
  color: var(--green);
  font-weight: 700;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 90px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  background: #e5eaf2;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--blue);
}

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

.transaction-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 110px 120px auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.amount-income {
  color: var(--green);
  font-weight: 900;
}

.amount-expense {
  color: var(--coral);
  font-weight: 900;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
}

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

.login-card {
  width: min(460px, 100%);
  padding: 28px;
}

.login-card h1 {
  font-size: 2.3rem;
}

.mobile-nav {
  display: none;
}

.empty {
  padding: 16px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.summary-note {
  padding: 14px;
  background: var(--soft-green);
  border: 1px solid #cbeedc;
  border-radius: 8px;
  color: #176844;
  font-weight: 700;
}

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

  .sidebar {
    display: none;
  }

  .mobile-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: 8px;
    align-items: center;
    overflow-x: auto;
    padding: 10px 12px;
    background: rgba(238, 244, 251, 0.96);
    border-bottom: 1px solid var(--line);
  }

  .mobile-nav .nav-link {
    white-space: nowrap;
  }

  .content {
    width: min(100% - 24px, 1120px);
    padding-top: 24px;
  }

  .page-head {
    display: block;
  }

  .grid.two,
  .grid.three,
  .grid.four-metrics,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .transaction-item {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .bar-row strong {
    grid-column: 2;
  }
}
