/* ============================================================
   THEME VARIABLES
   ============================================================ */
:root {
  --bg: #0b0f14;
  --surface: #0f141a;
  --text: #e7ecf3;
  --muted: #9aa6b2;
  --line: #1f2a36;
  --chip: #16202b;
  --primary: #4f8cff;

  --ok: #0ea05a;
  --warn: #f59f00;
  --bad: #f04438;

  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fafafa;
    --surface: #ffffff;
    --text: #1f2328;
    --muted: #6b7280;
    --line: #e6e8eb;
    --chip: #f3f4f6;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);

    --ok: #18794e;
    --warn: #915930;
    --bad: #a40000;
  }
}

/* ============================================================
   GLOBAL
   ============================================================ */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu,
    Helvetica, Arial, sans-serif;
}

/* Utility */
.relative {
  position: relative;
}

.hidden {
  display: none !important;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(140%) blur(10px);
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 30px;
  font-weight: 700;
}

.brand img {
  height: 50px;
  opacity: 0.9;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#twilight {
  font-size: 12px;
  color: var(--muted);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.app {
  max-width: 1200px;
  margin: 16px auto 48px;
  padding: 0 16px;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.7fr);
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   PANELS
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.panel .head {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel .body {
  padding: 12px;
}

/* ============================================================
   TOOLBAR & FORMS
   ============================================================ */
.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.field.relative {
  position: relative;
}

.input,
.select,
.btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px;
}

.btn {
  cursor: pointer;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: color-mix(in oklab, var(--primary) 70%, black);
}

.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================
   CHIPS
   ============================================================ */
.chips {
  display: flex;
  gap: 8px;
  margin: 10px 0 6px;
  flex-wrap: wrap;
}

.chip {
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.chip.active {
  background: var(--primary);
  color: #fff;
}

.count {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--muted);
  font-size: 12px;
}

.chip.active .count {
  border-color: color-mix(in oklab, var(--primary) 35%, black);
  background: color-mix(in oklab, var(--primary) 15%, transparent);
  color: #fff;
}

/* ============================================================
   RESULTS & CARDS
   ============================================================ */
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 8px;
  font-weight: 700;
}

.cards {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }
}

.cards.single {
  grid-template-columns: 1fr !important;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.small {
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.sep {
  height: 1px;
  background: var(--line);
  margin: 10px 0;
}

/* ============================================================
   METRICS (Cloud base, vis, icing)
   ============================================================ */
.metric {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  padding: 3px 7px;
  font-weight: 800;
  font-size: 12px;
  margin-right: 8px;
}

.metric.ok {
  background: color-mix(in oklab, var(--ok) 16%, transparent);
  color: var(--ok);
  border: 1px solid color-mix(in oklab, var(--ok) 35%, transparent);
}

.metric.warn {
  background: color-mix(in oklab, var(--warn) 12%, transparent);
  color: var(--warn);
  border: 1px solid color-mix(in oklab, var(--warn) 35%, transparent);
}

.metric.bad {
  background: color-mix(in oklab, var(--bad) 12%, transparent);
  color: var(--bad);
  border: 1px solid color-mix(in oklab, var(--bad) 35%, transparent);
}

.metrics-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ============================================================
   ROUTE CARD
   ============================================================ */
.routeCard {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.routeMap {
  width: 100%;
  height: 160px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--chip);
}

.route-info {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
}

.tapHint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* ============================================================
   AUTOCOMPLETE (Suggestions)
   ============================================================ */
.suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 6px;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
}

#suggestBox {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 6px;
  box-shadow: var(--shadow);
  max-height: 70vh;
  overflow-y: auto;
}

.s-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.s-item:last-child {
  border-bottom: none;
}

.s-item.active {
  background: color-mix(in oklab, var(--primary) 18%, transparent);
}

.s-icon {
  opacity: 0.7;
}

.s-title {
  font-size: 14px;
}

.s-sub {
  font-size: 12px;
  color: var(--muted);
}

.ifr-badge {
  color: var(--primary);
  font-weight: 600;
}

/* ============================================================
   IMAGE FEED
   ============================================================ */
.image-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.image-feed img {
  width: 360px;
  border-radius: 12px;
  cursor: zoom-in;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: color-mix(in oklab, #000 60%, transparent);
  z-index: 9999;
}

.modal.open {
  display: grid;
}

.modal-inner {
  position: relative;
  max-width: 96vw;
  max-height: 92vh;
}

.modal-img {
  max-width: 96vw;
  max-height: 92vh;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 1px solid var(--line);
  background: color-mix(in oklab, var(--surface) 70%, transparent);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
}

body.no-scroll {
  overflow: hidden;
}

.two-col {
  display: grid;
  grid-template-columns: 45% 50%;
  gap: 20px;
  align-items: start;
  width: 100%;
  overflow: hidden;
}

.cards-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch; /* eller flex-start, båda funkar */
}

.right-column {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 12px;
}

#eshkImages img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  border-radius: 12px;
  object-fit: cover;
}
@media (max-width: 980px) {
  .two-col {
    grid-template-columns: 1fr;
  }

  #eshkImages {
    margin-top: 12px;
  }
}
.cards.single .card {
  height: auto;
}
