:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-alt: #f8faf8;
  --ink: #1c2a24;
  --muted: #63716a;
  --line: #dde3df;
  --line-strong: #c9d2cc;
  --accent: #1f4d3d;
  --accent-hover: #173c30;
  --accent-soft: #e8f0ec;
  --danger: #972f2f;
  --danger-soft: #fbeceb;
  --warn: #7d5411;
  --warn-soft: #fdf3df;
  --ok: #1f6b46;
  --ok-soft: #e9f4ee;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 35, 28, 0.05), 0 8px 24px rgba(20, 35, 28, 0.04);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.15rem);
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
}

code {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.05rem 0.3rem;
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 20;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 1.02rem;
}

.brand-text small {
  color: var(--muted);
  font-size: 0.76rem;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.user-name {
  font-weight: 600;
}

.user-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.logout-form {
  margin: 0;
}

.simulation-banner {
  background: var(--warn-soft);
  border-bottom: 1px solid #eedcab;
  color: var(--warn);
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  text-align: center;
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem;
}

.card.narrow {
  max-width: 620px;
}

.hero {
  padding: clamp(1.6rem, 1rem + 2vw, 2.8rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

.lead {
  color: var(--muted);
  max-width: 62ch;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

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

.card.small {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card.small p {
  color: var(--muted);
  font-size: 0.92rem;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.metric-label {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-number {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.notice {
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--line);
  font-size: 0.94rem;
}

.notice ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}

.notice.success {
  background: var(--ok-soft);
  border-color: #c9e4d4;
  color: var(--ok);
}

.notice.error {
  background: var(--danger-soft);
  border-color: #efc9c6;
  color: var(--danger);
}

.record-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-head p {
  font-size: 0.9rem;
}

.record-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.record {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.record-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.record-identity {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.record-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.record-title h3 {
  overflow-wrap: anywhere;
}

.record-notes {
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.record-amount {
  font-size: 1.3rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid transparent;
  background: var(--surface-alt);
  color: var(--muted);
}

.status-active,
.status-recorded {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #cbe5d5;
}

.status-paused {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: #eedcab;
}

.status-cancelled,
.status-void {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #efc9c6;
}

.status-reviewed {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #cfe0d7;
}

.badge.overdue {
  background: var(--danger);
  color: #fff;
}

.record-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-top: 1px dashed var(--line);
  padding-top: 0.9rem;
}

.record-tools form {
  margin: 0;
}

.record-files {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.4rem 0.25rem 0.7rem;
  font-size: 0.84rem;
  max-width: 100%;
}

.chip a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 24ch;
}

.chip-size {
  color: var(--muted);
  font-size: 0.74rem;
}

.chip-delete {
  margin: 0;
  display: inline-flex;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 9px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.2;
}

.button:hover {
  border-color: var(--accent);
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.button.ghost {
  background: transparent;
}

.button.danger {
  color: var(--danger);
  border-color: #e6c3c0;
}

.button.danger:hover {
  background: var(--danger-soft);
}

.button.small {
  padding: 0.35rem 0.7rem;
  font-size: 0.84rem;
}

.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid #9dc3b2;
  outline-offset: 2px;
}

.icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  cursor: pointer;
  border-radius: 6px;
}

.icon-button:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

summary {
  cursor: pointer;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary.button {
  width: fit-content;
}

.new-record {
  position: relative;
}

.new-record[open] > summary {
  margin-bottom: 0.5rem;
}

.new-record-body {
  position: relative;
  z-index: 2;
}

.new-record-body .new-record-inner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  max-width: 760px;
}

.new-record-inner > summary {
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.editor-body {
  margin-top: 0.6rem;
}

.editor-body .record-form {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.88rem;
}

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

.field > span {
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  padding: 0.5rem 0.6rem;
  font: inherit;
  color: var(--ink);
}

.form-actions {
  margin-top: 0.9rem;
  display: flex;
  gap: 0.6rem;
}

.upload-trigger {
  position: relative;
  overflow: hidden;
}

.upload-trigger input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 0.1px;
}

.upload-hint {
  margin-top: 0.2rem;
}

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

.tiny {
  font-size: 0.78rem;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 1.6rem;
}

.narrow {
  margin: 0 auto;
}

.sim-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.sim-form fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sim-form legend {
  padding: 0 0.3rem;
  font-weight: 600;
  font-size: 0.85rem;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem;
  border-radius: 8px;
}

.radio-row:hover {
  background: var(--surface-alt);
}

.radio-row span {
  display: flex;
  flex-direction: column;
}

.radio-row small {
  color: var(--muted);
}

@media (max-width: 860px) {
  .summary,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .record-head {
    flex-direction: column;
    gap: 0.4rem;
  }
}

@media (max-width: 620px) {
  .page {
    padding: 1.25rem 0.9rem 2.5rem;
    gap: 1.1rem;
  }

  .topbar-inner {
    padding: 0.7rem 0.9rem;
  }

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

  .field.wide {
    grid-column: auto;
  }

  .card {
    padding: 1rem;
  }

  .record-tools {
    gap: 0.4rem;
  }

  .chip a {
    max-width: 18ch;
  }

  .footer {
    padding: 0 0.9rem 2rem;
  }
}
