/* Connectivity diagnostics page. Tokens (light + dark), header/footer, hero, panels and the
   base .btn live in theme.css, shared with the SRV checker. See STYLES.md and HEADER-FOOTER.md. */

  main{
    width:100%;
    max-width: 680px;
    padding: 32px 20px 64px;
    display:flex;
    flex-direction:column;
    align-items:center;
  }

  .panel-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .panel-title{
    font-size: 13px;
    font-weight:600;
    text-transform:uppercase;
    letter-spacing:0.06em;
    color: var(--muted);
  }

  /* region selector */

  .region-select{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    width:100%;
    margin-bottom: 16px;
  }

  .region-btn{
    flex: 1 1 0;
    appearance:none;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-family: inherit;
    font-weight:500;
    font-size: 14px;
    padding: 12px 10px;
    border-radius: 12px;
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
  }

  .region-btn:hover{
    background: var(--hover);
  }

  .region-btn.active{
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
  }

  .region-btn .flag{
    font-size: 16px;
    line-height:1;
  }

  /* legend */

  .legend{
    display:flex;
    gap: 14px;
    flex-wrap: wrap;
  }

  .legend-item{
    display:flex;
    align-items:center;
    gap:6px;
    font-size: 12px;
    font-weight:500;
    color: var(--text);
  }

  /* service rows */

  .card{
    width:100%;
    padding: 6px;
  }

  .service-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding: 14px 12px;
    border-radius: 12px;
    transition: background 0.2s ease;
    gap: 12px;
  }

  .service-row + .service-row{
    margin-top: 4px;
  }

  .service-row:hover{
    background: var(--hover);
  }

  .service-name{
    display:flex;
    flex-direction:column;
    gap: 2px;
    font-weight:500;
    font-size: 15px;
    color: var(--text);
    flex: 0 0 140px;
    width: 140px;
    min-width: 0;
  }

  .service-name .desc{
    font-size: 12px;
    font-weight:400;
    color: var(--muted);
  }

  .spark{
    flex: 0 0 200px;
    width: 200px;
    height: 44px;
    opacity: 0.9;
  }

  .status{
    display:flex;
    align-items:center;
    gap:10px;
    font-weight:600;
    font-size: 14px;
    /* fixed width, icon at the left edge, so the icons form one column however wide the number is */
    flex: 0 0 140px;
    width: 140px;
    justify-content:space-between;
  }

  .status-icon{ font-size: 18px; }
  .status-icon.good{ color: var(--ok); }
  .status-icon.warn{ color: var(--warn); }
  .status-icon.error{ color: var(--error); }
  .status-icon.running{ color: var(--muted); }

  .status .value{
    font-variant-numeric: tabular-nums;
  }

  .status .range{
    display:block;
    font-size: 11px;
    font-weight:400;
    color: var(--muted);
    text-align:right;
    font-variant-numeric: tabular-nums;
  }

  .status-text{
    display:flex;
    flex-direction:column;
    align-items:flex-end;
  }

  .status.pending .value{ color: var(--muted); font-weight:400; }
  .status.good .value{ color: var(--ok); }
  .status.warn .value{ color: var(--warn); }
  .status.error .value{ color: var(--error); }

  .placeholder{
    color: var(--muted);
    font-size: 14px;
    text-align:center;
    padding: 24px 12px;
    line-height:1.6;
  }

  .spinner{
    width:14px;
    height:14px;
    border-radius:50%;
    border: 2px solid var(--loader-track);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
    flex-shrink:0;
  }

  @keyframes spin{
    to{ transform: rotate(360deg); }
  }

  /* overall summary */

  .overall{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 12px;
  }

  .overall-badge{
    display:flex;
    align-items:center;
    gap:10px;
    font-weight:600;
    font-size: 16px;
  }

  .overall-badge .status-icon{
    font-size: 24px;
  }

  .overall-help{
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 13px;
    line-height: 1.55;
  }

  .overall-help strong{ color: var(--text); font-weight: 600; }

  .spark-key{
    padding: 10px 12px 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
  }

  .spark-key__dash{
    display: inline-block;
    width: 18px;
    vertical-align: middle;
    border-top: 1px dashed var(--faint);
  }

  .overall-note{
    color: var(--muted);
    font-size: 13px;
  }

  .actions{
    display:flex;
    justify-content:center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
  }

  .btn.secondary{
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
  }

  .btn.secondary:hover{
    background: var(--hover);
    box-shadow:none;
  }

  .btn.text-small{
    padding: 8px 14px;
    font-size: 12px;
  }

  .copy-feedback{
    font-size: 12px;
    color: var(--ok);
    text-align:center;
    margin-top: 8px;
    min-height: 16px;
  }

  /* history */

  .history-list{
    display:flex;
    flex-direction:column;
    gap: 6px;
  }

  .history-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--surface-2);
    font-size: 13px;
    cursor:pointer;
  }

  .history-details{
    display:none;
    flex-direction:column;
    gap: 4px;
    padding: 4px 12px 12px;
    margin-top: -4px;
    border-radius: 0 0 10px 10px;
    background: var(--surface-2);
  }

  .history-details.open{
    display:flex;
  }

  .history-detail-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    font-size: 12px;
    color: var(--muted);
    gap: 10px;
  }

  .history-detail-row .name{
    color: var(--text);
  }

  .history-detail-row .stats{
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .history-left{
    display:flex;
    align-items:center;
    gap:10px;
    color: var(--text);
    min-width:0;
  }

  .history-left .flag{
    font-size: 15px;
  }

  .history-time{
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
  }

  .history-right{
    display:flex;
    align-items:center;
    gap: 8px;
    flex: 0 0 auto;
  }

  .history-empty{
    color: var(--muted);
    font-size: 13px;
    text-align:center;
    padding: 12px;
  }

  .history-header-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
  }

  /* header mode toggle: both modes always shown, the current one filled lime.
     Boxed like the footer's theme toggle, with the 44px touch targets of HEADER-FOOTER.md */

  .mode-toggle{
    display:inline-flex;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
  }

  .mode-toggle button{
    display:inline-flex;
    align-items:center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-2);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
  }

  .mode-toggle button:hover{ background: var(--hover); color: var(--text); }
  .mode-toggle button[aria-pressed="true"]{ background: var(--brand); color: var(--brand-text); font-weight: 600; }
  .mode-toggle button:disabled{ cursor: not-allowed; }
  .mode-toggle button:disabled:not([aria-pressed="true"]){ opacity: 0.5; background: transparent; }
  .mode-toggle .material-symbols-outlined{ font-size: 16px; }

  @media (max-width: 560px){
    .mode-toggle button{ padding: 0 10px; font-size: 13px; }
  }

  /* the two modes */

  .view{
    width:100%;
    display:flex;
    flex-direction:column;
    align-items:center;
  }

  /* latency view: one colour per region, readable on white and on navy */

  :root{
    --series-na: #00727f;
    --series-eu: #b4306b;
    --series-uk: #3d6fd1;
    --series-au: #a86400;
  }

  :root[data-theme="dark"]{
    --series-na: #d4ff3a;
    --series-eu: #ff8c66;
    --series-uk: #7fd1ff;
    --series-au: #ffd166;
  }

  /* region names on one line (user request): wider fixed column, still fixed so sparklines line up */
  .latency-row .service-name{
    flex: 0 0 170px;
    width: 170px;
    white-space: nowrap;
  }

  .legend-item{ white-space: nowrap; }

  /* latency legend: its own full-width row under the title, so all four regions fit on one line */
  #latencyLegend{
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  #latencyLegend .legend-item{ gap: 5px; font-size: 11px; }
  #latencyLegend .legend-value{ min-width: 0; }

  .legend-swatch{
    width:8px;
    height:8px;
    border-radius:50%;
  }

  .legend-value{
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    font-weight:400;
    min-width: 44px;
  }

  .live-chart{
    width:100%;
    height: 200px;
    display:block;
  }

  .bar-chart{
    width:100%;
    height: 150px;
    display:block;
  }

  @media (max-width: 560px){
    .service-name{ font-size: 13px; }
    .region-btn{ font-size: 13px; padding: 10px 6px; }
    .spark{ display:none; }
  }
