/* =========================================================
   VK2FR - Live Dashboard (style.css)
   Theme: gunmetal / white / lime accents
========================================================= */

/* -------------------------
   Base + Theme Tokens
------------------------- */
:root{
  --bg: #0f1418;
  --surface: #151c22;
  --surface-2: #1a232b;
  --border: rgba(255,255,255,.08);

  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.62);

  --lime: #a6ff3b;
  --lime-2: #73ff1a;
  --danger: #ff4d4d;
  --warn: #ffcc66;

  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 18px;

  --max: 1180px;
  --gap: 16px;

  --font: "Roboto", system-ui, -apple-system, Segoe UI, Arial, sans-serif;

  /* Vars used by modal/pills */
  --card: var(--surface);
  --accent: var(--lime);
  --pill-bg: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  --pill-text: rgba(255,255,255,.90);
}

/* Light mode if theme-dark removed */
:root:not(.theme-dark){
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --border: rgba(16,24,32,.10);

  --text: rgba(16,24,32,.92);
  --muted: rgba(16,24,32,.62);

  --shadow: 0 10px 24px rgba(16,24,32,.10);

  --pill-text: rgba(16,24,32,.92);
  --card: #ffffff;

  /* tuned light-theme lime so it reads well on white */
  --lime: #5ea814;
  --lime-2: #4c8f0f;
}

/* -------------------------
   Global
------------------------- */
*{ box-sizing: border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 700px at 20% -10%, rgba(166,255,59,.10), transparent 55%),
    radial-gradient(900px 600px at 95% 0%, rgba(59,130,246,.10), transparent 60%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img{ max-width:100%; display:block; }
a{ color: inherit; text-decoration: none; }
a:hover{ text-decoration: none; }
button, input{ font-family: var(--font); }

.muted{ color: var(--muted); }
.small{ font-size: 12px; }

/* =========================================================
   HEADER / TOPBAR
   - Width now matches cards/grid below
   - Supports improved header markup
========================================================= */
.dashboard-header{
  position: relative;
  max-width: var(--max);
  margin: 18px auto 10px;
  padding: 0 14px;
}

.dashboard-header::before{
  content:"";
  position:absolute;
  left:14px;
  right:14px;
  top:-1px;
  height:1px;
  background: linear-gradient(90deg, transparent, rgba(166,255,59,.18), transparent);
  pointer-events:none;
}

.header-shell{
  display:flex;
  flex-direction:column;
  gap:14px;
}

.header-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  flex-wrap:wrap;
}

.header-row-left,
.header-row-right{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  min-height:48px;
}

.brand-logo{
  height: 110px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.25));
}

.header-actions{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;
}

/* Pills */
.qrz-link-pill,
.online-pill,
.theme-toggle,
.weather-pill{
  min-height:42px;
  border-radius:999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.qrz-link-pill{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding: 10px 14px;
  background: var(--pill-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
  color: var(--pill-text);
}
.qrz-link-pill:hover{
  transform: translateY(-1px);
  border-color: rgba(166,255,59,.35);
}

.qrz-dot{
  width:10px; height:10px; border-radius:50%;
  background: var(--lime);
  box-shadow: 0 0 0 6px rgba(166,255,59,.12);
}
.qrz-text{ font-weight: 700; letter-spacing: .2px; }

.online-pill{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--pill-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.online-pill:hover{
  transform: translateY(-1px);
  border-color: rgba(166,255,59,.35);
}
.online-heart{ color: var(--danger); }
.online-count{
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  text-align:center;
  font-weight: 900;
  font-size: 13px;
  color: var(--lime);
  background: rgba(166,255,59,.12);
}

.theme-toggle{
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--text);
  padding: 10px 12px;
  cursor:pointer;
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.theme-toggle:hover{
  transform: translateY(-1px);
  border-color: rgba(166,255,59,.35);
}

/* Weather pill */
.weather-pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 10px 14px;
  background: var(--pill-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-weight: 900;
  color: rgba(229,231,235,0.95);
  transition: background .25s ease, border-color .25s ease, transform .15s ease, box-shadow .15s ease;
}
.weather-pill:hover{
  transform: translateY(-1px);
  border-color: rgba(166,255,59,.35);
}
.weather-icon{
  font-size: 16px;
  line-height: 1;
}
.weather-temp{
  font-size: 14px;
  letter-spacing: .3px;
}
.weather-wind{
  margin-left: 2px;
  font-weight: 800;
  opacity: .9;
  font-size: 12px;
  white-space: nowrap;
}

/* temp bands */
.weather-pill.wx-cold{
  background: rgba(59,130,246,0.16);
  border-color: rgba(59,130,246,0.30);
}
.weather-pill.wx-mild{
  background: rgba(34,197,94,0.14);
  border-color: rgba(34,197,94,0.28);
}
.weather-pill.wx-warm{
  background: rgba(245,158,11,0.16);
  border-color: rgba(245,158,11,0.30);
}
.weather-pill.wx-hot{
  background: rgba(239,68,68,0.16);
  border-color: rgba(239,68,68,0.32);
}

/* light theme header polish */
:root:not(.theme-dark) .qrz-link-pill,
:root:not(.theme-dark) .online-pill,
:root:not(.theme-dark) .theme-toggle,
:root:not(.theme-dark) .weather-pill{
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(241,244,248,.96));
  border-color: rgba(16,24,32,.12);
  color: rgba(16,24,32,.92);
}
:root:not(.theme-dark) .qrz-link-pill:hover,
:root:not(.theme-dark) .online-pill:hover,
:root:not(.theme-dark) .theme-toggle:hover,
:root:not(.theme-dark) .weather-pill:hover{
  border-color: rgba(94,168,20,.30);
}
:root:not(.theme-dark) .qrz-dot,
:root:not(.theme-dark) .live-dot{
  box-shadow: 0 0 0 6px rgba(94,168,20,.12);
}
:root:not(.theme-dark) .weather-pill.wx-cold{
  background: rgba(59,130,246,.12);
  border-color: rgba(59,130,246,.22);
}
:root:not(.theme-dark) .weather-pill.wx-mild{
  background: rgba(34,197,94,.12);
  border-color: rgba(34,197,94,.22);
}
:root:not(.theme-dark) .weather-pill.wx-warm{
  background: rgba(245,158,11,.14);
  border-color: rgba(245,158,11,.24);
}
:root:not(.theme-dark) .weather-pill.wx-hot{
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.24);
}

/* -------------------------
   Topbar
------------------------- */
.topbar{
  margin-top: 2px;
  background:
    radial-gradient(circle at top right, rgba(166,255,59,.08), transparent 28%),
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 16px;
  display:grid;
  grid-template-columns: minmax(260px, 1.05fr) minmax(320px, 1.3fr) minmax(280px, .95fr);
  gap: 16px;
  align-items:stretch;
  overflow:hidden;
}
:root:not(.theme-dark) .topbar{
  background:
    radial-gradient(circle at top right, rgba(94,168,20,.06), transparent 28%),
    #ffffff;
}

.topbar-left,
.topbar-mid,
.topbar-right{
  min-width:0;
}

.topbar-left{
  display:flex;
  gap: 14px;
  align-items:center;
  padding: 12px;
  border-radius: 20px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.05);
}
:root:not(.theme-dark) .topbar-left{
  background: rgba(16,24,32,.025);
  border-color: rgba(16,24,32,.06);
}

.avatar{
  width: 64px;
  height: 64px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  object-fit: cover;
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.24);
}

.topbar-title{
  min-width:0;
}

.callsign{
  font-weight: 900;
  letter-spacing: .06em;
  font-size: 28px;
  line-height: 1;
  margin-bottom: 6px;
}
.tagline{
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  letter-spacing: .02em;
}

.topbar-mid{
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.05);
}
:root:not(.theme-dark) .topbar-mid{
  background: linear-gradient(180deg, rgba(16,24,32,.025), rgba(16,24,32,.015));
  border-color: rgba(16,24,32,.06);
}

.live-row{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap:wrap;
}
.live-dot{
  width:10px; height:10px; border-radius:50%;
  background: var(--lime);
  box-shadow: 0 0 0 7px rgba(166,255,59,.12);
}
.live-text{
  font-weight: 900;
  letter-spacing: 2px;
  font-size: 12px;
  color: var(--lime);
}
.live-status-note{
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .02em;
}

.freq{
  display:flex;
  align-items:flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width:0;
}

.freq-readout{
  display:flex;
  align-items:baseline;
  gap: 8px;
  min-width:0;
  margin-right: 4px;
}

.freq-big{
  font-size: clamp(34px, 4.3vw, 56px);
  font-weight: 900;
  letter-spacing: .3px;
  line-height: .92;
  text-shadow: 0 0 18px rgba(166,255,59,.10);
}
.freq-big.is-breathing{
  animation: freqBreath 1.9s ease-in-out infinite;
}

@keyframes freqBreath{
  0%,100%{ opacity:1; transform:translateY(0); }
  50%{ opacity:.86; transform:translateY(-1px); }
}

.freq-unit{
  color: var(--muted);
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 15px;
}

.pill-group{
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
  align-items:center;
  min-width:0;
}

.topbar-right{
  display:grid;
  grid-template-columns:1fr;
  gap: 10px;
}

.mini-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap: 10px;
}

.mini{
  background: rgba(0,0,0,.10);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 14px;
  min-width:0;
}
:root:not(.theme-dark) .mini{
  background: rgba(16,24,32,.04);
}

.mini-label{
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.mini-value{
  margin-top: 0;
  font-weight: 900;
  font-size: 18px;
  line-height: 1.15;
  white-space: nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.mini-sub{
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.solar-k-inline{
  opacity: .72;
  font-weight: 700;
  margin-left: 4px;
}

.solar-strip{
  display:grid;
  grid-template-columns:repeat(4, minmax(0,1fr));
  gap: 8px;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.05);
  background: rgba(255,255,255,.025);
}
:root:not(.theme-dark) .solar-strip{
  border-color: rgba(16,24,32,.06);
  background: rgba(16,24,32,.02);
}

.solar-chip{
  min-width:0;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.04);
  text-align:center;
}
:root:not(.theme-dark) .solar-chip{
  background: rgba(16,24,32,.025);
  border-color: rgba(16,24,32,.06);
}

.solar-chip-label{
  display:block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}
.solar-chip-value{
  display:block;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.topbar.onair-stale{
  opacity:.92;
}
.topbar.onair-stale .freq-big{
  opacity:.65;
}
.topbar.onair-stale .live-dot{
  background:#9ca3af;
  box-shadow:none;
}

.pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
  min-height: 30px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.12);
  font-weight: 900;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
:root:not(.theme-dark) .pill{
  background: rgba(16,24,32,.06);
  color: rgba(16,24,32,.88);
}
.pill-mode{
  color: var(--lime);
  background: rgba(166,255,59,.11);
  border-color: rgba(166,255,59,.22);
}
.pill-band{
  color: rgba(255,255,255,.88);
  background: rgba(0,194,255,.10);
  border-color: rgba(0,194,255,.20);
}
:root:not(.theme-dark) .pill-band{ color: rgba(16,24,32,.88); }

.pill.source{
  background: #e5e7eb;
  color: #374151;
}

.pill.tx{
  background: #dc2626;
  color: #fff;
  font-weight: 700;
}
.pill.tx.tx{
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.6; }
  100% { opacity: 1; }
}

/* Status bubble */
.topbar-status{
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
:root:not(.theme-dark) .topbar-status{
  background: #ffffff;
}
.topbar-status-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.topbar-status-bubble{
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  padding: 12px 12px;
}
:root:not(.theme-dark) .topbar-status-bubble{
  background: linear-gradient(180deg, rgba(16,24,32,.03), rgba(16,24,32,.015));
  border-color: rgba(16,24,32,.10);
}
.status-text{ font-size: 14px; line-height: 1.45; }
.status-meta{ margin-top: 8px; font-size: 12px; }
.status-pill{
  color: var(--lime);
  background: rgba(166,255,59,.12);
  border-color: rgba(166,255,59,.25);
}
:root:not(.theme-dark) .status-pill{
  background: rgba(94,168,20,.10);
  border-color: rgba(94,168,20,.22);
}

/* Mobile / tablet header */
@media (max-width: 1180px){
  .topbar{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px){
  .brand-logo{ height: 56px; }

  .header-actions{
    justify-content:flex-start;
  }

  .topbar{
    grid-template-columns: 1fr;
  }

  .card-large{ grid-column: span 12; }
}

@media (max-width: 760px){
  .dashboard-header{
    padding: 0 12px;
    margin-top: 14px;
  }

  .dashboard-header::before{
    left:12px;
    right:12px;
  }

  .topbar{
    padding: 12px;
    gap: 12px;
    border-radius: 20px;
  }

  .topbar-left,
  .topbar-mid{
    padding: 12px;
  }

  .avatar{
    width: 56px;
    height: 56px;
    border-radius: 16px;
  }

  .callsign{
    font-size: 24px;
  }

  .mini-grid{
    grid-template-columns: 1fr;
  }

  .solar-strip{
    grid-template-columns: repeat(2, minmax(0,1fr));
  }

  .freq{
    align-items:flex-start;
  }

  .freq-readout{
    width:100%;
  }

  .freq-big{
    font-size: clamp(30px, 9vw, 42px);
  }
}

@media (max-width: 520px){
  .header-actions{
    width:100%;
  }

  .qrz-link-pill,
  .online-pill,
  .weather-pill{
    width:100%;
    justify-content:center;
  }

  .theme-toggle{
    width:100%;
    justify-content:center;
  }

  .solar-strip{
    grid-template-columns: 1fr 1fr;
  }

  .freq-unit{
    font-size: 13px;
  }
}

/* -------------------------
   Main Grid
------------------------- */
.dashboard-grid{
  max-width: var(--max);
  margin: 12px auto 0;
  padding: 0 14px 16px;
  display:grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
  grid-auto-rows: auto;
  align-self: start;
}

/* Cards */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  overflow: hidden;
  height: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-self: start;
  min-width: 0;
}
:root:not(.theme-dark) .card{
  background: #ffffff;
}
.card h2{
  margin: 0 0 8px;
  font-size: 16px;
  letter-spacing: .2px;
}
.card-large{ grid-column: span 6; }

@media (max-width: 980px){
  .card-large{ grid-column: span 12; }
}

/* Station configuration layout */
.station-grid{
  display:grid;
  gap:14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 900px){
  .station-grid{ grid-template-columns: 1fr; }
}
.station-block{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  border-radius: 14px;
  padding: 12px;
}
:root:not(.theme-dark) .station-block{
  background: rgba(16,24,32,.025);
  border-color: rgba(16,24,32,.10);
}
.station-block-title{
  font-weight: 900;
  margin-bottom: 10px;
}
.station-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 7px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.08);
}
:root:not(.theme-dark) .station-row{
  border-bottom-color: rgba(16,24,32,.08);
}
.station-row:last-child{ border-bottom: 0; }

/* Latest QSOs */
.qso-list{
  list-style:none;
  padding: 0;
  margin: 12px 0 0;
  display:flex;
  flex-direction:column;
  gap: 10px;
}
.qso-list li{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 14px;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  transition: transform .12s ease, border-color .15s ease, opacity .25s ease;
  min-width: 0;
}
:root:not(.theme-dark) .qso-list li{
  background: linear-gradient(180deg, rgba(16,24,32,.03), rgba(16,24,32,.015));
  border-color: rgba(16,24,32,.10);
}
.qso-list li:hover{
  transform: translateY(-1px);
  border-color: rgba(166,255,59,.25);
  opacity: 1 !important;
}
.qso-left{
  display:flex;
  align-items:center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}
.qso-right{
  display:flex;
  flex-direction: column;
  align-items:flex-end;
  gap: 4px;
  flex: 0 0 auto;
  text-align: right;
  min-width: 0;
}

.qso-line1{
  display:flex;
  align-items:center;
  gap: 10px;
  white-space: nowrap;
  min-width: 0;
}
.qso-line2{
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0.85;
}

@media (max-width: 560px){
  .qso-list li{ align-items: flex-start; }
  .qso-right{ align-items: flex-start; text-align: left; }
  .qso-line1, .qso-line2{ white-space: normal; }
}

.qrz-link strong{
  font-weight: 900;
  letter-spacing: .2px;
}
.qrz-link:hover strong{
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(166,255,59,.7);
}

.flag{
  width: 18px;
  height: 13px;
  border-radius: 2px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
  display:inline-block;
}

.new-pill{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  border: 1px solid rgba(34,197,94,0.35);
  background: rgba(34,197,94,0.16);
  color: rgba(229,231,235,0.95);
  transition: opacity 1s ease, transform 1s ease;
}
:root:not(.theme-dark) .new-pill{
  color: var(--lime);
  background: rgba(94,168,20,.10);
  border-color: rgba(94,168,20,.25);
}
.new-pill.is-gone{
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 800ms ease, transform 800ms ease;
}

.age-pill{
  font-size: 11px;
  font-weight: 900;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.18);
}
:root:not(.theme-dark) .age-pill{ background: rgba(16,24,32,.06); }

.age-recent{
  color: var(--lime);
  border-color: rgba(166,255,59,.35);
  background: rgba(166,255,59,.12);
}
:root:not(.theme-dark) .age-recent{
  color: var(--lime);
  border-color: rgba(94,168,20,.25);
  background: rgba(94,168,20,.10);
}
.age-warm{
  color: #ffe08a;
  border-color: rgba(255,224,138,.35);
  background: rgba(255,224,138,.10);
}
:root:not(.theme-dark) .age-warm{
  color: #9a6a00;
  border-color: rgba(154,106,0,.22);
  background: rgba(245,158,11,.10);
}
.age-stale{ color: rgba(255,255,255,.78); }
:root:not(.theme-dark) .age-stale{ color: rgba(16,24,32,.72); }
.age-old{ color: rgba(255,255,255,.62); }
:root:not(.theme-dark) .age-old{ color: rgba(16,24,32,.58); }
.age-unknown{ color: var(--muted); }

/* Latest 5 row fade by age */
#latestQsos li.age-recent{ opacity: 1; }
#latestQsos li.age-warm{ opacity: .88; }
#latestQsos li.age-stale{ opacity: .74; }
#latestQsos li.age-old{ opacity: .58; }
#latestQsos li.age-unknown{ opacity: .92; }

@media (max-width: 560px){
  #latestQsos li.age-warm{ opacity: .92; }
  #latestQsos li.age-stale{ opacity: .82; }
  #latestQsos li.age-old{ opacity: .72; }
}

/* Time / Grayline */
.time-row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px){
  .time-row{ grid-template-columns: 1fr; }
}
.time-block{
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  padding: 12px;
}
:root:not(.theme-dark) .time-block{
  background: linear-gradient(180deg, rgba(16,24,32,.03), rgba(16,24,32,.015));
  border-color: rgba(16,24,32,.10);
}
.time-label{ color: var(--muted); font-size: 12px; font-weight: 700; }
.time-big{ font-size: 26px; font-weight: 900; margin-top: 6px; }
.time-small{ color: var(--muted); font-size: 12px; margin-top: 4px; }

.grayline{
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(0,0,0,.10);
  padding: 12px;
}
:root:not(.theme-dark) .grayline{ background: rgba(16,24,32,.04); }
.grayline-label{ color: var(--muted); font-size: 12px; font-weight: 800; }
.grayline-status{ margin-top: 6px; font-weight: 900; }
.grayline-small{ margin-top: 6px; color: var(--muted); font-size: 12px; }

/* Flip card */
.flip-card{ perspective: 1200px; }
.flip-inner{
  position: relative;
  transform-style: preserve-3d;
  transition: transform .55s ease;
}
.flip-inner.is-flipped{ transform: rotateY(180deg); }
.flip-face{ backface-visibility: hidden; transform-style: preserve-3d; }
.flip-front{ position: relative; }
.flip-back{ position:absolute; inset:0; transform: rotateY(180deg); }

.card-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 10px;
}
.flip-btn{
  border: 1px solid var(--border);
  background: rgba(0,0,0,.14);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  cursor:pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
:root:not(.theme-dark) .flip-btn{
  background: rgba(16,24,32,.05);
  border-color: rgba(16,24,32,.10);
  color: rgba(16,24,32,.88);
}
.flip-btn:hover{
  border-color: rgba(166,255,59,.25);
  transform: translateY(-1px);
}

/* Solar metric */
.card-solar{ position: relative; overflow: hidden; }
.card-solar::before{
  content:"";
  position:absolute;
  inset:-2px;
  background:
    radial-gradient(900px 320px at 18% 10%, rgba(132,204,22,.18), transparent 55%),
    radial-gradient(700px 260px at 88% 20%, rgba(6,182,212,.14), transparent 55%);
  pointer-events:none;
}

.solar-metric{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.00));
  margin-top: 10px;
}
:root:not(.theme-dark) .solar-metric{
  background: linear-gradient(180deg, rgba(16,24,32,.03), rgba(16,24,32,.015));
  border-color: rgba(16,24,32,.10);
}
.solar-metric span{
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .2px;
  opacity: .85;
}
.solar-metric strong{
  font-size: 22px;
  font-weight: 900;
  letter-spacing: .3px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  min-width: 68px;
  text-align: right;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), 0 4px 14px rgba(0,0,0,.35);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
:root:not(.theme-dark) .solar-metric strong{
  border-color: rgba(16,24,32,.10);
  background: rgba(16,24,32,.03);
  box-shadow: inset 0 0 0 1px rgba(16,24,32,.03), 0 4px 14px rgba(16,24,32,.08);
}
.solar-metric:hover strong{
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.10), 0 8px 22px rgba(0,0,0,.45);
  filter: brightness(1.05);
}
:root:not(.theme-dark) .solar-metric:hover strong{
  box-shadow: inset 0 0 0 1px rgba(16,24,32,.08), 0 8px 18px rgba(16,24,32,.12);
}

/* Tooltip */
.qso-tip{
  position: fixed;
  z-index: 9999;
  max-width: 320px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .12s ease, transform .12s ease;
  background: rgba(0,0,0,.85);
  color: #fff;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
}
:root:not(.theme-dark) .qso-tip{
  background: rgba(255,255,255,.97);
  color: rgba(16,24,32,.94);
  border-color: rgba(16,24,32,.12);
  box-shadow: 0 18px 40px rgba(16,24,32,.14);
}
.qso-tip.is-on{ opacity: 1; transform: translateY(0); }

#qsoTip .tip-title{
  font-weight: 900;
  font-size: 1rem;
  margin-bottom: 4px;
}
#qsoTip .tip-dxcc{
  opacity: 0.8;
  font-weight: 700;
}
#qsoTip .tip-sub{
  font-size: 0.88rem;
  opacity: 0.85;
  margin-top: 2px;
}

/* Guestbook */
.guestbook-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
}
.guestbook-sub{ color: var(--muted); font-size: 12px; margin-top: 2px; }
.guestbook-pill{
  min-width: 44px;
  text-align:center;
  font-weight: 900;
  border-radius: 999px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.12);
  color: var(--lime);
}
:root:not(.theme-dark) .guestbook-pill{
  background: rgba(94,168,20,.10);
  border-color: rgba(94,168,20,.22);
  color: var(--lime);
}

.guestbook-fade{
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  padding: 12px;
}
:root:not(.theme-dark) .guestbook-fade{
  background: linear-gradient(180deg, rgba(16,24,32,.03), rgba(16,24,32,.015));
  border-color: rgba(16,24,32,.10);
}
.guestbook-meta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.guestbook-name{ font-weight: 900; }
.guestbook-date{ color: var(--muted); font-size: 12px; }
.guestbook-message{ line-height: 1.5; }

#guestbookFade{
  transition: opacity 240ms ease, transform 240ms ease;
  opacity: 1;
  transform: translateY(0);
}
#guestbookFade.gb-fading{
  opacity: 0;
  transform: translateY(4px);
}

/* DX MAP */
.dx-map-wrap{
  position: relative;
  height: 320px;
  border-radius: 14px;
  overflow: hidden;
}
#dxMap{
  height: 100%;
  width: 100%;
  z-index: 1;
  border: 1px solid var(--border);
  background: var(--surface-2);
  position: relative;
}

/* Leaflet UI */
.leaflet-container{ font-family: var(--font); border-radius: 14px; }
:root.theme-dark .leaflet-control-attribution,
:root.theme-dark .leaflet-control-zoom a{
  background: rgba(0,0,0,.55) !important;
  color: rgba(255,255,255,.85) !important;
  border-color: rgba(255,255,255,.12) !important;
}
:root.theme-dark .leaflet-control-zoom a:hover{
  background: rgba(0,0,0,.70) !important;
}
:root:not(.theme-dark) .leaflet-control-attribution,
:root:not(.theme-dark) .leaflet-control-zoom a{
  background: rgba(255,255,255,.94) !important;
  color: rgba(16,24,32,.85) !important;
  border-color: rgba(16,24,32,.12) !important;
}
:root:not(.theme-dark) .leaflet-control-zoom a:hover{
  background: rgba(241,244,248,.98) !important;
}

/* =========================
   DX MAP LEGEND
========================= */
.dx-map-legend{
  margin-top: 12px;
  display: flex;
  justify-content: flex-start;
}

.dx-map-legend .legend-card{
  width: 100%;
  max-width: 520px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}

.theme-dark .dx-map-legend .legend-card{
  background: rgba(17,24,39,0.75);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 14px 40px rgba(0,0,0,0.45);
}
:root:not(.theme-dark) .dx-map-legend .legend-card{
  background: rgba(255,255,255,.96);
  border-color: rgba(16,24,32,.10);
  box-shadow: 0 10px 30px rgba(16,24,32,.10);
}

.dx-map-legend .legend-title{
  display:flex;
  align-items:center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.dx-map-legend .legend-title strong{
  font-weight: 900;
}
.dx-map-legend .legend-note{
  font-size: 12px;
  opacity: .75;
}

.dx-map-legend .legend-grid{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dx-map-legend .legend-pill{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.7);
}

.theme-dark .dx-map-legend .legend-pill{
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.14);
}
:root:not(.theme-dark) .dx-map-legend .legend-pill{
  background: rgba(16,24,32,.03);
  border-color: rgba(16,24,32,.10);
  color: rgba(16,24,32,.88);
}

.dx-map-legend .legend-dot{
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Legend outside map */
.dx-legend-out{
  margin-top: 10px;
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
  align-items:center;
}

.dx-legend-out .legend-pill{
  display:inline-flex;
  align-items:center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
}
:root:not(.theme-dark) .dx-legend-out .legend-pill{
  background: linear-gradient(180deg, rgba(16,24,32,.03), rgba(16,24,32,.015));
  border-color: rgba(16,24,32,.10);
}

.dx-legend-out .legend-dot{
  width: 10px;
  height: 10px;
  border-radius: 99px;
  display:inline-block;
}

.dx-legend-row{
  margin-top: 10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  flex-wrap:wrap;
}

.dx-limit{
  display:flex;
  gap: 8px;
  align-items:center;
}

.dx-limit-btn{
  appearance: none;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 900;
  font-size: 12px;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, filter .12s ease;
}
:root:not(.theme-dark) .dx-limit-btn{
  background: rgba(16,24,32,.05);
  border-color: rgba(16,24,32,.10);
  color: rgba(16,24,32,.88);
}
.dx-limit-btn:hover{
  transform: translateY(-1px);
  border-color: rgba(166,255,59,.25);
  filter: brightness(1.05);
}
.dx-limit-btn.is-on{
  border-color: rgba(166,255,59,.35);
  background: rgba(166,255,59,.12);
  color: var(--lime);
}
:root:not(.theme-dark) .dx-limit-btn.is-on{
  background: rgba(94,168,20,.10);
  border-color: rgba(94,168,20,.24);
  color: var(--lime);
}

/* =========================================================
   MODALS (Say Hi + QSL)
========================================================= */
.modal{
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  display: none !important;
}
.modal.is-on{ display:block !important; }

.modal-backdrop{
  position:absolute !important;
  inset:0 !important;
  background: rgba(0,0,0,0.55) !important;
  backdrop-filter: blur(6px) !important;
}

.modal-card{
  position: relative !important;
  width: min(560px, calc(100vw - 24px)) !important;
  margin: 10vh auto 0 !important;
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 18px !important;
  box-shadow: 0 30px 90px rgba(0,0,0,0.35) !important;
  overflow: hidden !important;
}

.modal-head{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-title{
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 0.2px;
}
.modal-sub{ margin-top: 3px; font-size: 13px; }
.modal-x{
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 8px 10px;
  border-radius: 10px;
}
.modal-x:hover{ background: rgba(17,24,39,0.06); }

.modal-body{
  padding: 14px 16px 16px;
  display: grid;
  gap: 12px;
}

.field{
  display:flex;
  flex-direction:column;
  gap: 6px;
}
.field-label{
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.field input{
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.16);
  color: var(--text);
  padding: 12px 12px;
  outline: none;
}
:root:not(.theme-dark) .field input{ background: rgba(16,24,32,.05); }
.field input:focus{
  border-color: rgba(166,255,59,.35);
  box-shadow: 0 0 0 4px rgba(166,255,59,.12);
}

.check-row{
  display:flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
}
.check-row input{
  margin-top: 3px;
  accent-color: var(--accent);
}

.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap: 10px;
  margin-top: 6px;
}

.btn-primary{
  border: 1px solid rgba(166,255,59,.35);
  background: linear-gradient(180deg, rgba(166,255,59,.22), rgba(166,255,59,.12));
  color: var(--text);
  font-weight: 900;
  letter-spacing: .2px;
  border-radius: 14px;
  padding: 12px 14px;
  cursor:pointer;
  box-shadow: 0 12px 28px rgba(0,0,0,.28);
  transition: transform .12s ease, filter .12s ease;
}
:root:not(.theme-dark) .btn-primary{
  background: linear-gradient(180deg, rgba(94,168,20,.16), rgba(94,168,20,.09));
  border-color: rgba(94,168,20,.28);
  color: rgba(16,24,32,.92);
  box-shadow: 0 10px 24px rgba(16,24,32,.10);
}
.btn-primary:hover{ transform: translateY(-1px); filter: brightness(1.05); }

.btn-secondary{
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--pill-text);
  font-weight: 900;
  cursor: pointer;
}
:root:not(.theme-dark) .btn-secondary{
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(241,244,248,.96));
  border-color: rgba(16,24,32,.12);
  color: rgba(16,24,32,.92);
}

.modal-msg{
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(17,24,39,0.03);
}
.theme-dark .modal-msg{ background: rgba(255,255,255,0.04); }

/* Say Hi animation */
@keyframes hi-throb {
  0%   { transform: scale(1);    box-shadow: 0 0 0 rgba(34, 197, 94, 0); }
  50%  { transform: scale(1.06); box-shadow: 0 0 18px rgba(34, 197, 94, 0.55); }
  100% { transform: scale(1);    box-shadow: 0 0 0 rgba(34, 197, 94, 0); }
}
.hi-pill{ animation: hi-throb 2.4s ease-in-out infinite; }
@keyframes hi-dot { 0%,100%{opacity:.6} 50%{opacity:1} }
.hi-pill .qrz-dot{ animation: hi-dot 2.4s ease-in-out infinite; }

/* Footer */
.site-footer{
  margin-top: 34px;
  padding: 18px 22px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(12,18,24,0.55), rgba(8,12,18,0.82));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

:root:not(.theme-dark) .site-footer{
  border-top: 1px solid rgba(16,24,32,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.78), rgba(241,244,248,.94));
  color: rgba(16,24,32,.92);
}

.footer-inner{
  max-width: var(--max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.2fr auto auto;
  align-items: center;
  gap: 18px;
}

@media (max-width: 980px){
  .footer-inner{
    grid-template-columns: 1fr;
    gap: 14px;
    text-align: center;
  }
}

.footer-left{
  min-width: 0;
}

.footer-brand{
  font-weight: 800;
  letter-spacing: 0.35px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

@media (max-width: 980px){
  .footer-brand{
    justify-content: center;
  }
}

.footer-callsign{
  font-size: 15px;
}

.footer-title{
  font-size: 14px;
  opacity: 0.82;
}

.footer-sep{
  opacity: 0.35;
}

.footer-small{
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
}

.footer-version{
  opacity: 0.62;
  font-weight: 500;
  letter-spacing: 0.25px;
}

:root:not(.theme-dark) .footer-small,
:root:not(.theme-dark) .footer-version,
:root:not(.theme-dark) .footer-title{
  color: rgba(16,24,32,.62);
  opacity: 1;
}

.footer-stats{
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}

:root:not(.theme-dark) .footer-stats{
  background: rgba(16,24,32,.035);
  border-color: rgba(16,24,32,.08);
}

@media (max-width: 980px){
  .footer-stats{
    justify-content: center;
    margin: 0 auto;
  }
}

.footer-stat{
  text-align: center;
  min-width: 74px;
}

.footer-stat-label{
  font-size: 10px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  opacity: 0.58;
  margin-bottom: 2px;
}

.footer-stat-value{
  font-size: 14px;
  font-weight: 800;
}

.footer-divider{
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.10);
}

:root:not(.theme-dark) .footer-divider{
  background: rgba(16,24,32,.10);
}

.footer-right{
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 980px){
  .footer-right{
    justify-content: center;
  }
}

.footer-btn{
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  transition: background .2s ease, border-color .2s ease, transform .15s ease;
}

.footer-btn:hover{
  background: rgba(255,255,255,0.10);
  border-color: rgba(166,255,59,.22);
  transform: translateY(-1px);
}

.footer-btn.ghost{
  background: transparent;
}

:root:not(.theme-dark) .footer-btn{
  background: rgba(16,24,32,.04);
  border-color: rgba(16,24,32,.08);
  color: rgba(16,24,32,.92);
}

:root:not(.theme-dark) .footer-btn:hover{
  background: rgba(16,24,32,.08);
  border-color: rgba(94,168,20,.22);
}

:root:not(.theme-dark) .footer-btn.ghost{
  background: transparent;
  border-color: rgba(16,24,32,.10);
}

/* Utility */
hr{
  border:0;
  border-top:1px solid var(--border);
  margin: 12px 0;
}

/* =========================================================
   TOASTS (Say Hi popup notifications)
========================================================= */
.toast-host{
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast{
  width: min(360px, calc(100vw - 32px));
  background: rgba(17, 24, 39, 0.88);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  padding: 12px 12px 10px;
  color: rgba(255,255,255,.92);

  opacity: 0;
  transform: translateY(10px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

:root:not(.theme-dark) .toast{
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(16,24,32,0.12);
  color: rgba(16,24,32,.92);
  box-shadow: 0 18px 40px rgba(16,24,32,.12);
}

.toast.is-on{
  opacity: 1;
  transform: translateY(0);
}

.toast-top{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toast-title{
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  letter-spacing: .2px;
  line-height: 1.25;
}

.toast-flag{
  width: 18px;
  height: 13px;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.20);
  flex: 0 0 auto;
}

:root:not(.theme-dark) .toast-flag{
  border: 1px solid rgba(16,24,32,0.16);
}

.toast-flag img{
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.toast-sub{
  margin-top: 6px;
  font-size: 13px;
  color: rgba(255,255,255,.72);
  line-height: 1.35;
}

:root:not(.theme-dark) .toast-sub{
  color: rgba(16,24,32,.70);
}

/* =========================================================
   FIX: Latest 5 layout + NEW pill + flag slot + tooltip
========================================================= */
#latestQsos li{
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

#latestQsos .qso-left{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#latestQsos .qso-right{
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 220px;
}

#latestQsos .qso-line1{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

#latestQsos .qso-line2{
  font-size: 12px;
  opacity: 0.72;
}

/* make sure flags have a consistent slot size even before load */
#latestQsos [id^="flag_"]{
  display: inline-flex;
  width: 22px;
  height: 16px;
  align-items: center;
  justify-content: center;
}
#latestQsos img.flag{
  width: 22px;
  height: 16px;
  border-radius: 3px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
:root:not(.theme-dark) #latestQsos img.flag{
  border-color: rgba(16,24,32,.12);
  box-shadow: 0 2px 8px rgba(16,24,32,.10);
}

/* ===============================
   Latest 5 Contacts — Mobile fix
================================ */
@media (max-width: 520px) {
  .qso-list li {
    padding: 14px 14px;
  }

  .qso-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-wrap: wrap;
  }

  .qso-left .qrz-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
  }

  .qso-left .muted {
    display: block;
    width: 100%;
    margin-left: 0;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .qso-right {
    width: 100%;
    margin-top: 10px;
  }

  .qso-line1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: nowrap;
  }

  .qso-line1 > span:first-child {
    min-width: 0;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
  }

  .age-pill {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .qso-line2 {
    margin-top: 6px;
    white-space: normal;
    line-height: 1.25;
  }

  .qso-list .flag {
    width: 22px;
    height: 16px;
    border-radius: 3px;
  }

  .new-pill {
    transform: scale(0.92);
    transform-origin: left center;
  }
}

@media (max-width: 520px) {
  .qso-line1 > span:first-child {
    font-size: 15px;
    letter-spacing: 0.2px;
  }
}

@media (max-width: 520px) {
  .qso-list li {
    padding-top: 12px;
    padding-bottom: 12px;
  }
}

.dashboard-grid { align-items: start; }
.dashboard-grid > * { align-self: start; }

/* =========================================================
   DESKTOP MASONRY (removes the “grid gaps”)
   - Keeps mobile the same
========================================================= */
@media (min-width: 981px){
  body:not(.admin-page) .dashboard-grid{
    display: block;
    column-count: 2;
    column-gap: var(--gap);
  }

  body:not(.admin-page) .dashboard-grid > .card{
    break-inside: avoid;
    margin: 0 0 var(--gap);
    width: 100%;
    display: inline-block;
  }

  body:not(.admin-page) .card-large{
    grid-column: auto;
  }
}

/* =========================================================
   MOBILE DASHBOARD REPAIR
   - stack everything cleanly on phones
   - prevents narrow collapsed columns/strips
========================================================= */
@media (max-width: 980px){
  .dashboard-grid{
    display: grid;
    grid-template-columns: 1fr !important;
    gap: var(--gap);
  }

  .dashboard-grid > .card,
  .dashboard-grid > *{
    width: 100%;
    min-width: 0;
    max-width: 100%;
    grid-column: 1 / -1 !important;
    display: flex;
    align-self: start;
  }

  .card,
  .card-large{
    grid-column: 1 / -1 !important;
  }
}

/* Search */
.search-row{
  display:flex;
  gap:10px;
  align-items:center;
  margin-top: 10px;
}
.search-input{
  flex: 1 1 auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.16);
  color: var(--text);
  padding: 12px 12px;
  outline: none;
  min-width: 0;
}
:root:not(.theme-dark) .search-input{ background: rgba(16,24,32,.05); }
.search-input:focus{
  border-color: rgba(166,255,59,.35);
  box-shadow: 0 0 0 4px rgba(166,255,59,.12);
}

.search-btn{
  flex: 0 0 auto;
  border: 1px solid rgba(166,255,59,.35);
  background: linear-gradient(180deg, rgba(166,255,59,.22), rgba(166,255,59,.12));
  color: var(--text);
  font-weight: 900;
  letter-spacing: .2px;
  border-radius: 14px;
  padding: 12px 14px;
  cursor:pointer;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  transition: transform .12s ease, filter .12s ease;
}
:root:not(.theme-dark) .search-btn{
  background: linear-gradient(180deg, rgba(94,168,20,.16), rgba(94,168,20,.09));
  border-color: rgba(94,168,20,.28);
  color: rgba(16,24,32,.92);
  box-shadow: 0 10px 24px rgba(16,24,32,.10);
}
.search-btn:hover{ transform: translateY(-1px); filter: brightness(1.05); }

@media (max-width:560px){
  .search-row{ flex-direction: column; align-items: stretch; }
}

/* Search modal rows */
.search-rows{
  display: grid;
  gap: 10px;
}

.search-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  min-width: 0;
}
:root:not(.theme-dark) .search-row{
  background: linear-gradient(180deg, rgba(16,24,32,.03), rgba(16,24,32,.015));
  border-color: rgba(16,24,32,.10);
}

.search-k{
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .2px;
}
.search-v{
  font-weight: 900;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#lastQsoCall{
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}