:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --panel: #ffffff;
  --ink: #152029;
  --muted: #62717c;
  --line: #d9e1e6;
  --navy: #102533;
  --warn-bg: #fff5df;
  --warn: #7a5200;
  --assigned: #215aa3;
  --worse: #a3362b;
  --better: #24744d;
  --removed: #74621a;
  --stale: #69737d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea { font: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--navy);
  color: #fff;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 7px;
  cursor: pointer;
}
button.secondary {
  background: #fff;
  color: var(--ink);
}
.site-header {
  background: rgba(245, 245, 247, 0.86);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(18px);
}
.site-nav {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1120px;
  min-height: 48px;
  padding: 0 24px;
}
.site-brand {
  color: #1d1d1f;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}
.site-links {
  align-items: center;
  display: flex;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-links a {
  color: #6e6e73;
  font-size: 13px;
  text-decoration: none;
}
.site-links a:hover {
  color: #1d1d1f;
}
.shell {
  width: min(720px, calc(100vw - 20px));
  margin: 0 auto;
  padding: 18px 0 28px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
h1, h2, p { margin: 0; }
h1 {
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}
.topbar p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
.disclaimer {
  color: #3d4c56;
  font-size: 12px;
  margin-bottom: 10px;
}
.icon-button {
  position: relative;
  min-width: 48px;
  display: inline-grid;
  place-items: center;
}
.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #b43a2e;
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  font-weight: 700;
}
.warning {
  margin-bottom: 10px;
  border: 1px solid #ead39b;
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 7px;
  padding: 9px 10px;
}
.add-card {
  width: 100%;
  min-height: 48px;
  margin-bottom: 10px;
  font-weight: 700;
}
.compact-label { display: none; }
.add-panel, .watchlist, .recent-alerts, .quick-stats {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
}
.add-panel {
  padding: 10px;
}
.lookup-form, .flight-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.form-actions {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 8px;
}
input, textarea {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}
textarea {
  min-height: 64px;
  margin-top: 8px;
  resize: vertical;
}
.lookup-message {
  min-height: 20px;
  margin-top: 8px;
  color: var(--muted);
}
.lookup-message.error { color: var(--worse); }
.candidate-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.candidate-list:not(:empty) {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.candidate {
  display: grid;
  grid-template-columns: 1fr 30px;
  gap: 6px;
  align-items: center;
}
.candidate-main {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  background: #f9fbfc;
  color: var(--ink);
  text-align: left;
}
.candidate-main:disabled {
  opacity: .65;
  cursor: default;
}
.candidate span, .candidate-main span { color: var(--muted); }
.candidate-remove {
  width: 30px;
  min-width: 30px;
  min-height: 40px;
  padding: 0;
}
.flight-rows {
  overflow: hidden;
  border-radius: 8px;
}
.flight-row {
  display: grid;
  grid-template-columns: 42px minmax(78px, 1.1fr) minmax(70px, 1fr) 58px 66px 32px;
  gap: 7px;
  align-items: center;
  min-height: 42px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.flight-row:last-child { border-bottom: 0; }
.flight-row strong {
  font-size: 14px;
  letter-spacing: 0;
}
.flight-row span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reorder-controls {
  display: grid;
  gap: 3px;
  grid-template-columns: 1fr 1fr;
}
.move-btn {
  min-width: 18px;
  min-height: 22px;
  padding: 0;
  background: #fff;
  border-color: #d0d8de;
  color: #52616b;
  font-size: 9px;
  line-height: 1;
}
.move-btn:disabled {
  opacity: .35;
  cursor: default;
}
.edct {
  font-weight: 700;
  text-align: right;
}
.change {
  justify-self: end;
  min-width: 54px;
  border-radius: 999px;
  padding: 3px 7px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.assigned { background: var(--assigned); }
.worse { background: var(--worse); }
.better { background: var(--better); }
.removed { background: var(--removed); }
.stale, .same { background: var(--stale); }
.delete-btn {
  justify-self: end;
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  overflow: hidden;
  color: transparent;
  background: #eef2f4;
  border-color: #d0d8de;
  position: relative;
}
.delete-btn::after {
  content: "x";
  color: #52616b;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.empty {
  padding: 14px 10px;
  color: var(--muted);
}
.recent-alerts {
  padding: 8px 10px;
}
.quick-stats {
  display: none;
  padding: 10px;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.quick-stats div {
  display: grid;
  gap: 2px;
}
.quick-stats strong {
  font-size: 18px;
}
.quick-stats span {
  color: var(--muted);
  font-size: 12px;
}
.link-button {
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--navy);
  font-weight: 700;
}
.alert-list {
  display: grid;
  gap: 6px;
}
.alert-line {
  color: #33434d;
  font-size: 13px;
}
footer {
  color: var(--muted);
  font-size: 12px;
  padding: 4px 2px;
}
dialog {
  width: min(420px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  font-size: 16px;
}
.notification-help {
  padding: 10px 12px 0;
  color: var(--muted);
  font-size: 13px;
}
.summary-content, .modal-list {
  padding: 12px;
}
.summary-content {
  display: grid;
  gap: 8px;
}
@media (min-width: 980px) {
  .shell {
    width: min(960px, calc(100vw - 48px));
    display: grid;
    grid-template-columns: minmax(520px, 680px) minmax(240px, 1fr);
    gap: 12px;
    align-items: start;
  }
  .topbar, .disclaimer, .warning, .add-card, .add-panel, .watchlist, .quick-stats, footer {
    grid-column: 1;
  }
  .recent-alerts {
    grid-column: 2;
    grid-row: 4 / span 2;
  }
  .lookup-form {
    grid-template-columns: 1fr 150px auto;
    align-items: center;
  }
  .form-actions {
    grid-template-columns: 112px 86px;
  }
  .flight-form {
    grid-template-columns: 1fr 90px 90px 190px 78px;
  }
  .flight-row {
    grid-template-columns: 46px 120px 120px 80px 86px 34px;
  }
  .quick-stats {
    display: grid;
  }
}

@media (min-width: 560px) and (max-width: 979px) {
  .shell {
    width: min(680px, calc(100vw - 32px));
  }
  .lookup-form {
    grid-template-columns: 1fr 150px auto;
    align-items: center;
  }
  .form-actions {
    grid-template-columns: 112px 86px;
  }
  .flight-row {
    grid-template-columns: 46px minmax(110px, 1fr) minmax(120px, 1fr) 72px 86px 34px;
  }
}

@media (max-width: 520px) {
  body { background: #fff; }
  .site-nav {
    padding: 0 18px;
  }
  .site-links {
    gap: 14px;
  }
  .site-links a {
    font-size: 12px;
  }
  .shell {
    width: 100%;
    padding: 8px 8px 18px;
  }
  .topbar {
    margin-bottom: 6px;
  }
  h1 {
    font-size: 22px;
  }
  .topbar p,
  .disclaimer,
  footer {
    display: none;
  }
  .icon-button {
    min-width: 38px;
    min-height: 34px;
  }
  .add-card {
    width: auto;
    min-height: 34px;
    margin-bottom: 4px;
    padding: 0 10px;
  }
  .wide-label { display: none; }
  .compact-label { display: inline; }
  .watchlist {
    border: 0;
    border-radius: 0;
    margin-bottom: 4px;
  }
  .flight-rows {
    border-radius: 0;
  }
  .flight-row {
    grid-template-columns: 30px minmax(58px, .95fr) minmax(58px, .9fr) 48px 46px 24px;
    gap: 5px;
    min-height: 32px;
    padding: 4px 2px;
  }
  .flight-row strong,
  .flight-row span {
    font-size: 12px;
  }
  .change {
    min-width: 38px;
    padding: 2px 5px;
    font-size: 11px;
  }
  .reorder-controls {
    gap: 2px;
    grid-template-columns: 1fr;
  }
  .move-btn {
    min-width: 22px;
    min-height: 15px;
    font-size: 8px;
  }
  .delete-btn {
    width: 24px;
    min-width: 24px;
    height: 24px;
    min-height: 24px;
    background: #fff;
    border-color: transparent;
  }
  .recent-alerts {
    display: none;
  }
  .quick-stats {
    display: none;
  }
  .add-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    top: 54px;
    z-index: 4;
    max-height: min(72vh, 520px);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 18px 48px rgba(15, 32, 42, .2);
  }
  .lookup-message {
    min-height: 0;
    margin-top: 6px;
  }
  .candidate {
    grid-template-columns: 1fr auto;
  }
  .candidate-main {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "flight action"
      "route time";
    gap: 2px 8px;
    min-height: 48px;
    padding: 6px 8px;
  }
  .candidate-main strong { grid-area: flight; }
  .candidate-main span:nth-of-type(1) { grid-area: route; }
  .candidate-main span:nth-of-type(2) { grid-area: time; }
  .candidate-main span:nth-of-type(3) { display: none; }
  .candidate-main span:nth-of-type(4) {
    grid-area: action;
    align-self: center;
  }
  .candidate-main span:nth-of-type(2),
  .candidate-main span:nth-of-type(3),
  .candidate-main span:nth-of-type(4) {
    font-size: 12px;
  }
}
