:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --canvas: oklch(0.975 0.004 45);
  --bg: oklch(0.995 0.002 45);
  --surface: oklch(0.96 0.006 45);
  --surface-strong: oklch(0.925 0.01 45);
  --ink: oklch(0.22 0.018 35);
  --muted: oklch(0.46 0.018 35);
  --line: oklch(0.88 0.012 45);
  --primary: oklch(0.49 0.145 32);
  --primary-hover: oklch(0.43 0.15 32);
  --primary-soft: oklch(0.94 0.03 32);
  --danger: oklch(0.52 0.18 25);
  --danger-soft: oklch(0.96 0.025 25);
  --success: oklch(0.43 0.13 150);
  --focus: oklch(0.6 0.15 32);
  --sidebar-width: 248px;
  --radius: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  overflow-x: hidden;
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

button,
input {
  color: inherit;
  font: inherit;
}

button,
a,
input {
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease), color 180ms var(--ease), opacity 180ms var(--ease), transform 180ms var(--ease);
}

a {
  color: inherit;
}

h1,
h2,
p,
dl,
dd {
  margin-top: 0;
}

h1,
h2 {
  line-height: 1.25;
  letter-spacing: -0.018em;
  text-wrap: balance;
}

h1 {
  margin-bottom: 6px;
  font-size: 1.7rem;
}

h2 {
  margin-bottom: 5px;
  font-size: 1rem;
}

p {
  text-wrap: pretty;
}

small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

input:hover {
  border-color: oklch(0.68 0.04 35);
}

input::placeholder {
  color: oklch(0.43 0.018 35);
}

label {
  display: grid;
  gap: 5px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 650;
}

.app-bootstrap {
  width: min(680px, calc(100% - 40px));
  margin: 18vh auto;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.sidebar > .brand-lockup {
  min-height: 78px;
  padding: 0 19px;
  border-bottom: 1px solid var(--line);
}

.brand-lockup > span:last-child {
  min-width: 0;
}

.brand-lockup strong {
  display: block;
  font-weight: 760;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: var(--primary);
  color: oklch(1 0 0);
  font-weight: 800;
}

.sidebar nav {
  display: grid;
  gap: 4px;
  padding: 18px 12px;
}

.sidebar nav a {
  display: flex;
  min-height: 44px;
  align-items: center;
  padding: 0 13px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
}

.sidebar nav a:hover {
  background: var(--surface);
  color: var(--ink);
}

.sidebar nav a:active {
  transform: translateY(1px);
}

.sidebar nav a[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.store-binding {
  display: grid;
  gap: 3px;
  margin-top: auto;
  padding: 17px 19px 20px;
  border-top: 1px solid var(--line);
}

.store-binding span,
.topbar span {
  color: var(--muted);
  font-size: 0.78rem;
}

.store-binding strong {
  overflow-wrap: anywhere;
  font-size: 0.88rem;
}

.main-content {
  min-width: 0;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--canvas);
}

.topbar > div {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.topbar strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-field {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
}

.month-field input {
  width: 148px;
}

.page-content {
  width: min(1080px, 100%);
  padding: 32px 30px 72px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header p {
  max-width: 68ch;
  margin-bottom: 0;
  color: var(--muted);
}

.mobile-nav {
  display: none;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-hover);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: oklch(1 0 0);
}

.button-primary:hover:not(:disabled) {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  color: oklch(1 0 0);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metrics-board {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(220px, 1fr) minmax(230px, 1.15fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.metric,
.metric-pair {
  min-width: 0;
  padding: 20px;
  border-right: 1px solid var(--line);
}

.metric > span,
.metric-pair span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.metric > strong,
.metric-pair strong,
.record-row header b {
  font-variant-numeric: tabular-nums;
}

.metric > strong {
  font-size: 1.3rem;
}

.metric-primary {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.metric-pair {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  border-right: 0;
}

.metric-pair > div + div {
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.calculation-note {
  margin: 10px 0 28px;
  color: var(--muted);
  font-size: 0.82rem;
}

.next-actions,
.logout-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.next-actions p,
.logout-section p,
.password-section > p {
  margin-bottom: 0;
  color: var(--muted);
}

.records-list {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.record-row {
  padding: 18px 4px;
  background: transparent;
}

.record-row + .record-row {
  border-top: 1px solid var(--line);
}

.record-row header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.record-row header > div {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.record-row header strong {
  overflow-wrap: anywhere;
}

.record-row header span {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.record-row header b {
  flex: 0 0 auto;
  color: var(--primary-hover);
  font-size: 1rem;
}

.record-row dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 22px;
  margin-bottom: 0;
}

.record-row dl > div {
  min-width: 0;
}

.record-row dt,
.account-layout dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.record-row dd,
.account-layout dd {
  margin-left: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.settlement-row dl {
  grid-template-columns: minmax(120px, 0.8fr) minmax(180px, 1fr) minmax(200px, 1.4fr);
}

.load-more {
  margin-top: 16px;
}

.account-layout {
  display: grid;
  grid-template-columns: minmax(210px, 0.65fr) minmax(320px, 1fr);
  gap: 0 36px;
}

.account-summary,
.password-section {
  padding: 20px 0 26px;
  border-top: 1px solid var(--line);
}

.account-summary dl {
  display: grid;
  gap: 16px;
  margin: 18px 0 0;
}

.password-section > p {
  margin-bottom: 18px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.form-stack .button {
  justify-self: start;
}

.form-error {
  min-height: 21px;
  margin-bottom: 0;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 650;
}

.logout-section {
  grid-column: 1 / -1;
  margin-top: 8px;
}

.empty-state,
.error-state {
  max-width: 620px;
  padding: 26px;
  border-radius: var(--radius);
  background: var(--surface);
}

.empty-state h2,
.error-state h2 {
  margin-bottom: 6px;
}

.empty-state p,
.error-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.error-state {
  background: var(--danger-soft);
}

.error-state .button {
  margin-top: 16px;
}

.skeleton-stack {
  display: grid;
  gap: 12px;
  max-width: 820px;
  padding: 4px 0;
}

.skeleton-stack span {
  display: block;
  height: 48px;
  border-radius: 8px;
  background: var(--surface-strong);
}

.skeleton-stack .skeleton-short {
  width: 62%;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 20px;
}

.login-panel {
  width: min(410px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.login-panel > .brand-lockup {
  margin-bottom: 28px;
}

.login-panel h1 {
  margin-top: 0;
}

.login-panel > div:nth-child(2) p,
.login-note {
  color: var(--muted);
}

.login-panel .form-stack {
  margin-top: 22px;
}

.login-panel .button {
  width: 100%;
}

.login-note {
  margin: 18px 0 0;
  font-size: 0.8rem;
}

.feedback {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-weight: 650;
}

@media (max-width: 960px) {
  .metrics-board {
    grid-template-columns: 1fr 1fr;
  }

  .metric,
  .metric-pair {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:nth-child(odd) {
    border-right: 1px solid var(--line);
  }

  .metric-pair {
    grid-column: 1 / -1;
    border-bottom: 0;
  }

  .record-row dl {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .topbar {
    position: static;
    min-height: 68px;
    padding: 9px 16px;
  }

  .topbar > div {
    max-width: calc(100% - 146px);
  }

  .month-field {
    display: grid;
    gap: 2px;
  }

  .month-field input {
    width: 138px;
    min-height: 44px;
  }

  .page-content {
    padding: 24px 16px 92px;
  }

  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 5px max(4px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: var(--bg);
  }

  .mobile-nav a {
    display: grid;
    min-width: 0;
    min-height: 48px;
    place-items: center;
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
  }

  .mobile-nav a[aria-current="page"] {
    background: var(--primary-soft);
    color: var(--primary-hover);
  }

  .account-layout {
    grid-template-columns: 1fr;
  }

  .logout-section {
    grid-column: 1;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 1.45rem;
  }

  .page-header {
    margin-bottom: 20px;
  }

  .metrics-board {
    grid-template-columns: 1fr;
  }

  .metric,
  .metric:nth-child(odd) {
    border-right: 0;
  }

  .metric-pair {
    grid-column: 1;
  }

  .next-actions,
  .logout-section {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .button-row,
  .button-row .button,
  .logout-section .button {
    width: 100%;
  }

  .record-row header {
    gap: 10px;
  }

  .record-row dl,
  .settlement-row dl {
    grid-template-columns: 1fr 1fr;
  }

  .record-note {
    grid-column: 1 / -1;
  }

  .empty-state,
  .error-state,
  .login-panel {
    padding: 22px 18px;
  }
}

@media (max-width: 360px) {
  .topbar {
    gap: 8px;
    padding-inline: 12px;
  }

  .topbar > div {
    max-width: calc(100% - 130px);
  }

  .month-field input {
    width: 126px;
    padding-inline: 6px;
  }

  .page-content {
    padding-inline: 12px;
  }

  .metric,
  .metric-pair {
    padding: 16px;
  }

  .record-row dl,
  .settlement-row dl {
    grid-template-columns: 1fr;
  }

  .record-note {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
