:root {
  --ink: #172033;
  --muted: #677084;
  --line: #dfe4eb;
  --line-strong: #cfd6df;
  --canvas: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --navy: #16324f;
  --navy-deep: #10263c;
  --green: #177557;
  --green-soft: #e8f5ef;
  --gold: #efb43d;
  --gold-soft: #fff5db;
  --red: #b84242;
  --red-soft: #fff0f0;
  --shadow: 0 12px 34px rgba(23, 32, 51, 0.08);
  --shadow-soft: 0 4px 15px rgba(23, 32, 51, 0.06);
  --radius: 14px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-width: 320px;
  max-width: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 86% 1%, rgba(239, 180, 61, 0.12), transparent 27rem),
    var(--canvas);
}

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

button,
summary,
select,
input[type="radio"],
input[type="checkbox"] {
  cursor: pointer;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1320px) / 2));
  color: white;
  background: rgba(16, 38, 60, 0.97);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--navy-deep);
  background: var(--gold);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -0.05em;
  border-radius: 9px 2px 9px 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.brand-copy {
  display: grid;
  gap: 1px;
}

.brand-copy strong {
  font-size: 16px;
  letter-spacing: 0.01em;
}

.brand-copy small {
  color: #b9c7d5;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.server-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #c8d3de;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #96a4b2;
  box-shadow: 0 0 0 4px rgba(150, 164, 178, 0.12);
}

.server-status.online .status-dot {
  background: #58d19a;
  box-shadow: 0 0 0 4px rgba(88, 209, 154, 0.14);
}

.server-status.offline .status-dot {
  background: #ff7b7b;
  box-shadow: 0 0 0 4px rgba(255, 123, 123, 0.14);
}

.api-settings {
  position: relative;
}

.api-settings summary {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 9px;
  list-style: none;
}

.api-settings summary::-webkit-details-marker {
  display: none;
}

.api-settings summary:hover {
  background: rgba(255, 255, 255, 0.08);
}

.api-settings svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-popover {
  position: absolute;
  top: 46px;
  right: 0;
  width: 310px;
  padding: 18px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.settings-popover label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 750;
}

.settings-popover small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.settings-popover code {
  color: var(--navy);
  background: #edf1f4;
  padding: 1px 4px;
  border-radius: 4px;
}

.secret-input {
  display: flex;
}

.secret-input input {
  min-width: 0;
  flex: 1;
  border-radius: 8px 0 0 8px;
}

.secret-input button {
  padding: 0 12px;
  color: var(--navy);
  background: #eef2f5;
  border: 1px solid var(--line-strong);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  font-size: 12px;
  font-weight: 700;
}

main {
  width: min(1320px, calc(100% - 48px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  align-items: end;
  gap: 36px;
  padding: 52px 8px 38px;
}

.eyebrow,
.section-kicker {
  display: block;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 780px;
  margin: 8px 0 12px;
  color: var(--navy-deep);
  font-size: clamp(30px, 4vw, 49px);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.hero p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.hero-stat {
  position: relative;
  display: grid;
  gap: 3px;
  padding: 18px 18px 18px 21px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
}

.hero-stat::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  content: "";
  background: var(--gold);
  border-radius: 10px 0 0 10px;
}

.hero-stat span,
.hero-stat small {
  color: var(--muted);
  font-size: 11px;
}

.hero-stat strong {
  color: var(--navy);
  font-size: 16px;
}

.progress-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.progress-step {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 52px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.progress-step:not(:last-child)::after {
  position: absolute;
  top: 13px;
  right: 0;
  width: 1px;
  height: 26px;
  content: "";
  background: var(--line);
}

.progress-step span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-size: 11px;
}

.progress-step:hover,
.progress-step.active {
  color: var(--navy);
  background: #fbfcfd;
}

.progress-step.active span {
  color: white;
  background: var(--green);
  border-color: var(--green);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  align-items: start;
  gap: 22px;
}

.main-column {
  display: grid;
  gap: 22px;
}

.panel {
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  scroll-margin-top: 92px;
}

.panel-heading,
.heading-group {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.panel-heading {
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid #e9edf1;
}

.panel-heading-split {
  align-items: center;
  justify-content: space-between;
}

.panel-heading h2,
.sticky-panel h2 {
  margin: 3px 0 4px;
  color: var(--navy-deep);
  font-size: 21px;
  letter-spacing: -0.015em;
}

.panel-heading p,
.side-intro {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.step-icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 10px;
}

.step-icon svg,
.button svg,
.empty-icon svg,
.generate-button svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
}

.field {
  min-width: 0;
}

.field label,
.output-choice legend {
  display: block;
  margin-bottom: 7px;
  color: #354056;
  font-size: 12px;
  font-weight: 750;
}

.field label b {
  color: var(--red);
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.taxpayer-status {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.taxpayer-status.success {
  color: #15543f;
  background: var(--green-soft);
  border-color: #bddaca;
}

.taxpayer-status.warning {
  color: #7a5510;
  background: var(--gold-soft);
  border-color: #efd690;
}

.taxpayer-status.error {
  color: #7e3030;
  background: var(--red-soft);
  border-color: #f1caca;
}

input,
select,
textarea {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input,
select {
  height: 43px;
  padding: 0 12px;
}

textarea {
  min-height: 70px;
  padding: 10px 12px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #a0a8b4;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #5a8d79;
  box-shadow: 0 0 0 3px rgba(23, 117, 87, 0.1);
}

input:user-invalid,
textarea:user-invalid,
select:user-invalid {
  border-color: #d58484;
}

.input-action {
  display: flex;
  gap: 9px;
}

.input-action input {
  min-width: 0;
  flex: 1;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 43px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 760;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.button.primary {
  color: white;
  background: var(--green);
  box-shadow: 0 4px 12px rgba(23, 117, 87, 0.2);
}

.button.primary:hover {
  background: #126548;
}

.button.secondary {
  color: var(--navy);
  background: #f3f6f8;
  border-color: var(--line);
}

.button.small {
  min-height: 37px;
  padding: 0 13px;
  white-space: nowrap;
  font-size: 12px;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  min-height: 130px;
  margin-top: 20px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px dashed #cbd3dc;
  border-radius: 10px;
}

.empty-state strong {
  display: block;
  margin-bottom: 3px;
  color: #3c4759;
  font-size: 13px;
}

.empty-state p {
  margin: 0;
  font-size: 12px;
}

.empty-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #7c8797;
  background: #edf1f4;
  border-radius: 9px;
}

.technical-result {
  margin-top: 20px;
  border: 1px solid #cfe4da;
  border-radius: 11px;
  overflow: hidden;
}

.result-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 15px 17px;
  background: var(--green-soft);
  border-bottom: 1px solid #cfe4da;
}

.result-banner > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.result-banner strong,
.result-banner small {
  display: block;
}

.result-banner strong {
  color: #15543f;
  font-size: 13px;
}

.result-banner small {
  margin-top: 2px;
  color: #5d7a6e;
  font-size: 11px;
}

.success-check {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: white;
  background: var(--green);
  border-radius: 50%;
  font-size: 14px;
  font-weight: 800;
}

.success-check.large {
  width: 38px;
  height: 38px;
  margin: 0 auto 8px;
  font-size: 20px;
}

.verified-badge {
  padding: 5px 8px;
  color: #15543f;
  background: white;
  border: 1px solid #bddaca;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.spec-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  padding: 4px 17px 17px;
}

.spec-grid div {
  min-width: 0;
  padding: 16px 12px 10px 0;
  border-bottom: 1px solid #edf0f2;
}

.spec-grid dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.spec-grid dd {
  margin: 0;
  color: var(--navy-deep);
  font-size: 14px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.missing-warning,
.error-message {
  padding: 11px 13px;
  color: #7e3030;
  background: var(--red-soft);
  border: 1px solid #f1caca;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.missing-warning {
  margin: 0 17px 17px;
}

.form-grid {
  display: grid;
  gap: 17px;
}

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

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

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

.items-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.items-table th {
  padding: 10px 11px;
  color: #667184;
  background: #f5f7f9;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
}

.items-table td {
  padding: 9px 7px;
  border-bottom: 1px solid #edf0f3;
}

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

.items-table input {
  height: 38px;
  border-color: transparent;
  background: #f9fafb;
}

.items-table input:focus {
  background: white;
  border-color: #5a8d79;
}

.adaptation-field {
  margin: 18px 0 22px;
  padding: 16px 18px;
  background: #f7faf9;
  border: 1px solid #d6e3de;
  border-radius: 10px;
}

.adaptation-field textarea {
  min-height: 86px;
}

.optional-label {
  margin-left: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.number-column {
  width: 100px;
}

.money-column {
  width: 150px;
}

.line-total {
  display: block;
  padding-right: 5px;
  color: var(--navy-deep);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.fixed-quantity {
  width: 100%;
  min-height: 38px;
  display: grid;
  place-items: center;
  color: var(--navy-deep);
  background: #f1f4f6;
  border-radius: 7px;
  font-weight: 800;
}

input[readonly] {
  color: #4d596b;
  background: #f1f4f6;
  cursor: default;
}

.user-session {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
}

.user-session span,
.user-session small,
.user-session strong {
  display: block;
}

.user-session small {
  color: #9fb0c0;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.user-session strong {
  max-width: 210px;
  color: white;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-session button {
  padding: 7px 10px;
  color: white;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 7px;
  font-weight: 700;
}

.user-session button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 80% 10%, rgba(239, 180, 61, 0.16), transparent 30%),
    linear-gradient(135deg, #eef3f5, #f9faf8);
}

.login-card {
  width: min(100%, 430px);
  padding: 38px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 20px 55px rgba(16, 38, 60, 0.14);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-bottom: 26px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.login-brand strong,
.login-brand small {
  display: block;
}

.login-brand strong {
  color: var(--navy-deep);
  font-size: 18px;
}

.login-brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.login-card h1 {
  margin: 6px 0 8px;
  color: var(--navy-deep);
  font-size: 30px;
}

.login-card > p {
  margin: 0 0 24px;
  color: var(--muted);
}

.login-card form {
  display: grid;
  gap: 17px;
}

.login-button {
  width: 100%;
  min-height: 48px;
  margin-top: 3px;
}

.remove-item {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: #8a94a2;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 17px;
}

.remove-item:hover {
  color: var(--red);
  background: var(--red-soft);
}

.commercial-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 255px;
  align-items: start;
  gap: 24px;
  margin-top: 24px;
}

.totals-card {
  padding: 18px;
  background: var(--navy-deep);
  color: white;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(16, 38, 60, 0.16);
}

.totals-title {
  display: block;
  padding-bottom: 10px;
  margin-bottom: 8px;
  color: #afbfce;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.totals-card > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  color: #c4d0dc;
  font-size: 12px;
}

.totals-card > div strong {
  color: white;
}

.totals-card .discount-line strong {
  color: #76dfae;
}

.totals-card .grand-total {
  align-items: flex-end;
  padding-top: 13px;
  margin-top: 7px;
  color: white;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 14px;
}

.totals-card .grand-total strong {
  color: #ffd46e;
  font-size: 20px;
}

.totals-card small {
  display: block;
  margin-top: 11px;
  color: #91a4b5;
  font-size: 10px;
  line-height: 1.45;
}

.sticky-panel {
  position: sticky;
  top: 96px;
}

.side-intro {
  margin-bottom: 20px;
}

.readiness-list {
  display: grid;
  margin-bottom: 22px;
  border-top: 1px solid #e9edf1;
}

.readiness-list > div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid #e9edf1;
}

.readiness-list > div > span {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #8791a0;
  background: #edf1f4;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
}

.readiness-list p,
.readiness-list strong,
.readiness-list small {
  display: block;
  margin: 0;
}

.readiness-list strong {
  color: #3a4557;
  font-size: 12px;
}

.readiness-list small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
}

.readiness-list > div.complete > span {
  color: white;
  background: var(--green);
}

.readiness-list > div.complete > span {
  font-size: 0;
}

.readiness-list > div.complete > span::after {
  content: "✓";
  font-size: 12px;
}

.output-choice {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0 0 18px;
  border: 0;
}

.format-card {
  display: grid;
  grid-template-columns: auto 36px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.format-card:hover,
.format-card.selected {
  background: #f6fbf8;
  border-color: #80af9c;
}

.format-card input {
  width: 15px;
  height: 15px;
  accent-color: var(--green);
}

.format-card > span:last-child strong,
.format-card > span:last-child small {
  display: block;
}

.format-card > span:last-child strong {
  color: #354056;
  font-size: 12px;
}

.format-card > span:last-child small {
  color: var(--muted);
  font-size: 10px;
}

.file-icon {
  width: 32px;
  height: 36px;
  display: grid;
  place-items: center;
  color: white;
  border-radius: 4px 4px 6px 4px;
  font-size: 11px;
  font-weight: 900;
}

.file-icon.docx {
  background: #2867b2;
}

.file-icon.pdf {
  background: #c54a4a;
}

.file-icon.both {
  background: #6957a7;
}

.approval-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px;
  margin-bottom: 14px;
  color: #485367;
  background: var(--gold-soft);
  border: 1px solid #f0d797;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.5;
}

.approval-check input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-top: 1px;
  accent-color: var(--green);
}

.generate-button {
  width: 100%;
  min-height: 49px;
  color: var(--navy-deep);
  background: var(--gold);
  border-color: #dfa223;
  box-shadow: 0 5px 14px rgba(239, 180, 61, 0.22);
}

.generate-button:hover:not(:disabled) {
  background: #f4bf52;
  box-shadow: 0 7px 18px rgba(239, 180, 61, 0.3);
}

.generate-button.loading {
  cursor: wait;
}

.generate-button.loading svg {
  animation: pulse-arrow 0.8s ease-in-out infinite alternate;
}

@keyframes pulse-arrow {
  to {
    transform: translateX(5px);
  }
}

.generation-result {
  padding: 17px 12px 4px;
  text-align: center;
}

.generation-result > strong {
  color: #15543f;
  font-size: 14px;
}

.generation-result p {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 11px;
}

.artifact-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  margin-top: 7px;
  color: white;
  background: var(--green);
  border-radius: 7px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 750;
}

.artifact-link:hover {
  background: #126548;
}

.error-message {
  margin-top: 13px;
}

footer {
  width: min(1320px, calc(100% - 48px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 30px auto 0;
  padding: 25px 6px 36px;
  color: #7a8493;
  border-top: 1px solid #dfe4e9;
  font-size: 11px;
}

footer a {
  color: var(--green);
  font-weight: 700;
  text-decoration: none;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: 360px;
  padding: 12px 15px;
  color: white;
  background: var(--navy-deep);
  border-radius: 9px;
  box-shadow: var(--shadow);
  font-size: 12px;
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

@media (max-width: 1080px),
  (max-device-width: 900px) and (hover: none) and (pointer: coarse) {
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr) 300px;
  }

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

  .totals-card {
    width: min(100%, 330px);
    justify-self: end;
  }

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

@media (max-width: 880px),
  (max-device-width: 900px) and (hover: none) and (pointer: coarse) {
  main,
  footer {
    width: min(100% - 30px, 760px);
  }

  .topbar {
    padding-inline: 16px;
  }

  .hero {
    grid-template-columns: 1fr;
    padding-top: 36px;
  }

  .hero-stat {
    max-width: 300px;
  }

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

  .sticky-panel {
    position: static;
  }

  .readiness-list {
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid #e9edf1;
  }

  .readiness-list > div {
    border-bottom: 0;
  }

  .output-choice {
    grid-template-columns: repeat(3, 1fr);
  }

  .format-card {
    grid-template-columns: auto 1fr;
  }

  .format-card input {
    grid-row: 1 / 3;
  }

  .format-card .file-icon {
    display: none;
  }
}

@media (max-width: 650px),
  (max-device-width: 900px) and (hover: none) and (pointer: coarse) {
  .login-page {
    min-height: 100dvh;
    padding: 12px;
  }

  .login-card {
    padding: 24px 20px;
  }

  .login-card h1 {
    font-size: 26px;
  }

  main,
  footer {
    width: calc(100% - 24px);
  }

  .topbar {
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-copy strong {
    font-size: 14px;
  }

  .brand-copy small {
    font-size: 9px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .topbar-actions > a {
    font-size: 12px;
  }

  .user-session {
    gap: 8px;
    margin-left: auto;
    padding-left: 8px;
  }

  .user-session strong {
    max-width: 130px;
  }

  .user-session button {
    min-height: 44px;
  }

  .server-status span:last-child {
    display: none;
  }

  .hero {
    gap: 12px;
    padding: 22px 2px 20px;
  }

  .hero h1 {
    font-size: 27px;
  }

  .hero p {
    font-size: 14px;
    line-height: 1.45;
  }

  .hero-stat {
    max-width: none;
    padding: 10px 12px 10px 16px;
  }

  .hero-stat small {
    display: none;
  }

  .progress-nav {
    margin-bottom: 12px;
  }

  .progress-step {
    flex-direction: column;
    gap: 3px;
    min-height: 58px;
    font-size: 11px;
  }

  .progress-step span {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }

  .panel {
    padding: 20px 16px;
    scroll-margin-top: 120px;
  }

  .panel-heading-split {
    align-items: flex-start;
    flex-direction: column;
  }

  .search-grid,
  .two-columns {
    grid-template-columns: 1fr;
  }

  .input-action {
    flex-direction: column;
  }

  .input-action .button {
    width: 100%;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  .button {
    min-height: 48px;
  }

  .side-column {
    scroll-margin-top: 120px;
  }

  .items-table-wrap {
    overflow: visible;
    border: 0;
  }

  .items-table,
  .items-table tbody,
  .items-table tr,
  .items-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .items-table thead {
    display: none;
  }

  .items-table tr {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
  }

  .items-table td {
    padding: 5px 0;
    border: 0;
  }

  .items-table td::before {
    display: block;
    margin-bottom: 5px;
    color: #667184;
    content: attr(data-label);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .items-table input {
    height: 48px;
    padding-inline: 12px;
    border: 1px solid var(--line-strong);
    background: white;
  }

  .items-table td:last-child {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
    padding-top: 11px;
    border-top: 1px solid var(--line);
  }

  .items-table td:last-child::before {
    margin: 0;
  }

  .line-total {
    padding: 0;
    font-size: 15px;
  }

  .adaptation-field {
    padding: 14px;
  }

  .totals-card {
    width: 100%;
    max-width: none;
  }

  .full-width {
    grid-column: auto;
  }

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

  .result-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .readiness-list,
  .output-choice {
    grid-template-columns: 1fr;
  }

  .readiness-list {
    border-bottom: 0;
  }

  .readiness-list > div {
    border-bottom: 1px solid #e9edf1;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
    max-width: none;
  }
}

@media (max-width: 380px) {
  .topbar-actions {
    flex-wrap: wrap;
  }

  .progress-step {
    font-size: 10px;
  }

  .panel {
    padding: 18px 12px;
  }
}

/* Mobile-first finishing layer: readable without zoom and safe on narrow phones. */
@media (max-width: 700px),
  (max-device-width: 900px) and (hover: none) and (pointer: coarse) {
  body {
    font-size: 16px;
  }

  .login-page {
    grid-template-columns: minmax(0, 1fr);
  }

  .login-card {
    width: 100%;
    min-width: 0;
    max-width: 430px;
  }

  main,
  footer,
  .app-shell,
  .workspace-grid,
  .main-column,
  .side-column,
  .panel,
  .field,
  .model-field,
  .commercial-grid,
  .terms-fields {
    min-width: 0;
    max-width: 100%;
  }

  main,
  footer {
    width: calc(100% - 16px);
  }

  .topbar {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: max(10px, env(safe-area-inset-top)) 10px 10px;
  }

  .brand,
  .brand-copy,
  .topbar-actions,
  .user-session {
    min-width: 0;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    width: 100%;
  }

  .topbar-actions > a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0 4px;
  }

  .server-status {
    display: none;
  }

  .user-session {
    justify-content: space-between;
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
  }

  .user-session strong {
    max-width: min(42vw, 180px);
  }

  .hero {
    padding: 20px 4px 16px;
  }

  .hero h1 {
    margin-top: 6px;
    font-size: clamp(25px, 8vw, 32px);
    line-height: 1.12;
  }

  .hero p {
    font-size: 15px;
    line-height: 1.55;
  }

  .progress-nav {
    position: sticky;
    top: 0;
    z-index: 25;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-inline: -1px;
    box-shadow: 0 6px 18px rgba(23, 32, 51, 0.1);
  }

  .progress-step {
    min-width: 0;
    min-height: 62px;
    padding: 5px 2px;
    font-size: 12px;
  }

  .panel {
    padding: 20px 14px;
    border-radius: 12px;
    scroll-margin-top: 72px;
  }

  .panel-heading {
    gap: 12px;
    padding-bottom: 18px;
    margin-bottom: 18px;
  }

  .panel-heading h2,
  .sticky-panel h2 {
    font-size: 22px;
  }

  .panel-heading p,
  .side-intro {
    font-size: 14px;
    line-height: 1.55;
  }

  .step-icon {
    width: 44px;
    height: 44px;
  }

  .form-grid,
  .search-grid,
  .commercial-grid {
    gap: 16px;
  }

  .field label,
  .output-choice legend {
    margin-bottom: 8px;
    font-size: 14px;
  }

  .field-hint,
  .terms-fields small,
  .taxpayer-status {
    font-size: 12px;
    line-height: 1.5;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    min-width: 0;
    min-height: 52px;
    padding-inline: 13px;
    font-size: 16px;
  }

  textarea {
    min-height: 104px;
    padding-block: 12px;
  }

  .button,
  .button.small {
    min-height: 52px;
    padding-inline: 16px;
    font-size: 15px;
  }

  .input-action {
    width: 100%;
  }

  .empty-state {
    justify-content: flex-start;
    min-height: 0;
    padding: 18px 14px;
  }

  .empty-state strong,
  .result-banner strong {
    font-size: 15px;
  }

  .empty-state p,
  .result-banner small {
    font-size: 13px;
    line-height: 1.45;
  }

  .result-banner,
  .spec-grid,
  .missing-warning {
    padding-inline: 14px;
  }

  .spec-grid dt {
    font-size: 11px;
  }

  .spec-grid dd {
    font-size: 16px;
    line-height: 1.4;
  }

  .missing-warning,
  .error-message {
    font-size: 14px;
  }

  .items-table tbody {
    display: grid;
    gap: 12px;
  }

  .items-table tr {
    padding: 14px;
    background: #fff;
    box-shadow: var(--shadow-soft);
  }

  .items-table td::before {
    font-size: 12px;
  }

  .items-table input {
    height: 52px;
  }

  .adaptation-field {
    margin: 16px 0;
  }

  .totals-card {
    padding: 20px 16px;
  }

  .totals-title,
  .totals-card small {
    font-size: 12px;
  }

  .totals-card > div {
    padding: 9px 0;
    font-size: 14px;
  }

  .totals-card .grand-total strong {
    font-size: 23px;
  }

  .readiness-list strong,
  .format-card > span:last-child strong {
    font-size: 14px;
  }

  .readiness-list small,
  .format-card > span:last-child small {
    font-size: 12px;
  }

  .format-card {
    min-height: 60px;
    padding: 10px 12px;
  }

  .format-card input,
  .approval-check input {
    width: 20px;
    height: 20px;
  }

  .approval-check {
    padding: 14px;
    font-size: 14px;
  }

  .generate-button {
    min-height: 58px;
    font-size: 16px;
  }

  .artifact-link {
    min-height: 48px;
    font-size: 14px;
  }

  footer {
    padding-bottom: max(28px, env(safe-area-inset-bottom));
    font-size: 12px;
  }
}
