:root {
  color-scheme: light;
  --ink: #172326;
  --muted: #5d6f73;
  --line: #d8e3e5;
  --paper: #f7faf9;
  --panel: #ffffff;
  --teal: #0f4c5c;
  --green: #2d7d5f;
  --amber: #b36b16;
  --blue: #1f6f9f;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  background: #f7faf9;
  color: var(--ink);
  font-size: 12px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

button,
input {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1180px, calc(100vw - 16px));
  margin: 0 auto;
  padding: 8px 0 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(16px, 3.5vw, 26px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 12px;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  color: var(--teal);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.icon-button.small {
  width: 28px;
  height: 24px;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.status-grid {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 6px;
}

.details-open .status-grid {
  display: grid;
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
}

.text-button {
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  color: var(--teal);
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
}

.metric {
  min-height: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metric.accent {
  border-color: rgba(15, 76, 92, 0.45);
  background: #f2fbf8;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, 360px) auto auto;
  gap: 6px;
  align-items: end;
  margin-bottom: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
}

.search-wrap,
.range-wrap {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.search-wrap input {
  width: 100%;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0 6px;
  background: #fff;
  color: var(--ink);
}

.range-wrap input {
  width: 100%;
  accent-color: var(--teal);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 144px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #eef5f3;
}

.segmented button {
  height: 24px;
  border: 0;
  border-radius: 1px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
}

.segmented button.active {
  background: var(--panel);
  color: var(--teal);
  box-shadow: 0 1px 8px rgba(23, 35, 38, 0.12);
}

.segmented button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.table-section {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.table-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 6px;
  border-bottom: 1px solid var(--line);
}

.table-heading p {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr.biggest {
  background: #fff8ee;
}

.gap-cell {
  width: 82px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.flight-cell {
  display: grid;
  gap: 2px;
}

.flight-main {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.badge {
  display: none;
  min-width: 46px;
  height: 16px;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  color: #fff;
  font-size: 8px;
  font-weight: 800;
}

.details-open .badge {
  display: inline-flex;
}

.badge.departure {
  background: var(--blue);
}

.badge.arrival {
  background: var(--green);
}

.flight-time {
  font-size: 12px;
}

.flight-route {
  display: none;
  font-size: 12px;
  font-weight: 800;
}

.flight-meta {
  display: none;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.details-open .flight-route,
.details-open .flight-meta {
  display: block;
}

.empty-state {
  padding: 12px 6px;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 860px) {
  .details-open .status-grid,
  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .controls .segmented {
    grid-column: auto;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100vw - 8px, 1180px);
    padding-top: 5px;
    padding-bottom: 12px;
  }

  .topbar {
    align-items: flex-start;
    margin-bottom: 5px;
  }

  h1 {
    font-size: 16px;
    line-height: 1.05;
  }

  .details-open .status-grid,
  .controls {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .controls {
    padding: 5px;
  }

  .metric {
    min-height: auto;
    padding: 5px;
  }

  .metric strong {
    font-size: 12px;
  }

  .table-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
    padding: 5px;
  }

  .table-scroll {
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody tr {
    padding: 5px;
    border-bottom: 1px solid var(--line);
  }

  tbody tr.biggest {
    background: #fff8ee;
  }

  tbody tr.continuation {
    padding-top: 0;
  }

  tbody tr.continuation td:first-child {
    display: none;
  }

  td {
    padding: 0;
    border-bottom: 0;
  }

  td + td {
    margin-top: 5px;
  }

  td:first-child::before,
  td:last-child::before {
    display: none;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 8px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .details-open td:first-child::before,
  .details-open td:last-child::before {
    display: block;
  }

  td:first-child::before {
    content: "Flight before gap";
  }

  td:last-child::before {
    content: "Next flight";
  }

  .gap-cell {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 6px;
    color: var(--green);
    font-size: 12px;
  }

  .gap-cell::before,
  .gap-cell::after {
    content: none;
    height: 1px;
    flex: 1;
    background: var(--line);
  }

  .details-open .gap-cell::before,
  .details-open .gap-cell::after {
    content: "";
  }

  .flight-time {
    font-size: 12px;
  }

  .flight-route {
    font-size: 12px;
  }

  .flight-meta {
    font-size: 10px;
  }

  .badge {
    min-width: 44px;
    height: 16px;
    font-size: 8px;
  }
}

@media (max-width: 390px) {
  .app-shell {
    width: min(100vw - 6px, 1180px);
  }

  h1 {
    font-size: 15px;
  }

.icon-button {
    width: 30px;
    height: 30px;
  }
}
