/* otselend: tume kujundus (sügav sinakas taust, klaasjad paneelid, helesinine aktsent) */
:root {
  color-scheme: dark;   /* brauseri enda elemendid (kerimisribad, kuupäevavalik) samuti tumedad */
  --bg: #0b1120; --card: #111a2e; --text: #e6edf7; --muted: #8b9ab3; --line: #1f2b44;
  --primary: #4cc2ff; --primary-hover: #7dd3ff; --navy: #0d1528; --navy2: #16213a; --sky: #4cc2ff;
  --panel: rgba(17,26,46,.8);
  --good-bg: rgba(52,211,153,.14); --good: #6ee7b7; --warn-bg: rgba(251,191,36,.14); --warn: #fcd34d;
  --bad-bg: rgba(248,113,113,.15); --bad: #fca5a5; --gray-bg: rgba(148,163,184,.14); --gray: #cbd5e1;
  --blue-bg: rgba(96,165,250,.15); --blue: #93c5fd; --purple-bg: rgba(167,139,250,.15); --purple: #c4b5fd;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 18px; }
body { margin: 0; color: var(--text); line-height: 1.45;
       background: radial-gradient(1200px 600px at 75% -10%, #13284d 0%, transparent 60%), var(--bg); background-attachment: fixed;
       font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Source Sans 3", sans-serif; }

.app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }   /* riba = sisu kõrgus, ülejäänu põhisisule */

/* ---- valikute riba: kitsal ekraanil paneel lehe ülaosas, laial ekraanil klaasriba (vt @media allpool) ---- */
aside { background: rgba(13,21,40,.85); border-bottom: 1px solid var(--line); color: #e8eef6; padding: 1.2rem; }
aside h2 { font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 600; margin: 1.8rem 0 .7rem; }
aside > .grp:first-of-type > h2 { margin-top: 0; }
aside label { display: flex; justify-content: space-between; font-size: .85rem; margin: 1rem 0 .3rem; color: #a7b4c9; }
aside label b { color: var(--sky); font-weight: 600; }
aside select, aside input[type=search], aside input[type=date] {
  width: 100%; background: var(--navy2); color: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: .55rem .7rem; font: inherit; font-size: .9rem; }
aside input[type=search]::placeholder { color: #9fb1c6; }
aside input:focus, aside select:focus { outline: 2px solid rgba(76,194,255,.5); outline-offset: 0; }
aside .search { margin-top: 1rem; }
aside select option { color: #fff; background: var(--navy2); }
aside input[type=range] { width: 100%; accent-color: var(--sky); }
aside .check { justify-content: flex-start; gap: .55rem; align-items: center; cursor: pointer; margin-top: 1.1rem; }
aside input[type=checkbox] { accent-color: var(--sky); width: 1rem; height: 1rem; }
aside .hint { font-size: .78rem; color: #9fb1c6; margin: .35rem 0 0; }
.linkbtn { background: none; border: 0; color: var(--primary); font: inherit; font-size: .8rem; cursor: pointer; padding: 0; }
.linkbtn:hover { text-decoration: underline; }

/* ---- päis ---- */
main { padding: 2.6rem 2.5rem 1.6rem; min-width: 0; display: flex; flex-direction: column; }   /* jalus alati lehe allservas */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; }
h1 { font-size: 2.6rem; line-height: 1.2; letter-spacing: -.03em; font-weight: 750; margin: 0;   /* helendav gradient-pealkiri */
     background: linear-gradient(90deg, #ffffff 0%, #bfe8ff 55%, #4cc2ff 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { color: var(--muted); font-size: .85rem; margin: .35rem 0 1.3rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: #fff; flex-shrink: 0; margin-top: .3rem; }
.brand svg { width: 44px; height: 44px; display: block; }
.brand span { font-size: 1.55rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.brand span b { color: var(--primary); font-weight: 800; }

/* ---- vaate nupud + värskenda ---- */
.pills { display: flex; gap: .6rem; margin-bottom: 1.1rem; flex-wrap: wrap; align-items: center; }
.pill { background: rgba(255,255,255,.04); border: 1px solid var(--line); color: #c8d3e6; border-radius: 10px;
        padding: .38rem 1.2rem; font: inherit; font-size: .9rem; cursor: pointer; }
.pill:hover { border-color: #33476e; color: #fff; }
.pill[aria-pressed="true"] { background: rgba(76,194,255,.16); border-color: rgba(76,194,255,.55); color: #fff; }
.pill.action { background: linear-gradient(180deg, #4cc2ff, #2b9ee6); border-color: transparent; color: #04121f; font-weight: 600; }
.pill.action:hover { background: linear-gradient(180deg, #7dd3ff, #4cc2ff); }
.pill.action:disabled { opacity: .6; cursor: progress; }
.pills .sep { width: 1px; height: 1.6rem; background: var(--line); margin: 0 .2rem; }

.caption { color: var(--muted); font-size: .8rem; margin: .2rem 0 .5rem; min-height: 1.2em; }

/* ---- tabelid ---- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
              overflow: auto; resize: vertical; /* ainult kõrgust saab venitada, laiust mitte */ min-height: 140px; }
table { border-collapse: collapse; width: 100%; font-size: .84rem; }
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid rgba(31,43,68,.7); white-space: nowrap; }
tbody tr:hover { background: rgba(76,194,255,.06); }
thead th { position: sticky; top: 0; background: #0f1830; color: #7f8fab; font-weight: 600; font-size: .7rem; z-index: 1;
           text-transform: uppercase; letter-spacing: .09em; cursor: pointer; user-select: none; }
thead th:hover { color: #fff; }
thead th[aria-sort="ascending"]::after { content: " ▲"; font-size: .65rem; }
thead th[aria-sort="descending"]::after { content: " ▼"; font-size: .65rem; }
td.time { font-variant-numeric: tabular-nums; font-weight: 600; color: #fff; }
td.rev { color: var(--warn); }
.chip { display: inline-block; padding: .08rem .6rem; border-radius: 8px; font-size: .8rem; font-weight: 500; border: 1px solid rgba(255,255,255,.06); }
.good { background: var(--good-bg); color: var(--good); } .warn { background: var(--warn-bg); color: var(--warn); }
.bad { background: var(--bad-bg); color: var(--bad); } .gray { background: var(--gray-bg); color: var(--gray); }
.blue { background: var(--blue-bg); color: var(--blue); } .purple { background: var(--purple-bg); color: var(--purple); }

.alert { padding: .8rem 1rem; border-radius: 12px; margin: .6rem 0; font-size: .9rem;
         background: rgba(251,191,36,.08); color: #fcd34d; border: 1px solid rgba(251,191,36,.25); }
.alert.err { background: rgba(248,113,113,.08); color: #fca5a5; border-color: rgba(248,113,113,.25); }
.alert.info { background: rgba(96,165,250,.08); color: #bfdbfe; border-color: rgba(96,165,250,.22); }
.progress { height: 8px; background: var(--navy2); border-radius: 99px; overflow: hidden; margin: .4rem 0 .8rem; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #2b9ee6, #4cc2ff); width: 0; transition: width .9s linear; }

/* ---- radari kaardid: klaasjad, värviline kuma nurgas ---- */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; margin: .6rem 0 1.1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: .7rem 1rem; position: relative; overflow: hidden; }
.card::after { content: ""; position: absolute; inset: auto -20% -60% auto; width: 140px; height: 140px; border-radius: 50%;
               background: radial-gradient(circle, rgba(76,194,255,.28), transparent 70%); }
.card.c-dep::after { background: radial-gradient(circle, rgba(52,211,153,.3), transparent 70%); }
.card.c-gnd::after { background: radial-gradient(circle, rgba(148,163,184,.25), transparent 70%); }
.card.c-oth::after { background: radial-gradient(circle, rgba(251,146,60,.3), transparent 70%); }
.card span { font-size: .8rem; display: block; color: var(--muted); }
.card b { font-size: 2rem; font-weight: 700; line-height: 1.2; color: #fff; }

.radar-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 4fr); gap: 1rem; align-items: start; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .88rem; margin-bottom: .4rem; color: #c8d3e6; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: .4rem; vertical-align: -1px; }
.note { color: var(--muted); font-size: .78rem; margin: .3rem 0 .7rem; }
#map { height: 430px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); }
#map .leaflet-tile-pane { filter: invert(1) hue-rotate(200deg) brightness(.8) contrast(.95) saturate(.5); }   /* OSM-kaart tumedaks */
.leaflet-container .leaflet-control-attribution { background: rgba(11,17,32,.75); color: var(--muted); }
.leaflet-container .leaflet-control-attribution a { color: #a7c7e7; }
.leaflet-bar a { background: var(--navy2); color: var(--text); border-color: var(--line); }
footer { color: var(--muted); font-size: .75rem; margin-top: auto; padding-top: 1.2rem; text-align: right; }
footer a { color: var(--primary); }
.map-fallback { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: .85rem; padding: 1rem; text-align: center; }

@media (max-width: 1200px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .radar-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  main { padding: 1.5rem 1rem; }
  h1 { font-size: 1.8rem; }
}

/* ---- lemmikud ---- */
.airport-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem; }
.star { background: var(--navy2); border: 1px solid var(--line); border-radius: 10px; width: 2.4rem; cursor: pointer; display: grid; place-items: center; }
.star svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: #9fb1c6; stroke-width: 1.8; stroke-linejoin: round; }
.star:hover svg { stroke: var(--sky); }
.star[aria-pressed="true"] svg { fill: #ffc940; stroke: #ffc940; }
.favs { display: flex; flex-wrap: wrap; gap: .4rem; }
.fav { display: inline-flex; align-items: center; background: var(--navy2); border: 1px solid var(--line); border-radius: 999px; font-size: .8rem; }
.fav button { background: none; border: 0; color: #e8eef6; font: inherit; cursor: pointer; padding: .3rem .2rem .3rem .75rem; }
.fav button.x { color: #9fb1c6; padding: .3rem .6rem .3rem .3rem; }
.fav button:hover { color: var(--sky); }
.fav.active { outline: 1px solid var(--sky); }

/* ---- konto ---- */
.top-right { display: flex; align-items: center; gap: 1.1rem; }
.top-right .brand { margin: 0 0 0 auto; }
.top-right .brand svg { width: 34px; height: 34px; }
.top-right .brand span { font-size: 1.25rem; }
.account { display: flex; align-items: center; gap: .7rem; font-size: .82rem; color: var(--muted); min-height: 1.9rem; }

/* rippmenüü (konto): <details>, ilma JavaScriptita; klõps mujale sulgeb (app.js) */
details.dropdown { position: relative; }
details.dropdown > summary { list-style: none; cursor: pointer; user-select: none; }
details.dropdown > summary::-webkit-details-marker { display: none; }
.acct > summary { color: var(--text); max-width: 13rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; }
.acct > summary::after { content: " ▾"; color: var(--muted); }
.dropdown .menu { position: absolute; top: calc(100% + .55rem); left: 0; z-index: 1200; min-width: 12rem;
                  display: flex; flex-direction: column; align-items: flex-start; gap: .55rem; padding: .85rem 1rem;
                  background: #0f182c; color: var(--text); border: 1px solid var(--line); border-radius: 12px;
                  box-shadow: 0 16px 40px rgba(0,0,0,.5); font-size: .8rem; }
.dropdown .menu p { margin: 0; line-height: 1.65; }
.dropdown .menu .muted { color: var(--muted); font-size: .72rem; }
.dropdown .menu a { color: var(--primary); }
.account .pill { padding: .3rem 1rem; font-size: .85rem; white-space: nowrap; }
.linkbtn.dark { color: var(--primary); font-size: .85rem; }
.login-prompt { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem 1.6rem; max-width: 40rem; }
.login-prompt b { font-size: 1.05rem; }
.login-prompt p { color: var(--muted); font-size: .9rem; margin: .45rem 0 .8rem; }
.login-prompt ul { margin: 0 0 1.2rem; padding: 0; list-style: none; display: grid; gap: .45rem; font-size: .88rem; color: #c8d3e6; }
.login-prompt li { padding-left: 1.3rem; position: relative; }
.login-prompt li::before { content: ""; position: absolute; left: .2rem; top: .5em; width: .45rem; height: .45rem; border-radius: 50%; background: var(--primary); }
.lp-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* ---- sisselogimise dialoog ---- */
dialog { background: #0f182c; color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 1.6rem 1.7rem 1.2rem;
         width: min(26rem, calc(100vw - 2rem)); box-shadow: 0 30px 80px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(3,7,18,.7); backdrop-filter: blur(4px); }
dialog h2 { margin: 0 0 .4rem; font-size: 1.3rem; }
dialog .muted { color: var(--muted); font-size: .85rem; margin: 0 0 1rem; }
dialog label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .3rem; }
dialog input { width: 100%; font: inherit; font-size: 1rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 8px;
               background: var(--bg); color: var(--text); }
dialog input:focus { outline: 2px solid var(--primary); background: var(--bg); }
#login-code-input { letter-spacing: .5em; font-variant-numeric: tabular-nums; font-size: 1.3rem; text-align: center; }
.dlg-msg { min-height: 1.3em; font-size: .82rem; color: var(--bad); margin: .45rem 0 .2rem; }
.dlg-msg.ok { color: var(--good); }
.dlg-actions { display: flex; justify-content: flex-end; align-items: center; gap: .8rem; flex-wrap: wrap; margin-top: .4rem; }
.privacy { color: var(--muted); font-size: .72rem; margin: 1rem 0 0; border-top: 1px solid var(--line); padding-top: .7rem; }
@media (max-width: 860px) {
  /* kitsal ekraanil samuti kõrvuti: konto (nupp / e-post) vasakul, logo paremal */
  .top-right { gap: .9rem; margin-top: 0; max-width: 100%; }
  .account { flex-wrap: wrap; min-width: 0; gap: .3rem .7rem; }
  .account .email { max-width: 100%; }
}
@media (max-width: 860px) {
  aside .top-right { margin-bottom: .4rem; }
}

/* ---- laial ekraanil: valikud kompaktse klaasribana ekraani ülaosas ----
   1. rida: riik, lennujaam, kuupäev (tabloo), otsing | konto ja logo paremal
   2. rida: radari sätted (radarivaates) ja lemmikud
   Grupid "sulanduvad" ribasse (display: contents), et väljade järjekorda saaks muuta (order) ilma HTML-i muutmata. */
@media (min-width: 861px) {
  aside { position: sticky; top: 0; z-index: 1100;
          display: flex; flex-wrap: wrap; align-items: center; gap: 0 1.1rem;
          padding: .55rem 2.5rem; background: rgba(11,17,32,.62); border-bottom: 1px solid rgba(76,194,255,.14);
          backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3); box-shadow: 0 6px 24px rgba(0,0,0,.25); }
  aside h2 { display: none; }
  .grp-airport, #set-board { display: contents; }
  .grp-airport .field:nth-child(2) { order: 1; }            /* riik */
  .grp-airport .field:nth-child(3) { order: 2; }            /* lennujaam + täht */
  #set-board .field { order: 3; }                           /* kuupäev */
  .grp-airport .field-search { order: 4; }                  /* otsing */
  .top-right { order: 5; margin-left: auto; }
  aside::after { content: ""; order: 6; flex-basis: 100%; height: 0; }   /* reamurdmine: edasi 2. rida */
  #set-radar { order: 7; display: flex; align-items: center; gap: .55rem 1.1rem; margin-top: .45rem; }
  #fav-box { order: 8; flex: 1 1 18rem; min-width: 0; overflow: hidden; margin-top: .45rem; }   /* alla 18rem ruumi: oma rida */
  aside .field { display: flex; align-items: center; gap: .45rem; }
  aside label { margin: 0; font-size: .72rem; color: var(--muted); white-space: nowrap; gap: .4rem; }
  aside label b { font-size: .78rem; }
  aside select, aside input[type=search], aside input[type=date] {
    padding: .3rem .8rem; font-size: .8rem; border-radius: 999px; background: rgba(22,33,58,.85); }
  .grp-airport .field:nth-child(2) select { width: 9.5rem; }
  .grp-airport .field:nth-child(3) .airport-row { width: 12.5rem; }
  .grp-airport .field-search { width: 11rem; }
  aside .search { margin-top: 0; }
  .star { width: 1.9rem; height: 1.9rem; border-radius: 999px; }
  .star svg { width: 1rem; height: 1rem; }
  #set-board input[type=date] { width: 9.5rem; }
  aside input[type=range] { width: 6rem; }
  aside .check { margin: 0; font-size: .74rem; }
  aside input[type=checkbox] { width: .9rem; height: .9rem; }
  .favs { flex-wrap: nowrap; overflow-x: auto; }
  .fav { font-size: .74rem; flex-shrink: 0; }
  .fav button { white-space: nowrap; }
  .dropdown .menu { left: auto; right: 0; }
  main { padding-top: 1.6rem; }
}
/* kui valikud + konto ühte ritta ei mahu: konto ja logo omaette ülemisele reale (paremale) */
@media (min-width: 861px) and (max-width: 1560px) {
  .top-right { order: 0; flex-basis: 100%; justify-content: flex-end; margin: 0 0 .35rem; }
  .top-right .brand { margin-left: 0; }
}
