@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700&display=swap');

:root {
  color-scheme: light;
  --ink: #132238;
  --muted: #67758a;
  --line: #dce4ee;
  --blue: #1769e0;
  --blue-dark: #0d4fb5;
  --sky: #eaf4ff;
  --paper: #f7f9fc;
  --white: #fff;
  --green: #197446;
  --shadow: 0 18px 48px rgba(33, 61, 97, .09);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-width: 300px;
  color: var(--ink);
  background:
    radial-gradient(circle at 78% 0%, rgba(191, 222, 255, .7), transparent 28rem),
    linear-gradient(180deg, #f4f9ff 0, var(--paper) 34rem);
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
}
body:not(.edit-mode) .edit-only { display: none !important; }
body.edit-mode .readonly-only { display: none !important; }
.auth-field input { width: 100%; height: 54px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; font: 600 16px/1 "DM Sans", sans-serif; outline: none; }
.auth-field input:focus { border-color: #70a9ef; box-shadow: 0 0 0 3px rgba(23,105,224,.1); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }

.topbar {
  height: 76px;
  padding: 0 max(24px, calc((100vw - 1260px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(205, 219, 235, .8);
  background: rgba(250, 253, 255, .78);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font: 700 18px/1 Manrope, sans-serif; }
.brand-mark { width: 35px; height: 35px; border-radius: 12px; display: grid; place-items: center; background: var(--blue); color: white; font-size: 22px; box-shadow: 0 8px 20px rgba(23, 105, 224, .25); }
.top-actions { display: flex; gap: 10px; }
.top-currency { height: 42px; min-width: 132px; position: relative; }
.top-currency span { position: absolute; z-index: 1; left: 12px; top: 5px; color: var(--muted); font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; pointer-events: none; }
.top-currency select { width: 100%; height: 100%; padding: 15px 28px 2px 11px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: rgba(255,255,255,.78); font-weight: 700; outline: none; }
.top-currency select:focus { border-color: #83b6f6; box-shadow: 0 0 0 3px rgba(23,105,224,.1); }
.button { border: 0; border-radius: 12px; min-height: 42px; padding: 0 16px; font-weight: 700; transition: .18s ease; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--blue); box-shadow: 0 8px 20px rgba(23, 105, 224, .2); }
.button.primary:hover { background: var(--blue-dark); }
.button.ghost { background: rgba(255,255,255,.7); border: 1px solid var(--line); color: var(--ink); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.wide { width: 100%; margin-top: 9px; }
.refresh-icon { font-size: 18px; line-height: 1; }
.refresh-icon.spinning { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { max-width: 1260px; margin: 0 auto; padding: 32px 24px 80px; }
.eyebrow { margin: 0 0 12px; color: var(--blue); font-weight: 700; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; }

.filters { display: grid; grid-template-columns: 1.15fr 1fr 1fr 1fr 1fr auto; gap: 10px; padding: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.86); border-radius: 18px; box-shadow: var(--shadow); }
.filters label { position: relative; min-width: 0; }
.filters label > span { position: absolute; z-index: 1; top: 9px; left: 13px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; pointer-events: none; }
.filters select, .filters input { width: 100%; height: 58px; padding: 23px 34px 7px 12px; color: var(--ink); border: 1px solid transparent; border-radius: 11px; outline: none; background: #f4f7fb; font-weight: 600; }
.filters select:focus, .filters input:focus { border-color: #83b6f6; background: white; box-shadow: 0 0 0 3px rgba(23,105,224,.1); }
.price-input { position: relative; }
.price-input span { position: absolute; right: 11px; bottom: 10px; color: var(--muted); font-size: 13px; }
.price-input input { padding-right: 35px; }
.clear-filter { align-self: center; border: 0; color: var(--blue); background: transparent; padding: 10px; font-weight: 700; }

.board-heading { margin: 48px 2px 20px; display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.board-heading h2 { margin: 0; font: 700 25px/1.1 Manrope, sans-serif; letter-spacing: -.025em; }
.board-heading p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.legend { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.legend-dot { width: 11px; height: 11px; border-radius: 4px; display: inline-block; }
.legend-dot.low { background: #d7f4df; }
.legend-dot.high { background: #f9e4dd; margin-left: 6px; }
.fare-board { display: grid; gap: 14px; min-width: 0; }
.aggregate-board { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; min-width: 0; }
.aggregate-card { min-width: 0; max-width: 100%; background: var(--white); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 10px 36px rgba(37,64,96,.055); overflow: hidden; }
.aggregate-card:only-child { grid-column: 1 / -1; }
.aggregate-head { min-height: 108px; padding: 20px 22px; display: flex; justify-content: space-between; align-items: center; gap: 22px; }
.aggregate-title { min-width: 0; }
.aggregate-title p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.aggregate-route { display: flex; align-items: center; gap: 12px; font: 700 22px/1 Manrope, sans-serif; letter-spacing: -.035em; }
.aggregate-route .plane { color: var(--blue); font-size: 18px; }
.aggregate-best { text-align: right; flex: 0 0 auto; }
.aggregate-best small { color: var(--muted); display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; margin-bottom: 7px; }
.aggregate-best strong { color: var(--green); font: 700 21px/1 Manrope, sans-serif; }
.aggregate-body { min-width: 0; padding: 18px; border-top: 1px solid var(--line); background: #fbfcfe; }
.aggregate-card .month { flex-basis: 252px; }
.aggregate-card .fare-cell { min-height: 53px; }
.fare-cell .route-tag { color: #52647a; font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.individual-heading { margin-top: 44px; }

.route-card { min-width: 0; max-width: 100%; background: var(--white); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 10px 36px rgba(37,64,96,.055); overflow: hidden; }
.route-summary { min-height: 112px; padding: 20px 22px; display: grid; grid-template-columns: minmax(220px, 1fr) 180px 180px auto; align-items: center; gap: 24px; list-style: none; cursor: pointer; }
.route-summary::-webkit-details-marker { display: none; }
.route-line { display: flex; align-items: center; gap: 15px; }
.airport-code { font: 700 25px/1 Manrope, sans-serif; letter-spacing: -.03em; }
.route-arrow { width: 44px; height: 2px; background: #b8c6d7; position: relative; }
.route-arrow::after { content: ""; position: absolute; right: 0; top: -4px; width: 8px; height: 8px; border-top: 2px solid #91a3b9; border-right: 2px solid #91a3b9; transform: rotate(45deg); }
.route-sub { color: var(--muted); font-size: 12px; margin-top: 9px; }
.metric { border-left: 1px solid var(--line); padding-left: 24px; min-width: 0; }
.metric small { color: var(--muted); display: block; font-size: 11px; margin-bottom: 7px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.metric strong { font: 700 21px/1.15 Manrope, sans-serif; white-space: nowrap; }
.metric strong.good { color: var(--green); }
.metric span { color: var(--muted); font-size: 13px; }
.summary-actions { display: flex; align-items: center; gap: 10px; }
.search-link, .icon-button { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; text-decoration: none; color: var(--blue); border: 1px solid var(--line); background: #fff; font-weight: 700; }
.icon-button { color: #9a4550; font-size: 17px; }
.chevron { width: 30px; height: 30px; display: grid; place-items: center; color: var(--muted); transition: transform .2s ease; }
.route-card[open] .chevron { transform: rotate(180deg); }
.route-body { min-width: 0; max-width: 100%; border-top: 1px solid var(--line); padding: 22px; background: #fbfcfe; }
.month-scroll { width: 100%; max-width: 100%; display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 2px 14px; scrollbar-color: #c7d4e4 transparent; }
.month { flex: 0 0 286px; scroll-snap-align: start; }
.month h3 { margin: 0 0 13px 4px; font: 700 14px/1 Manrope, sans-serif; }
.weekdays, .month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.weekdays { margin-bottom: 4px; color: #95a1b2; text-align: center; font-size: 9px; font-weight: 700; }
.fare-cell { min-height: 48px; padding: 6px 5px; border-radius: 8px; display: flex; flex-direction: column; justify-content: space-between; color: var(--ink); text-decoration: none; transition: transform .15s ease, box-shadow .15s ease; }
.fare-cell:hover { transform: translateY(-2px); box-shadow: 0 5px 13px rgba(34,64,97,.13); }
.fare-cell .day { font-size: 10px; color: #65748a; }
.fare-cell .fare { font-size: 10px; font-weight: 700; letter-spacing: -.02em; }
.fare-cell.blank { background: transparent; pointer-events: none; }
.heat-0 { background: #d8f4df; } .heat-1 { background: #e8f4df; } .heat-2 { background: #f5f1d9; } .heat-3 { background: #f9e8d8; } .heat-4 { background: #f9dedc; }
.route-footer { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-top: 6px; color: var(--muted); font-size: 11px; }
.route-footer a { color: var(--blue); font-weight: 700; text-decoration: none; }
.no-cache { padding: 28px; color: var(--muted); text-align: center; }
.no-cache strong { display: block; color: var(--ink); margin-bottom: 5px; }
.route-error { color: #9a4550; font-size: 12px; margin: 0 0 12px; }
.empty-state { min-height: 300px; border: 1px dashed #cbd8e7; border-radius: 20px; display: grid; place-items: center; align-content: center; text-align: center; background: rgba(255,255,255,.5); }
.empty-plane { font-size: 34px; color: var(--blue); transform: rotate(-12deg); }
.empty-state h3 { margin: 18px 0 5px; }
.empty-state p { margin: 0; color: var(--muted); }

dialog { border: 0; padding: 0; border-radius: 24px; box-shadow: 0 25px 80px rgba(25,45,70,.25); }
dialog::backdrop { background: rgba(24,39,57,.4); backdrop-filter: blur(6px); }
.dialog-card { width: min(520px, calc(100vw - 32px)); padding: 32px; position: relative; }
.dialog-card h2 { margin: 0; font: 700 28px/1.15 Manrope, sans-serif; }
.dialog-copy { color: var(--muted); margin: 10px 0 25px; }
.dialog-close { position: absolute; right: 18px; top: 16px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #f0f4f8; font-size: 20px; color: var(--muted); }
.route-fields { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; }
.route-fields label span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 7px 2px; }
.route-fields input { width: 100%; height: 58px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; text-transform: uppercase; font: 700 22px/1 Manrope, sans-serif; outline: none; }
.route-fields input:focus { border-color: #70a9ef; box-shadow: 0 0 0 3px rgba(23,105,224,.1); }
.swap { width: 40px; height: 40px; margin-bottom: 9px; border-radius: 50%; border: 1px solid var(--line); background: white; color: var(--blue); font-size: 18px; }
.form-error { color: #a23e48; min-height: 20px; font-size: 12px; margin: 10px 0 0; }

.run-panel { position: fixed; z-index: 30; right: 20px; bottom: 20px; width: min(570px, calc(100vw - 40px)); max-height: min(620px, calc(100vh - 40px)); border-radius: 20px; color: #e8f0fa; background: #122033; box-shadow: 0 28px 80px rgba(10,24,40,.36); overflow: hidden; transform: translateY(calc(100% + 30px)); opacity: 0; pointer-events: none; transition: .28s cubic-bezier(.2,.8,.2,1); }
.run-panel.visible { transform: translateY(0); opacity: 1; pointer-events: auto; }
.run-head { padding: 20px 22px 16px; display: flex; justify-content: space-between; align-items: start; }
.run-kicker { margin: 0 0 5px; color: #8ebeff; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; }
.run-head h2 { margin: 0; font: 700 17px/1.2 Manrope, sans-serif; }
.panel-close { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(255,255,255,.08); color: #bdc9d9; font-size: 18px; }
.progress-track { height: 3px; background: rgba(255,255,255,.09); }
.progress-track span { display: block; height: 100%; width: 4%; background: #5ba1ff; transition: width .3s ease; }
.run-log { margin: 0; padding: 17px 22px 22px; max-height: 400px; overflow: auto; color: #b9c8dc; background: #0e1a2a; font: 11px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }

@media (max-width: 980px) {
  .filters { grid-template-columns: repeat(3, 1fr); }
  .aggregate-board { grid-template-columns: 1fr; }
  .route-summary { grid-template-columns: minmax(210px, 1fr) 160px auto; }
  .metric.freshness { display: none; }
}
@media (max-width: 680px) {
  .topbar { height: 66px; padding: 0 15px; }
  .brand { font-size: 0; gap: 0; }
  .brand-mark { font-size: 20px; }
  .button { min-height: 39px; padding: 0 12px; font-size: 13px; }
  .button.ghost { font-size: 0; width: 39px; padding: 0; }
  .button.ghost::after { content: "+"; font-size: 21px; }
  .top-actions { gap: 6px; }
  .top-currency { min-width: 76px; height: 39px; }
  .top-currency span { display: none; }
  .top-currency select { padding: 0 20px 0 9px; font-size: 12px; }
  main { padding: 20px 14px 65px; }
  .filters { grid-template-columns: repeat(2, 1fr); padding: 9px; }
  .clear-filter { grid-column: span 2; }
  .board-heading { margin-top: 35px; }
  .aggregate-head { min-height: 96px; padding: 17px; }
  .aggregate-route { font-size: 19px; }
  .aggregate-body { padding: 14px 12px; }
  .legend { display: none; }
  .route-summary { grid-template-columns: 1fr auto; padding: 17px; gap: 13px; }
  .metric { border: 0; padding: 0; text-align: right; }
  .metric strong { font-size: 18px; }
  .metric.freshness, .summary-actions .search-link, .summary-actions .icon-button { display: none; }
  .route-line { gap: 11px; }
  .airport-code { font-size: 21px; }
  .route-arrow { width: 28px; }
  .route-body { padding: 16px 12px; }
  .month { flex-basis: 260px; }
  .route-footer { align-items: start; flex-direction: column; }
  .dialog-card { padding: 27px 20px 22px; }
}

@media (max-width: 350px) {
  .top-actions .button.primary { width: 39px; padding: 0; font-size: 0; }
  .top-actions .button.primary .refresh-icon { font-size: 18px; }
}
