/* Admin (/admin, pages/admin.py): one screen on desktop and phones. Desktop: tiles in a row, then the three
   panels side by side. Phones: a 2x2 of tiles, then Drop-off / Mistakes / Emails as tabs. Lists scroll inside. */
.ad-page { --ad-gap: 12px; }
.ad-shell { max-width: calc(var(--b-wide, 1100px) + 2 * var(--b-gutter, 24px)); margin: 0 auto; padding: 16px var(--b-gutter, 24px) 16px;
  box-sizing: border-box; height: calc(100svh - 64px); display: flex; flex-direction: column; gap: var(--ad-gap); color: var(--b-text, #e6edf6); }
.ad-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ad-h1 { margin: 2px 0 0; font: 800 26px/1.15 var(--b-font, system-ui, sans-serif); }
.ad-sub, .ad-sub2 { color: var(--b-text-2, #9fb2c8); font-size: 13px; margin: 0; }
.ad-link { color: var(--b-teal, #6AA59C); font-weight: 700; }
.ad-periods { display: flex; gap: 6px; flex-wrap: wrap; }
.ad-pchip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--b-line, #203047); background: var(--b-surface, #0f1b2d); color: var(--b-text-2, #9fb2c8);
  font: 700 13px var(--b-font, system-ui, sans-serif); cursor: pointer; }
.ad-pchip.on { background: var(--b-teal, #6AA59C); border-color: var(--b-teal, #6AA59C); color: #0b1220; }
.ad-upd { display: flex; align-items: center; gap: 8px; }
.ad-ref { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--b-line, #203047); background: none; color: var(--b-text, #e6edf6); cursor: pointer; font-size: 16px; }

.ad-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--ad-gap); }
.ad-tile { background: var(--b-surface, #0f1b2d); border: 1px solid var(--b-line, #203047); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.ad-tile.live { border-color: #4d8077; }
.ad-tile.gold { border-color: #7a6235; }
.ad-tv { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ad-tv b { font: 800 26px/1.1 var(--b-font, system-ui, sans-serif); }
.ad-tl { font-size: 12px; color: var(--b-text-2, #9fb2c8); margin-top: 2px; }
.ad-delta { font-size: 12px; font-weight: 800; color: var(--b-text-2, #9fb2c8); }
.ad-delta.up { color: #6AA59C; } .ad-delta.down { color: #e8964a; }
.ad-live { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #6AA59C; margin-right: 8px; vertical-align: middle;
  box-shadow: 0 0 0 0 rgba(106,165,156,.6); animation: ad-pulse 2s infinite; }
@keyframes ad-pulse { 70% { box-shadow: 0 0 0 8px rgba(106,165,156,0); } 100% { box-shadow: 0 0 0 0 rgba(106,165,156,0); } }

.ad-tabs { display: none; }
.ad-panels { flex: 1; min-height: 0; display: grid; grid-template-columns: 1.1fr 1.1fr .9fr; gap: var(--ad-gap); }
.ad-panel { background: var(--b-surface, #0f1b2d); border: 1px solid var(--b-line, #203047); border-radius: 14px; padding: 12px 14px; min-height: 0;
  display: flex; flex-direction: column; gap: 6px; }
.ad-ph { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ad-ph b { font-size: 15px; }
.ad-dd { width: 170px; font-size: 13px; }
.ad-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.ad-drow { display: grid; grid-template-columns: 34px minmax(0, 1fr) 48px 40px; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.ad-drow.worst .ad-dp { color: #e8964a; font-weight: 800; }
.ad-dl { color: var(--b-text-2, #9fb2c8); font-weight: 700; }
.ad-dbar { height: 10px; border-radius: 999px; background: #16263c; overflow: hidden; }
.ad-dbar i { display: block; height: 100%; background: var(--b-teal, #6AA59C); border-radius: 999px; }
.ad-drow.worst .ad-dbar i { background: #e8964a; }
.ad-dp { text-align: right; font-weight: 700; } .ad-dn { text-align: right; color: var(--b-text-2, #9fb2c8); font-size: 12px; }
.ad-mrow { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid #16263c; font-size: 13px; }
.ad-mi { color: var(--b-text-2, #9fb2c8); font-weight: 800; }
.ad-ml small { display: block; color: var(--b-text-2, #9fb2c8); font-size: 11px; }
.ad-mn { font-weight: 800; }
.ad-empty { color: var(--b-text-2, #9fb2c8); font-size: 13px; }
.ad-etiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ad-etiles .ad-tile { padding: 8px 10px; background: var(--b-bg, #0b1220); }
.ad-etiles .ad-tv b { font-size: 20px; }
.ad-kinds { display: flex; gap: 6px; flex-wrap: wrap; }
.ad-chip { padding: 3px 10px; border-radius: 999px; background: #16263c; font-size: 12px; font-weight: 700; }
.ad-ebtns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: auto; }
.ad-btn { padding: 9px 16px; border-radius: 12px; border: 0; background: var(--b-teal, #6AA59C); color: #0b1220; font: 800 13px var(--b-font, system-ui, sans-serif); cursor: pointer; }
.ad-btn.warn { background: #e8964a; }
.ad-btn.ghost { background: none; border: 1px solid var(--b-line, #203047); color: var(--b-text, #e6edf6); }
.ad-rules { margin: 0; font-size: 11px; color: var(--b-text-3, #6f839b); line-height: 1.5; }

/* Phones: tiles 2x2 (certificates a slim line), the three panels as tabs, one screen above the tab bar */
@media (max-width: 768px) {
  .ad-shell { height: calc(100svh - 126px - env(safe-area-inset-bottom)); padding: 10px 16px 8px; gap: 8px; }
  .ad-top { align-items: center; gap: 8px; }
  .ad-top > div:first-child .b-eyebrow { display: none; }
  .ad-h1 { font-size: 20px; }
  .ad-periods { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; }
  .ad-pchip { padding: 6px 11px; font-size: 12px; flex: none; }
  .ad-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ad-tile { padding: 8px 10px; border-radius: 12px; }
  .ad-tv b { font-size: 20px; }
  .ad-tile.gold { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; padding: 6px 10px; }
  .ad-tile.gold .ad-tl { margin: 0; }
  .ad-tile.gold .ad-tv b { font-size: 16px; }
  .ad-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .ad-tab { padding: 8px 0; border-radius: 10px; border: 1px solid var(--b-line, #203047); background: none; color: var(--b-text-2, #9fb2c8); font: 700 13px var(--b-font, system-ui, sans-serif); }
  .ad-tab.on { background: #16263c; color: var(--b-text, #e6edf6); border-color: #4d8077; }
  .ad-panels { display: block; }
  .ad-panels > .ad-panel { display: none; height: 100%; box-sizing: border-box; }
  .ad-panels.show-drop > .ad-drop, .ad-panels.show-mis > .ad-mis, .ad-panels.show-emails > .ad-emails { display: flex; }
  .ad-dd { width: 150px; }
}
body:has(.ad-shell) .site-footer { display: none !important; }   /* the admin page is one screen */

/* The update form: a centred card over the page (a sheet from the bottom on phones) */
.ad-modal { position: fixed; inset: 0; z-index: 5000; background: rgba(5,10,20,.7); display: grid; place-items: center; padding: 16px; }
.ad-modal[hidden] { display: none; }
.ad-modal-card { width: min(560px, 100%); max-height: calc(100svh - 32px); overflow-y: auto; box-sizing: border-box; background: var(--b-surface, #0f1b2d);
  border: 1px solid #4d8077; border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; color: var(--b-text, #e6edf6); }
.ad-flabel { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--b-text-2, #9fb2c8); margin-top: 6px; }
.ad-input { width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--b-line, #203047); background: var(--b-bg, #0b1220);
  color: var(--b-text, #e6edf6); font: 15px var(--b-font, system-ui, sans-serif); }
.ad-ta { min-height: 96px; resize: vertical; }
.ad-frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ad-modal-card .ad-ebtns { margin-top: 10px; }
@media (max-width: 768px) {
  .ad-modal { place-items: end stretch; padding: 0; }
  .ad-modal-card { width: 100%; border-radius: 16px 16px 0 0; max-height: 92svh; }
  .ad-frow { grid-template-columns: 1fr; }
}

@media (max-width: 768px) { html.standalone .ad-shell { height: calc(100svh - 126px - env(safe-area-inset-bottom) - env(safe-area-inset-top)); } }   /* app: status bar too */
