/* 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(7, 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.8fr 1.1fr .85fr; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: "fun mis emails" "fun drop emails"; gap: var(--ad-gap); }
.ad-fun { grid-area: fun; } .ad-mis { grid-area: mis; } .ad-drop { grid-area: drop; } .ad-emails { grid-area: emails; }
/* mistakes and drop-off share a column: 5 rows at a time, the rest scroll inside */
.ad-mis .ad-list, .ad-drop .ad-list { max-height: 140px; }
.ad-mis .ad-ph .dash-dropdown, .ad-drop .ad-ph .dash-dropdown { max-width: 124px; flex: 0 0 124px; }   /* (styles.css makes every dropdown 100%) so the heading fits and 5 rows show */
.ad-mis .ad-mrow { padding: 4px 0; }
.ad-mis .ad-ml { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-mis .ad-ml small { display: inline; margin-left: 6px; }
.ad-drop .ad-dbar i { background: #e8964a; }   /* every level shown lost learners */
/* Visitors: the steps and the arrival pages side by side; where from and device under both */
.ad-fun .ad-list { display: grid; grid-template-columns: minmax(0, 250px) minmax(0, 1fr); column-gap: 24px; align-content: start; }
.ad-fun .ad-list > .ad-src { grid-column: 1 / -1; }
.ad-fun .ad-list > .ad-vlist + .ad-vlist { border-top: 0; margin-top: 0; }
.ad-fun .ad-list > .ad-vlist:first-child { padding-top: 22px; }   /* level with the arrival pages under their heading row */
/* the visitor funnel: each step, its bar, how many, and its share of the step before */
.ad-fnrow { display: grid; grid-template-columns: 76px minmax(0, 1fr) 30px 46px; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.ad-fnrow.worst .ad-dp { color: #e8964a; font-weight: 800; }
.ad-fl { color: var(--b-text-2, #9fb2c8); font-weight: 700; }
.ad-src { line-height: 1.5; }
.ad-vrow { display: grid; grid-template-columns: minmax(0, 1fr) 36px 50px; align-items: center; gap: 6px; padding: 4px 0; font-size: 13px; }
.ad-vrow .ad-fl { overflow-wrap: anywhere; line-height: 1.3; }
.ad-vrow .ad-dn, .ad-vrow .ad-dp { text-align: right; font-variant-numeric: tabular-nums; }
.ad-vrow.worst .ad-dp { color: #e8964a; font-weight: 800; }
.ad-vhead { font-size: 12px; color: var(--b-text-3, #8aa0b8); padding-top: 8px; }
.ad-vlist + .ad-vlist { border-top: 1px solid var(--b-line, #22364f); margin-top: 6px; }
.ad-tally { margin: 0; padding: 8px 10px; border-radius: 10px; background: var(--b-surface-2, #16263c); font-size: 13px; line-height: 1.45; }   /* everyone, anonymous: above the funnel */
.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 panels as tabs; the page runs as long as it needs, evenly spaced */
@media (max-width: 768px) {
  .ad-shell { height: auto; padding: 14px 16px 24px; gap: 14px; }
  .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: 10px; }
  .ad-tile { padding: 10px 12px; 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: 8px; }
  .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-fun .ad-list { display: block; } .ad-fun .ad-list > .ad-vlist:first-child { padding-top: 0; }
  .ad-fun .ad-list > .ad-vlist + .ad-vlist { border-top: 1px solid var(--b-line, #22364f); margin-top: 6px; }
  /* phones: room between rows; mistakes and drop-off show 5 at a time and Visitors every step to "Signed in",
     the rest scrolling inside its box */
  .ad-panel { gap: 10px; padding: 14px 14px 16px; }
  .ad-mis .ad-mrow, .ad-drop .ad-drow, .ad-vrow { padding: 9px 0; }
  .ad-mis .ad-list { flex: none; max-height: 236px; } .ad-drop .ad-list { flex: none; max-height: 180px; }
  .ad-fun .ad-list { flex: none; overflow: visible; }
  .ad-fun .ad-list > .ad-vlist + .ad-vlist { margin-top: 10px; padding-top: 4px; max-height: 190px; overflow-y: auto; overscroll-behavior: contain; }
  .ad-mis .ad-ml { white-space: normal; } .ad-mis .ad-ml small { display: block; margin-left: 0; }
  .ad-panels > .ad-panel { display: none; box-sizing: border-box; }
  .ad-panels.show-drop > .ad-drop, .ad-panels.show-mis > .ad-mis, .ad-panels.show-emails > .ad-emails, .ad-panels.show-fun > .ad-fun { 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; }
}

/* Opened vs finished per level (anonymous): level, opened, finished, % who left without finishing */
.ad-orow{display:grid;grid-template-columns:44px minmax(0,1fr) minmax(0,1fr) 56px;align-items:center;gap:8px;padding:4px 0;font-size:13px}
.ad-orow .ad-on{text-align:right;font-variant-numeric:tabular-nums;color:var(--b-text-2,#9fb2c8)}
.ad-orow .ad-dp{text-align:right}
.ad-ohead{font-size:11px;color:var(--b-text-3,#8aa0b8)}.ad-ohead .ad-on,.ad-ohead .ad-dp,.ad-ohead .ad-dl{font-weight:600;color:var(--b-text-3,#8aa0b8)}
.ad-orow.worst .ad-dp{color:#e8964a;font-weight:800}
.ad-osub{margin-top:6px;padding-top:8px;border-top:1px solid var(--b-line,#22364f)}
@media (min-width:761px){.ad-drop .ad-olist{max-height:140px}}
@media (max-width:760px){.ad-drop .ad-olist{flex:none;max-height:180px}#dash .ad-orow,.ad-orow{padding:9px 0}}

/* the Visitors panel's switch: Visitors | Insights */
.ad-switch { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--b-line, #203047); border-radius: 999px; }
.ad-sw { border: 0; background: none; color: var(--b-text-2, #9fb2c8); font: 700 13px var(--b-font, system-ui, sans-serif); padding: 4px 12px; border-radius: 999px; cursor: pointer; }
.ad-sw.on { background: #16263c; color: var(--b-text, #e6edf6); box-shadow: inset 0 0 0 1px #4d8077; }
/* Insights: short sections, one after another */
.ad-fun .ad-list.ad-ins { display: flex; flex-direction: column; gap: 4px; }   /* one column (the Visitors view is two) */
.ad-ins > * { flex-shrink: 0; }   /* the panel is short: the list scrolls, nothing squashes */
.ad-ihead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 10px 0 2px; padding-top: 8px; border-top: 1px solid #16263c; }
.ad-ins > .ad-ihead:first-child { margin-top: 2px; border-top: 0; padding-top: 0; }
.ad-ih { font-size: 13px; font-weight: 800; }
.ad-hours { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; height: 44px; align-items: end; }
.ad-hours i { display: block; background: #6AA59C; border-radius: 2px 2px 0 0; min-height: 2px; }
.ad-haxis { display: flex; justify-content: space-between; font-size: 11px; color: var(--b-text-2, #9fb2c8); }
.ad-vrow2 { grid-template-columns: minmax(0, 1fr) auto; }
.ad-vrow .ad-wide { white-space: nowrap; }
