:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #18312d;
  background: #f2f5f2;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #18312d;
  --muted: #667873;
  --line: #d9e2dc;
  --paper: #f2f5f2;
  --card: #fff;
  --green: #17654f;
  --green-dark: #153a34;
  --amber: #915d17;
  --amber-soft: #fff5e6;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell {
  width: min(100% - 28px, 760px);
  margin: 0 auto;
  padding: 20px 0 28px;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 2px 18px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  background: var(--green-dark);
  color: white;
  font-size: 19px;
  font-weight: 800;
}

.brand-mark svg {
  display: block;
  width: 34px;
  height: 34px;
}

h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -.025em;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 5px 18px #123b2c0a;
}

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

.field { min-width: 0; }

.field label {
  display: block;
  margin-bottom: 7px;
  color: #536761;
  font-size: 13px;
  font-weight: 680;
}

.field input, .field select {
  width: 100%;
  min-height: 52px;
  padding: 0 13px;
  border: 1px solid #c8d6ce;
  border-radius: 11px;
  outline: none;
  background: white;
  color: var(--ink);
  font-size: 17px;
}

.field input::placeholder { color: #96a49e; }
.field input:focus, .field select:focus { border-color: var(--green); box-shadow: 0 0 0 3px #17654f20; }
.field-hint { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }

.results, .details { margin-top: 14px; padding: 17px; }
.details { display: grid; gap: 17px; }
.details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.custom-aircraft { margin-top: 8px; }
.taxi-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.taxi-control { display: grid; gap: 7px; }
.taxi-label { color: #536761; font-size: 12px; font-weight: 680; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.stepper button {
  width: 44px;
  height: 42px;
  border: 1px solid #c8d6ce;
  border-radius: 10px;
  background: #fff;
  color: var(--green);
  font-size: 21px;
  font-weight: 650;
}
.stepper output { display: flex; min-width: 48px; align-items: baseline; justify-content: center; gap: 4px; color: var(--ink); text-align: center; font-size: 14px; font-weight: 720; }
.stepper output small { color: var(--muted); font-size: 11px; font-weight: 400; }
.segment-fields { display: grid; gap: 12px; }
.segment-editor { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fbfcfb; }
.segment-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 13px; }
.segment-heading h2 { margin: 0; font-size: 14px; }
.core-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.route-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.segment-editor .field input, .segment-editor .field select, .details-grid .field input, .details-grid .field select {
  min-height: 46px;
  font-size: 15px;
}
.segment-editor .field label, .details-grid .field label { margin-bottom: 5px; font-size: 11px; }
.add-segment {
  min-height: 45px;
  border: 1px dashed #9aafa5;
  border-radius: 11px;
  background: #f7faf7;
  color: var(--green);
  font-weight: 700;
}
.quick-result { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 10px; }
.quick-result h2 { margin: 0; font-size: 14px; }
.quick-total { color: var(--green); font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.quick-leg { padding: 7px 0; border-top: 1px solid #edf1ee; color: #334a44; font-size: 12px; overflow-wrap: anywhere; }
.entry-output { padding-top: 11px; border-top: 1px solid var(--line); }
.entry-output h3 { margin: 0 0 7px; font-size: 13px; }
.table-wrap { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; overscroll-behavior-x: contain; }
.table-wrap:focus-visible { outline: 3px solid #17654f40; outline-offset: 2px; }
.data-table { width: max-content; min-width: 100%; border-collapse: collapse; color: #334a44; font-size: 11px; text-align: left; }
.data-table th, .data-table td { padding: 8px 9px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table th { background: #f5f8f5; color: #536761; font-weight: 700; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table th:last-child, .data-table td:last-child { border-right: 0; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.result-actions button { min-height: 45px; border: 0; border-radius: 10px; background: var(--green); color: #fff; font-weight: 700; }
.result-actions button + button { background: var(--green-dark); }
.field-error { margin: 8px 0 0; color: #a44036; font-size: 12px; }
.ground-warning { margin: 8px 0 0; color: var(--amber); font-size: 12px; font-weight: 700; }
.segment-error { margin: 8px 0 0; color: var(--amber); font-size: 11px; }

footer {
  margin: 17px 4px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

@media (min-width: 640px) {
  .app-shell { padding-top: 28px; }
  .primary-form { padding: 24px; }
  .results, .details { padding: 22px; }
}

@media (max-width: 600px) {
  .table-wrap { overflow: visible; border: 0; }
  .data-table, .data-table tbody { display: block; width: 100%; min-width: 0; }
  .data-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .data-table tbody { display: grid; gap: 8px; }
  .data-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
  }
  .data-table td {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    border: 0;
    border-right: 1px solid var(--line);
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .data-table td:nth-child(even) { border-right: 0; }
  .data-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
  }
}

@media (max-width: 390px) {
  .app-shell { width: min(100% - 20px, 760px); }
  .primary-form { gap: 14px; padding: 15px; }
  .results, .details { padding: 13px; }
  .taxi-controls { gap: 6px; }
  .stepper { gap: 3px; }
  .stepper button { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: no-preference) {
  .card { transition: box-shadow 160ms ease; }
}
