:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --text: #1d2733;
  --muted: #647386;
  --line: #d8e0e8;
  --accent: #1f7a5c;
  --accent-strong: #176146;
  --danger: #a83a32;
  --danger-bg: #fff1ef;
  --shadow: 0 16px 40px rgba(39, 52, 68, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.landing {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.landing-hero {
  display: grid;
  gap: 14px;
  max-width: 760px;
  padding: 42px 0 84px;
}

.tools-section {
  margin-top: 0;
}

.section-heading {
  margin-bottom: 18px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 360px));
  gap: 18px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 230px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-card h3 {
  margin: 0 0 10px;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.tool-card-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  margin-top: 28px;
  text-decoration: none;
}

.tool-nav {
  margin-bottom: 26px;
}

.back-link {
  color: var(--accent-strong);
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.intro {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 20px;
  line-height: 1.2;
}

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

.lead {
  margin-bottom: 0;
  max-width: 640px;
  font-size: 18px;
  line-height: 1.55;
}

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

.status-card {
  padding: 18px;
}

.status-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status-card strong {
  font-size: 20px;
}

.panel {
  padding: 22px;
}

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

.panel-header.compact {
  align-items: center;
}

.panel-header p {
  margin-bottom: 0;
}

textarea {
  display: block;
  width: 100%;
  min-height: 190px;
  padding: 16px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fbfcfd;
  color: var(--text);
  line-height: 1.5;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 92, 0.14);
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

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

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.secondary-button {
  border: 1px solid var(--accent);
  background: #ffffff;
  color: var(--accent-strong);
}

.text-button {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: #314053;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.options-panel {
  margin-top: 18px;
}

.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.year-filter {
  display: grid;
  grid-template-columns: 160px 160px 1fr;
  gap: 14px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.year-filter label {
  display: block;
  margin-bottom: 6px;
  color: #354456;
  font-size: 14px;
  font-weight: 700;
}

.year-filter input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.year-filter input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 92, 0.14);
}

.year-filter p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.field-options {
  display: grid;
  gap: 18px;
  margin-top: 16px;
}

.field-group {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.field-group h3 {
  margin: 0 0 12px;
  color: #223044;
  font-size: 18px;
  line-height: 1.2;
}

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

.field-options-grid label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  position: relative;
  min-height: 46px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #314053;
  line-height: 1.25;
}

.field-label-text {
  flex: 1 1 auto;
}

.field-options-grid input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.hint {
  position: relative;
  flex: 0 0 auto;
  margin-left: auto;
}

.hint-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #c5d0dc;
  border-radius: 50%;
  background: #f1f4f7;
  color: #657489;
  cursor: help;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.hint-icon:focus-visible {
  outline: 3px solid rgba(31, 122, 92, 0.18);
  outline-offset: 2px;
}

.hint-text {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 10;
  width: min(320px, calc(100vw - 64px));
  padding: 12px 14px;
  border: 1px solid #cfd9e4;
  border-radius: 8px;
  background: #243244;
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(22, 32, 45, 0.22);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.hint-text::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 100%;
  border: 7px solid transparent;
  border-top-color: #243244;
}

.hint:hover .hint-text,
.hint:focus-within .hint-text {
  opacity: 1;
  transform: translateY(0);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 220ms ease;
}

.actions-panel {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-top: 18px;
}

.actions-panel p {
  margin-bottom: 0;
}

.result-status {
  min-width: 0;
  flex: 1 1 auto;
}

.result-status .progress-block {
  margin-top: 18px;
  max-width: 620px;
}

.result-actions {
  display: grid;
  gap: 12px;
  width: min(260px, 100%);
  flex: 0 0 260px;
}

.result-actions .primary-button,
.result-actions .secondary-button {
  width: 100%;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  margin-top: 18px;
}

.table-panel,
.errors-panel {
  min-width: 0;
}

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

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  background: var(--surface-soft);
  color: #354456;
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

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

.error-list li {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #f0c8c3;
  border-radius: 8px;
  background: var(--danger-bg);
}

.error-list strong {
  color: var(--danger);
}

.error-list span {
  color: #71423e;
  font-size: 14px;
}

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

@media (max-width: 860px) {
  .landing {
    padding-top: 34px;
  }

  .landing-hero {
    padding-bottom: 52px;
  }

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

  .tool-card {
    min-height: 220px;
  }

  .intro,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .actions-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .result-actions {
    width: 100%;
    flex-basis: auto;
  }

  .primary-button,
  .secondary-button,
  .text-button {
    width: 100%;
  }

  .quick-actions,
  .year-filter,
  .field-options-grid {
    grid-template-columns: 1fr;
  }
}
