:root {
  color-scheme: light;
  --ink: #14211d;
  --muted: #5f6f69;
  --line: #dce5e1;
  --paper: #f7faf8;
  --accent: #0D4731;
  --accent-dark: #072C1E;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px;
}

.brand {
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 18px;
}

nav a {
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
}

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

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 20px 80px;
}

.hero {
  padding: 64px 0 44px;
}

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

h1 {
  max-width: 760px;
  margin: 12px 0 18px;
  font-size: clamp(2.2rem, 6vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.lead {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.6;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button {
  display: inline-block;
  border-radius: 999px;
  padding: 12px 18px;
  color: white;
  background: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

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

.button.secondary {
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--line);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.card {
  padding: 22px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

.main-nav {
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.user-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.logout-form {
  margin: 0;
}

.link-button {
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.messages {
  display: grid;
  gap: 8px;
  margin: 12px 0 20px;
}

.message {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: white;
  font-size: 0.92rem;
}

.message.success {
  border-color: #b7e4d0;
  background: #effaf4;
  color: #075a43;
}

.message.warning {
  border-color: #f2dfaf;
  background: #fffaf0;
  color: #7a5300;
}

.message.error {
  border-color: #f0c2c2;
  background: #fff5f5;
  color: #8a1f1f;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin: 20px 0 28px;
}

.page-head h1 {
  margin: 6px 0 8px;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
}

.page-head .lead {
  margin: 0;
  font-size: 1rem;
}

.back-link {
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
}

.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: none;
}

.tab span {
  border-radius: 999px;
  padding: 1px 7px;
  background: #edf2ef;
  font-size: 0.75rem;
}

.tab:hover,
.tab.active {
  color: var(--accent);
  background: #eaf6f0;
  border-color: #c7e7d8;
}

.filters {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto auto auto auto;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
}

.filter-search {
  min-width: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
  font: inherit;
  font-size: 0.92rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #b7e4d0;
  outline-offset: 1px;
  border-color: var(--accent);
}

.filters select,
.filters input {
  min-height: 42px;
}

.filters input[type="search"] {
  min-width: 0;
}

.filters .button {
  min-height: 42px;
  white-space: nowrap;
}

.htmx-indicator {
  display: none;
  color: var(--muted);
  font-size: 0.82rem;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.data-table th,
.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid #edf2ef;
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

.data-table th {
  color: var(--muted);
  background: #fbfdfc;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #fbfdfc;
}

.document-link {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.document-link:hover {
  color: var(--accent);
}

.subtext {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.amount {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.date {
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.82rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge.large {
  padding: 7px 12px;
  font-size: 0.84rem;
}

.badge.neutral {
  color: #4b5c56;
  background: #eef3f1;
}

.badge.info {
  color: #0D4731;
  background: #ecfdf5;
}

.badge.warning {
  color: #7a5300;
  background: #fff4d9;
}

.badge.success {
  color: #075a43;
  background: #e5f7ee;
}

.badge.danger {
  color: #8a1f1f;
  background: #fdecec;
}

.empty-state {
  border: 1px dashed #c9d8d2;
  border-radius: 16px;
  padding: 32px 24px;
  background: white;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.empty-state p {
  margin: 0 0 18px;
  color: var(--muted);
}

.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(240px, 0.7fr);
  align-items: start;
  gap: 18px;
}

.form-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  background: white;
}

.form-card.compact {
  border: 0;
  border-radius: 0;
  padding: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
}

.field.has-error input,
.field.has-error select {
  border-color: #d66b6b;
}

.field-error,
.errorlist {
  margin: 0;
  color: #8a1f1f;
  font-size: 0.8rem;
  list-style: none;
  padding: 0;
}

.help {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

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

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.button {
  border: 1px solid transparent;
  cursor: pointer;
}

.button.secondary {
  color: var(--accent);
  background: white;
  border-color: var(--line);
}

.button.secondary:hover {
  background: #f3faf6;
}

.button.danger {
  color: #8a1f1f;
  background: #fff5f5;
  border-color: #f0c2c2;
}

.button.danger:hover {
  background: #fdecec;
}

.inline-form {
  margin-top: 14px;
}

.info-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  background: #f0f8f4;
}

.info-card h2 {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.steps {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.steps li + li {
  margin-top: 8px;
}

.document-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.preview-panel,
.review-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: white;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
}

.muted-link {
  color: var(--accent);
  font-size: 0.86rem;
  text-decoration: none;
}

.preview-image,
.preview-frame {
  display: block;
  width: 100%;
  max-height: 620px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f5f8f6;
  object-fit: contain;
}

.preview-frame {
  height: 620px;
}

.preview-empty {
  border: 1px dashed #c9d8d2;
  border-radius: 12px;
  padding: 34px 20px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

.preview-empty a {
  color: var(--accent);
}

.meta-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 17px 0 0;
}

.meta-list dt {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.meta-list dd {
  margin: 2px 0 0;
  font-size: 0.88rem;
}

.preview-panel h3 {
  margin: 20px 0 8px;
  font-size: 0.9rem;
}

.run-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.run-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #edf2ef;
  padding-top: 8px;
  font-size: 0.82rem;
}

.run-list .subtext {
  display: inline;
  margin: 0;
}

.alert {
  border-radius: 12px;
  padding: 11px 13px;
  margin-bottom: 14px;
  font-size: 0.86rem;
  line-height: 1.45;
}

.alert.error {
  border: 1px solid #f0c2c2;
  background: #fff5f5;
  color: #8a1f1f;
}

.alert.success {
  border: 1px solid #b7e4d0;
  background: #effaf4;
  color: #075a43;
}

.issues {
  margin-top: 18px;
  border-top: 1px solid #edf2ef;
  padding-top: 14px;
}

.issues h3 {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.issues ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.issue {
  border-left: 3px solid var(--line);
  padding: 5px 9px;
  color: var(--muted);
  font-size: 0.82rem;
}

.issue.warning {
  border-color: #e7b43c;
}

.issue.error {
  border-color: #d66b6b;
}

.auth-card {
  max-width: 460px;
  margin: 60px auto 0;
}

.auth-card h1 {
  margin-top: 4px;
  font-size: 2.5rem;
}

.auth-card .lead {
  margin-bottom: 22px;
}

@media (max-width: 900px) {
  .document-layout,
  .form-layout {
    grid-template-columns: 1fr;
  }

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

  .filter-search {
    grid-column: 1 / -1;
  }

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

@media (max-width: 620px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .main-nav {
    justify-content: flex-start;
  }

  .page-head {
    flex-direction: column;
  }

  .page-head > .button,
  .page-head > .badge {
    align-self: flex-start;
  }

  .field-grid,
  .meta-list {
    grid-template-columns: 1fr;
  }

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

  .filters .button {
    width: 100%;
  }
}


