:root {
  --ink: #17212b;
  --muted: #5d6974;
  --paper: #f4f2ed;
  --surface: #ffffff;
  --surface-soft: #eef2ef;
  --line: #d8ddd9;
  --brand: #193f38;
  --brand-strong: #0f302a;
  --accent: #d8a23d;
  --accent-soft: #f6e7c4;
  --danger: #9f2f2f;
  --success: #216344;
  --shadow: 0 18px 45px rgba(25, 40, 35, 0.09);
  --radius: 18px;
  --radius-small: 11px;
  --content: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(216, 162, 61, 0.12), transparent 26rem),
    var(--paper);
}

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

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid rgba(216, 162, 61, 0.75);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.7rem 1rem;
  color: #fff;
  background: var(--brand-strong);
  border-radius: 8px;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.header-inner {
  width: min(calc(100% - 2rem), var(--content));
  min-height: 74px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--brand);
  border-radius: 12px;
  font-weight: 850;
  letter-spacing: -0.04em;
}

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

.brand strong {
  line-height: 1.1;
}

.brand small {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.primary-nav > a {
  min-height: 44px;
  padding: 0.65rem 0.85rem;
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.primary-nav > a:hover {
  background: var(--surface-soft);
}

.primary-nav form {
  margin: 0;
}

.user-summary {
  margin-left: 0.4rem;
  padding-left: 0.95rem;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.nav-toggle {
  margin-left: auto;
  min-height: 44px;
  padding: 0.55rem 0.85rem;
  display: none;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 750;
}

.environment-strip {
  padding: 0.28rem 1rem;
  color: #432f08;
  background: var(--accent-soft);
  border-top: 1px solid #ead198;
  text-align: center;
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-shell {
  width: min(calc(100% - 2rem), var(--content));
  min-height: calc(100vh - 150px);
  margin: 0 auto;
  padding: 3rem 0 4rem;
}

.page-heading {
  margin-bottom: 2rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
}

.page-heading h1,
.auth-brand h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.page-heading p:not(.eyebrow) {
  max-width: 720px;
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.compact-heading {
  align-items: center;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.button {
  min-height: 44px;
  padding: 0.72rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  transition: transform 120ms ease, background 120ms ease;
}

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

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

.button-primary {
  color: #fff;
  background: var(--brand);
  box-shadow: 0 8px 20px rgba(25, 63, 56, 0.17);
}

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

.button-secondary {
  color: var(--brand);
  background: var(--surface);
  border-color: var(--brand);
}

.button-quiet {
  min-height: 38px;
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.button-wide {
  width: 100%;
}

.state-badge,
.environment-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0.35rem 0.75rem;
  color: #4f3503;
  background: var(--accent-soft);
  border: 1px solid #ead198;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.foundation-grid {
  margin-bottom: 1.5rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.status-card {
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.status-card h2,
.workspace-card h2,
.decision-preview h2,
.empty-state h2 {
  margin: 0;
  font-size: 1.12rem;
}

.status-card p,
.workspace-card p,
.decision-preview p,
.empty-state p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.status-icon,
.section-number {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: var(--surface-soft);
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 900;
}

.status-ready .status-icon {
  color: #fff;
  background: var(--success);
}

.empty-state {
  padding: clamp(2rem, 7vw, 5rem);
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed #bdc7c0;
  border-radius: var(--radius);
  text-align: center;
}

.empty-symbol {
  width: 58px;
  height: 58px;
  margin: 0 auto 1rem;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: var(--accent-soft);
  border-radius: 18px;
  font-family: Georgia, serif;
  font-size: 1.8rem;
}

.empty-state .button {
  margin-top: 1.35rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.75fr);
  gap: 1.25rem;
  align-items: start;
}

.workspace-main {
  display: grid;
  gap: 1rem;
}

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

.workspace-card {
  min-height: 128px;
  display: flex;
  gap: 1rem;
}

.decision-preview {
  position: sticky;
  top: 1.25rem;
}

.decision-preview dl {
  margin: 1.5rem 0;
}

.decision-preview dl > div {
  padding: 0.75rem 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.decision-preview dt {
  color: var(--muted);
}

.decision-preview dd {
  margin: 0;
  font-weight: 900;
}

.flash {
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
}

.flash-error {
  color: #6e2020;
  background: #fff0f0;
  border-color: #e7bcbc;
}

.flash-success {
  color: #174d35;
  background: #edf8f1;
  border-color: #b9ddc7;
}

.flash-info {
  color: #334d5d;
  background: #eef6fa;
  border-color: #c4dbe7;
}

.site-footer {
  width: min(calc(100% - 2rem), var(--content));
  margin: 0 auto;
  padding: 1.5rem 0 2.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.auth-body {
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    linear-gradient(120deg, rgba(15, 48, 42, 0.96), rgba(25, 63, 56, 0.88)),
    var(--brand);
}

.auth-shell {
  width: min(100%, 980px);
  min-height: 590px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  overflow: hidden;
  background: var(--surface);
  border-radius: 26px;
  box-shadow: 0 30px 80px rgba(4, 17, 14, 0.3);
}

.auth-brand,
.auth-panel {
  padding: clamp(2rem, 6vw, 4.5rem);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #fff;
  background:
    linear-gradient(160deg, rgba(15, 48, 42, 0.94), rgba(25, 63, 56, 0.98)),
    var(--brand);
}

.auth-brand .eyebrow {
  color: #f2dca8;
}

.auth-brand p:not(.eyebrow) {
  max-width: 32rem;
  margin: 1.25rem 0 1.75rem;
  color: rgba(255, 255, 255, 0.76);
  font-size: 1.08rem;
}

.auth-brand .environment-badge {
  width: fit-content;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.panel-heading h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 2.25rem;
  letter-spacing: -0.035em;
}

.panel-heading > p:last-child {
  margin: 0.4rem 0 1.5rem;
  color: var(--muted);
}

.stack-form {
  display: grid;
  gap: 1rem;
}

.stack-form label {
  display: grid;
  gap: 0.4rem;
  font-weight: 750;
}

.stack-form input {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.8rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #bfc8c2;
  border-radius: 10px;
}

.stack-form input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(25, 63, 56, 0.1);
  outline: none;
}

@media (max-width: 820px) {
  .header-inner {
    flex-wrap: wrap;
    padding: 0.75rem 0;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .primary-nav {
    width: 100%;
    margin-left: 0;
    padding-top: 0.65rem;
    display: none;
    align-items: stretch;
    flex-direction: column;
    border-top: 1px solid var(--line);
  }

  .primary-nav.is-open {
    display: flex;
  }

  .primary-nav > a,
  .primary-nav form,
  .primary-nav .button {
    width: 100%;
  }

  .user-summary {
    margin: 0.5rem 0 0;
    padding: 0.75rem 0.85rem 0.2rem;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

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

  .decision-preview {
    position: static;
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    min-height: 260px;
  }
}

@media (max-width: 600px) {
  .page-shell {
    width: min(calc(100% - 1.25rem), var(--content));
    padding-top: 2rem;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 1rem;
  }

  .page-heading .button {
    width: 100%;
  }

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

  .workspace-card {
    min-height: 0;
  }

  .site-footer {
    flex-direction: column;
  }

  .auth-body {
    display: block;
    padding: 0;
    background: var(--surface);
  }

  .auth-shell {
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-brand {
    min-height: 230px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

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

.manual-badge {
  color: #65470d;
  background: var(--accent-soft);
}

.quote-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1.5rem;
  align-items: start;
}

.quote-form-column,
.stops-list,
.legs-list {
  display: grid;
  gap: 1rem;
}

.form-section,
.decision-panel {
  padding: 1.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-section-heading {
  margin-bottom: 1.25rem;
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
}

.form-section-heading > span {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--brand);
  border-radius: 10px;
  font-weight: 850;
}

.form-section h2,
.decision-panel h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 1.55rem;
  letter-spacing: -0.025em;
}

.form-section-heading p,
.decision-panel > p:not(.eyebrow),
.commitment-box p {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 1rem;
}

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

.form-grid label,
.stop-row label,
.leg-row label,
.commitment-box label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.form-grid input,
.form-grid select,
.stop-row input,
.stop-row select,
.leg-row input,
.leg-row select,
.commitment-box input {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 0.72rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #bcc7c1;
  border-radius: 9px;
}

.checkbox-field {
  min-height: 46px;
  padding-top: 1.45rem;
  display: flex !important;
  align-items: center;
  gap: 0.55rem !important;
}

.checkbox-field input {
  width: 20px;
  min-height: 20px;
}

.stop-row {
  display: grid;
  grid-template-columns: 34px 180px minmax(0, 1fr) 42px;
  gap: 0.65rem;
  align-items: center;
}

.stop-index {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: var(--surface-soft);
  border-radius: 50%;
  font-weight: 850;
}

.icon-button {
  width: 40px;
  height: 40px;
  color: var(--danger);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  font-size: 1.4rem;
}

.leg-row {
  padding: 0.85rem;
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) repeat(3, minmax(105px, 1fr));
  gap: 0.75rem;
  align-items: end;
  background: var(--surface-soft);
  border-radius: 12px;
}

.leg-title strong,
.leg-title span {
  display: block;
}

.leg-title span {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.commitment-box {
  margin-top: 1rem;
  padding: 1rem;
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) 1fr;
  gap: 1rem;
  align-items: end;
  background: var(--accent-soft);
  border-radius: 12px;
}

.decision-panel {
  position: sticky;
  top: 1rem;
}

.result-list {
  margin: 1.25rem 0;
}

.result-list div {
  padding: 0.65rem 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.result-list dt {
  color: var(--muted);
}

.result-list dd {
  margin: 0;
  font-weight: 850;
}

.result-emphasis dd {
  color: var(--brand);
}

.commercial-result {
  margin-bottom: 1rem;
  padding: 1rem;
  color: #fff;
  background: var(--brand);
  border-radius: 13px;
}

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

.commercial-result strong {
  margin: 0.15rem 0;
  font-family: Georgia, serif;
  font-size: 2rem;
}

.route-summary {
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.route-summary span {
  padding: 0.35rem 0.55rem;
  background: var(--surface-soft);
  border-radius: 7px;
  font-size: 0.75rem;
  font-weight: 800;
}

.warning-list {
  padding-left: 1.15rem;
  color: #75510d;
  font-size: 0.85rem;
}

.autosave-status {
  margin: 0.7rem 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.76rem;
}

.decision-panel .button + .button {
  margin-top: 0.6rem;
}

.quote-list-card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.quote-list-heading {
  padding: 1rem 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.quote-list-heading h2 {
  margin: 0;
  font-family: Georgia, serif;
}

.quote-list-heading span {
  color: var(--muted);
  font-size: 0.82rem;
}

.table-scroll {
  overflow-x: auto;
}

.quote-table {
  width: 100%;
  border-collapse: collapse;
}

.quote-table th,
.quote-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.quote-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

@media (max-width: 980px) {
  .four-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .decision-panel {
    position: static;
  }
}

@media (max-width: 650px) {
  .four-columns,
  .commitment-box {
    grid-template-columns: 1fr;
  }

  .stop-row {
    grid-template-columns: 30px minmax(0, 1fr) 40px;
  }

  .stop-row label:first-of-type {
    grid-column: 2 / 4;
    grid-row: 1;
  }

  .stop-location {
    grid-column: 2 / 3;
  }

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

  .leg-title {
    grid-column: 1 / -1;
  }
}
