:root {
  --ink: #142b3a;
  --ink-soft: #2d4653;
  --teal: #246b78;
  --teal-dark: #1b5661;
  --teal-pale: #eaf1f2;
  --canvas: #edf1f1;
  --surface: #ffffff;
  --surface-soft: #f6f8f8;
  --line: #ccd7d9;
  --line-strong: #aebfc2;
  --muted: #60727a;
  --green: #316d4b;
  --green-pale: #e6f1e9;
  --amber: #986019;
  --amber-pale: #fff1d8;
  --red: #9e3f39;
  --red-pale: #f8e7e5;
  --focus: #0d73a8;
  --shadow: 0 10px 30px rgb(20 43 58 / 7%);
  --radius: 14px;
  color-scheme: light;
  font-family: Inter, Aptos, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, #f8fafa 0, var(--canvas) 420px),
    var(--canvas);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

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

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 55%, transparent);
  outline-offset: 2px;
}

.shell {
  width: min(100%, 1500px);
  margin-inline: auto;
  padding-inline: clamp(12px, 2.3vw, 34px);
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  border-bottom: 1px solid rgb(174 191 194 / 72%);
  background: rgb(248 250 250 / 94%);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  display: flex;
  width: min(100%, 1500px);
  min-height: 70px;
  margin-inline: auto;
  padding-inline: clamp(12px, 2.3vw, 34px);
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

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

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 10px;
  background: var(--ink);
  color: white;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand div {
  display: grid;
  line-height: 1.15;
}

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

nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

nav a {
  min-height: 44px;
  padding: 11px 15px;
  border-radius: 9px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

nav a:hover,
nav a.active {
  background: var(--teal-pale);
  color: var(--teal-dark);
}

nav a.nav-primary {
  margin-left: 4px;
  background: var(--ink);
  color: white;
}

nav a.nav-primary:hover,
nav a.nav-primary.active {
  background: var(--teal-dark);
  color: white;
}

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

h1 {
  max-width: 900px;
  margin-bottom: 18px;
  font-size: clamp(2rem, 4.2vw, 4rem);
  line-height: 1.03;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  line-height: 1.18;
  letter-spacing: -0.025em;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.hero {
  display: grid;
  min-height: 560px;
  padding-block: clamp(48px, 7vw, 96px);
  align-items: center;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: clamp(36px, 7vw, 110px);
}

.hero-copy > p {
  max-width: 730px;
  margin-bottom: 27px;
  color: var(--ink-soft);
  font-size: clamp(1.05rem, 1.5vw, 1.3rem);
}

.hero-actions,
.export-actions,
.detail-actions,
.confirm-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.machine-panel {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 3vw, 38px);
  border: 1px solid #294552;
  border-radius: 18px;
  background: var(--ink);
  box-shadow: 0 28px 70px rgb(20 43 58 / 22%);
  color: white;
}

.machine-panel::after {
  position: absolute;
  right: -54px;
  bottom: -54px;
  width: 190px;
  height: 190px;
  border: 34px solid rgb(255 255 255 / 4%);
  border-radius: 50%;
  content: "";
}

.machine-head,
.machine-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.machine-code {
  color: #b9d6db;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.machine-model {
  margin: 44px 0 3px;
  font-size: clamp(2.8rem, 5vw, 4.8rem);
  font-weight: 750;
  letter-spacing: -0.05em;
  line-height: 1;
}

.machine-target {
  color: #b9c8ce;
}

.machine-counts {
  display: grid;
  margin: 35px 0;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border: 1px solid rgb(255 255 255 / 13%);
  border-radius: 12px;
  background: rgb(255 255 255 / 13%);
}

.machine-counts > div {
  display: grid;
  padding: 16px;
  background: #183543;
  gap: 3px;
}

.machine-counts > div:first-child {
  border-radius: 11px 0 0 11px;
}

.machine-counts > div:last-child {
  border-radius: 0 11px 11px 0;
}

.machine-counts strong {
  font-size: 1.5rem;
}

.machine-counts span,
.machine-result > span {
  color: #b9c8ce;
  font-size: 12px;
}

.section-block {
  padding-block: clamp(30px, 4.5vw, 62px);
}

.section-heading,
.list-toolbar,
.detail-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

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

.section-heading h2 {
  margin-bottom: 0;
}

.eyebrow,
.panel-code,
.step-label {
  margin-bottom: 9px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.text-link,
.row-link,
.clear-link {
  color: var(--teal-dark);
  font-weight: 750;
  text-underline-offset: 4px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.metric {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 4px 18px rgb(20 43 58 / 4%);
}

.metric-label,
.metric-detail {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.metric-label {
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-value {
  overflow: hidden;
  margin: 7px 0 3px;
  font-size: clamp(1.45rem, 2.4vw, 2.2rem);
  font-weight: 780;
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
}

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

.ui-card-header {
  display: flex;
  min-height: 84px;
  padding: 22px 24px 16px;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #e1e8e9;
}

.ui-card-title {
  margin-bottom: 0;
}

.ui-card-content {
  padding: 24px;
}

.ui-button {
  display: inline-flex;
  min-height: 46px;
  padding: 11px 18px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

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

.ui-button-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.ui-button-primary:hover {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.ui-button-secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.ui-button-secondary:hover {
  border-color: var(--teal);
  background: var(--teal-pale);
}

.ui-button-quiet {
  background: transparent;
  color: var(--ink-soft);
}

.ui-button-danger {
  background: var(--red);
  color: white;
}

.ui-badge {
  display: inline-flex;
  width: fit-content;
  min-height: 27px;
  padding: 4px 9px;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.035em;
  white-space: nowrap;
}

.ui-badge-success {
  border-color: #a7c8b2;
  background: var(--green-pale);
  color: var(--green);
}

.ui-badge-warning {
  border-color: #e1bf84;
  background: var(--amber-pale);
  color: var(--amber);
}

.ui-badge-danger {
  border-color: #ddb1ad;
  background: var(--red-pale);
  color: var(--red);
}

.table-frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 6px 22px rgb(20 43 58 / 5%);
}

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

.report-table th,
.report-table td {
  padding: 15px 14px;
  border-bottom: 1px solid #e4eaeb;
  text-align: left;
  white-space: nowrap;
}

.report-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.report-table td {
  color: var(--ink-soft);
  font-size: 14px;
}

.report-table tbody tr:hover {
  background: #f8fbfb;
}

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

.page-heading {
  padding: clamp(28px, 5vw, 58px) 0 26px;
}

.page-heading h1 {
  margin-bottom: 12px;
  font-size: clamp(2.2rem, 4vw, 3.8rem);
}

.page-heading > p:last-child {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.08rem;
}

.error-heading {
  padding-bottom: 10px;
}

.filter-bar {
  display: grid;
  margin-bottom: 18px;
  padding: 16px;
  align-items: end;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 210px) minmax(150px, 210px) auto auto;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.filter-field,
.field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.filter-field label,
.field label {
  display: flex;
  min-height: 20px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 750;
}

.required-word {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ui-input,
.ui-select,
.ui-textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgb(20 43 58 / 3%);
}

.ui-input,
.ui-select {
  min-height: 50px;
  padding: 10px 12px;
}

.ui-textarea {
  min-height: 112px;
  padding: 12px;
  line-height: 1.45;
  resize: vertical;
}

.ui-input:hover,
.ui-select:hover,
.ui-textarea:hover {
  border-color: #829ba0;
}

.ui-input:focus,
.ui-select:focus,
.ui-textarea:focus {
  border-color: var(--focus);
  outline: 3px solid rgb(13 115 168 / 16%);
}

[aria-invalid="true"] {
  border-color: var(--red);
  background: #fffafa;
}

.field-error,
.field-hint {
  margin: 0;
  font-size: 12px;
}

.field-error {
  color: var(--red);
  font-weight: 650;
}

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

.filter-button {
  min-width: 104px;
}

.clear-link {
  display: grid;
  min-height: 46px;
  padding: 10px;
  place-items: center;
}

.list-toolbar {
  margin: 20px 0 12px;
  align-items: center;
}

.list-toolbar > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.form-main {
  display: grid;
  gap: 16px;
}

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

.span-2 {
  grid-column: 1 / -1;
}

.live-summary {
  position: sticky;
  top: 88px;
  overflow: hidden;
  padding: 24px;
  border: 1px solid #294552;
  border-radius: var(--radius);
  background: var(--ink);
  box-shadow: 0 20px 45px rgb(20 43 58 / 16%);
  color: white;
}

.live-summary .panel-code {
  color: #9cc4ca;
}

.live-summary h2 {
  margin-bottom: 22px;
}

.live-numbers {
  display: grid;
  gap: 1px;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 10px;
  background: rgb(255 255 255 / 12%);
}

.live-numbers > div {
  display: flex;
  min-height: 54px;
  padding: 13px 15px;
  align-items: center;
  justify-content: space-between;
  background: #193744;
}

.live-numbers > div:first-child {
  border-radius: 9px 9px 0 0;
}

.live-numbers > div:last-child {
  border-radius: 0 0 9px 9px;
}

.live-numbers span {
  color: #b9c8ce;
  font-size: 13px;
}

.live-numbers strong {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 1.3rem;
}

.calculation-note {
  margin: 18px 0;
  padding: 13px;
  border-left: 3px solid #70aeb8;
  background: rgb(255 255 255 / 6%);
}

.calculation-note p,
.aside-help {
  margin-bottom: 0;
  color: #c2d0d5;
  font-size: 13px;
}

.form-actions {
  justify-content: flex-end;
  padding: 8px 0 24px;
}

.narrow-section {
  width: min(100%, 1120px);
  margin-inline: auto;
}

.review-grid,
.detail-grid {
  display: grid;
  gap: 16px;
}

.review-grid {
  grid-template-columns: 1.2fr 0.8fr;
}

.review-grid .ui-card:first-child,
.detail-grid .ui-card:first-child {
  grid-column: 1 / -1;
}

.review-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.review-metrics .metric {
  box-shadow: none;
}

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

.definition-grid > div {
  display: grid;
  min-width: 0;
  padding: 12px 0;
  border-bottom: 1px solid #e3e9ea;
  grid-template-columns: minmax(90px, 0.45fr) minmax(0, 1fr);
  gap: 14px;
}

.definition-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.definition-grid dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.definition-grid.notes {
  grid-template-columns: 1fr;
}

.confirm-actions,
.detail-actions {
  margin-top: 18px;
  justify-content: flex-end;
}

.detail-heading {
  margin-bottom: 22px;
  align-items: center;
}

.detail-heading h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.detail-heading > div > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

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

.success-banner {
  display: flex;
  margin: 24px 0 4px;
  padding: 14px 16px;
  align-items: center;
  gap: 8px;
  border: 1px solid #a7c8b2;
  border-radius: 10px;
  background: var(--green-pale);
  color: var(--green);
}

.empty-state {
  padding: 50px 24px;
  text-align: center;
}

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

.site-footer {
  padding-block: 35px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 1050px) {
  .hero {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .machine-panel {
    width: min(100%, 650px);
  }

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

  .entry-layout {
    grid-template-columns: 1fr;
  }

  .live-summary {
    position: static;
    grid-row: 1;
  }

  .filter-bar {
    grid-template-columns: 1fr 1fr;
  }

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

  .filter-button,
  .clear-link {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .topbar-inner {
    min-height: 62px;
  }

  .brand small,
  nav a:not(.nav-primary) {
    display: none;
  }

  nav a.nav-primary {
    margin: 0;
  }

  .hero {
    padding-top: 38px;
    gap: 30px;
  }

  h1 {
    font-size: clamp(2.25rem, 11vw, 3.35rem);
  }

  .machine-counts > div {
    padding: 13px 10px;
  }

  .machine-counts strong {
    font-size: 1.2rem;
  }

  .section-heading,
  .list-toolbar,
  .detail-heading {
    align-items: start;
    flex-direction: column;
  }

  .list-toolbar {
    gap: 12px;
  }

  .export-actions,
  .export-actions .ui-button {
    width: 100%;
  }

  .table-frame {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .report-table,
  .report-table tbody {
    display: grid;
    gap: 10px;
  }

  .report-table thead {
    display: none;
  }

  .report-table tr {
    display: grid;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 4px 16px rgb(20 43 58 / 4%);
    grid-template-columns: 1fr 1fr;
    gap: 0 18px;
  }

  .report-table td {
    display: flex;
    min-width: 0;
    padding: 9px 0;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #e4eaeb;
    white-space: normal;
  }

  .report-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .report-table td:first-child,
  .report-table td:last-child {
    grid-column: 1 / -1;
  }

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

  .report-table td:last-child::before {
    content: none;
  }

  .row-link {
    display: grid;
    width: 100%;
    min-height: 44px;
    place-items: center;
    border-radius: 8px;
    background: var(--teal-pale);
  }

  .form-grid,
  .review-grid,
  .detail-grid,
  .definition-grid {
    grid-template-columns: 1fr;
  }

  .review-grid .ui-card:first-child,
  .detail-grid .ui-card:first-child,
  .span-2 {
    grid-column: auto;
  }

  .ui-card-header,
  .ui-card-content {
    padding-inline: 16px;
  }

  .confirm-actions,
  .detail-actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .confirm-actions .ui-button,
  .detail-actions .ui-button,
  .form-actions .ui-button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .shell,
  .topbar-inner {
    padding-inline: 10px;
  }

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

  .metrics,
  .review-metrics,
  .filter-bar {
    grid-template-columns: 1fr;
  }

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

  .machine-panel,
  .live-summary,
  .ui-card,
  .report-table tr {
    border-radius: 10px;
  }

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

  .machine-counts span {
    font-size: 10px;
  }

  .report-table tr {
    grid-template-columns: 1fr;
  }

  .report-table td:first-child,
  .report-table td:last-child {
    grid-column: auto;
  }
}

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

@media print {
  .topbar,
  .site-footer,
  .hero-actions,
  .export-actions,
  .filter-bar,
  .detail-actions {
    display: none !important;
  }

  body,
  html {
    background: white;
  }

  .shell {
    width: 100%;
    padding: 0;
  }
}
