* { box-sizing: border-box; margin: 0; }
:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --surface: #171a1f;
  --surface-2: #1d2127;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .15);
  --text: #f4f5f6;
  --muted: #969da7;
  --red: #e30f18;
  --red-dark: #bd0d14;
  --green: #4fd08a;
  --amber: #f0b54a;
  --blue: #78b7ff;
  --radius: 16px;
  --shadow: 0 18px 60px rgba(0, 0, 0, .25);
}
html { min-width: 320px; background: var(--bg); }
body {
  min-height: 100vh;
  font: 14px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at 84% -10%, rgba(227, 15, 24, .13), transparent 32rem),
    radial-gradient(circle at -8% 42%, rgba(86, 105, 132, .08), transparent 30rem),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(120, 183, 255, .72);
  outline-offset: 2px;
}
.hidden { display: none !important; }
.muted { color: #8a919b; font-weight: 400; font-size: 12px; }
.error { color: #ff6b6b; min-height: 1.2em; margin-top: 8px; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { background: linear-gradient(145deg, rgba(32, 36, 43, .96), rgba(21, 24, 29, .98)); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 42px 36px; border-radius: 20px; width: min(100%, 360px); text-align: center; }
.login-box h1 { margin-bottom: 20px; font-size: 22px; }
.login-box h1 span, header h1 span { color: #e30f18; }
.login-box input { width: 100%; padding: 11px 12px; border-radius: 8px; border: 1px solid #333; background: #121417; color: #eee; margin-bottom: 12px; }
.login-box button { width: 100%; padding: 11px; border: none; border-radius: 8px; background: #e30f18; color: #fff; font-weight: 700; cursor: pointer; }

/* header */
header { display: flex; align-items: center; gap: 20px; min-height: 66px; padding: 11px 24px; background: rgba(20, 23, 28, .88); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px) saturate(135%); position: sticky; top: 0; z-index: 20; }
header h1 { font-size: 18px; white-space: nowrap; }
/* desktop: una riga sola, scroll orizzontale se non ci sta (mai wrap confusionario) */
#tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
#tabs::-webkit-scrollbar { height: 5px; }
#tabs::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
#tabs button { background: none; border: none; color: #aab2bd; padding: 8px 13px; border-radius: 8px; cursor: pointer; font-size: 14px; white-space: nowrap; flex-shrink: 0; }
#tabs button.active { background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff; box-shadow: 0 8px 24px rgba(227, 15, 24, .2); }
#tabs button:hover:not(.active) { background: #262b32; }

/* hamburger: nascosto su desktop */
.nav-toggle { display: none; flex-direction: column; justify-content: center; gap: 4px; width: 38px; height: 38px; background: none; border: 1px solid #333; border-radius: 8px; cursor: pointer; padding: 0 9px; }
.nav-toggle span { display: block; height: 2px; background: #ccc; border-radius: 2px; transition: all 0.25s ease; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* backdrop scuro dietro al drawer (nascosto su desktop) */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.28s ease;
}
.nav-backdrop.show { opacity: 1; }

/* ===== MOBILE: hamburger + DRAWER laterale che oscura sotto ===== */
@media (max-width: 820px) {
  header { gap: 12px; padding: 12px 16px; }
  header h1 { font-size: 16px; margin-right: auto; }
  .nav-toggle { display: flex; }
  #whoami { font-size: 11px; }
  #logout { padding: 6px 12px; }

  .nav-backdrop { display: block; visibility: hidden; }
  .nav-backdrop.show { visibility: visible; }

  /* i tab diventano un pannello che entra da SINISTRA, sopra il backdrop */
  #tabs {
    position: fixed;
    top: 0;
    left: 0;
    width: 264px;
    max-width: 82vw;
    height: 100vh;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: #1b1f24;
    border-right: 1px solid #2a2f36;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    padding: 68px 12px 20px;   /* sotto l'header sticky */
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }
  #tabs::-webkit-scrollbar { display: none; }
  #tabs.open { transform: translateX(0); }
  #tabs button { width: 100%; text-align: left; padding: 13px 16px; font-size: 15px; border-radius: 8px; }
}
#logout { background: none; border: 1px solid #444; color: #aab2bd; padding: 7px 14px; border-radius: 8px; cursor: pointer; }

/* layout */
main { padding: 28px clamp(16px, 2.5vw, 36px) 54px; max-width: 1520px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.card { background: linear-gradient(145deg, rgba(29, 33, 39, .97), rgba(22, 25, 30, .97)); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; overflow-x: auto; box-shadow: 0 12px 36px rgba(0, 0, 0, .12); }
.card.wide { grid-column: 1 / -1; }
.card h2 { font-size: 15px; margin-bottom: 14px; color: #fff; }
.compact-panel > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; color: #fff; list-style: none; }
.compact-panel > summary::-webkit-details-marker { display: none; }
.compact-panel > summary::after { content: '+'; width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-size: 18px; flex: 0 0 auto; }
.compact-panel[open] > summary::after { content: '−'; }
.compact-panel > summary > span { display: flex; flex-direction: column; gap: 3px; }
.compact-panel > summary b { font-size: 15px; }
.compact-panel > summary small { color: var(--muted); font-weight: 400; }
.compact-panel[open] > summary { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.compact-panel-body { margin-top: 8px; }
.settings-legacy { margin-top: 18px; padding: 14px 0 0; border-top: 1px solid var(--line); }
.settings-legacy[open] > summary { margin-bottom: 14px; }
.tab { display: flex; flex-direction: column; gap: 16px; }
.tab .card { margin-bottom: 0; }

/* tabelle */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid rgba(255, 255, 255, .065); white-space: nowrap; }
th { color: #8a919b; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
td.wrap { white-space: normal; }

.status-ok { color: #4caf7d; font-weight: 700; }
.status-bad { color: #ff6b6b; font-weight: 700; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge.green { background: #17351f; color: #4caf7d; }
.badge.red { background: #3a1518; color: #ff6b6b; }
.badge.gray { background: #262b32; color: #aab2bd; }
.badge.amber { background: rgba(240, 181, 74, .14); color: var(--amber); }

/* controls */
input[type="search"] { width: 100%; max-width: 380px; padding: 9px 12px; border-radius: 8px; border: 1px solid #333; background: #121417; color: #eee; margin-bottom: 12px; }
button.mini { border: 1px solid var(--line-strong); background: rgba(12, 14, 17, .72); color: #e3e6ea; border-radius: 9px; padding: 6px 11px; min-height: 32px; cursor: pointer; font-size: 12px; margin-right: 4px; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
button.mini:hover { border-color: #e30f18; color: #fff; }
button.mini:active { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: .58; }
button.mini.danger { border-color: #7c2a2a; }
button.proc { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; background: #121417; border: 1px solid #333; color: #eee; border-radius: 10px; padding: 12px 16px; margin: 0 10px 10px 0; cursor: pointer; min-width: 220px; }
button.proc:hover { border-color: #e30f18; }
button.proc b { font-size: 13px; }
button.proc small { color: #8a919b; }
#proc-output { background: #0d0f12; border: 1px solid #2a2f36; border-radius: 8px; padding: 14px; margin-top: 14px; white-space: pre-wrap; font-size: 12px; max-height: 380px; overflow: auto; }

a { color: #6fb3ff; }

/* spinner: caricamento umano per ogni pannello */
.spinner {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #8a919b;
  font-size: 13px;
  padding: 14px 2px;
}
.spinner::before {
  content: '';
  width: 18px;
  height: 18px;
  border: 2.5px solid #2a2f36;
  border-top-color: #e30f18;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pane-error { color: #ff6b6b; font-size: 13px; padding: 10px 2px; }

/* barre risorse (mem/disco) leggibili */
.meter { margin-bottom: 14px; }
.meter-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.meter-label b { font-size: 13px; }
.meter-bar { height: 8px; border-radius: 6px; background: #262b32; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 6px; background: #4caf7d; transition: width 400ms ease; }
.meter-fill.warn { background: #e0a63a; }
.meter-fill.crit { background: #e30f18; }
.sys-row { font-size: 13px; color: #aab2bd; margin-top: 4px; }
.sys-row b { color: #e6e6e6; }

/* banner form */
.banner-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin-bottom: 8px; }
.banner-form input, .banner-form select { padding: 8px 10px; border-radius: 8px; border: 1px solid #333; background: #121417; color: #eee; font-size: 13px; }
.banner-thumb { height: 34px; max-width: 120px; object-fit: contain; border-radius: 4px; background: #fff; }

/* stato ok/ko a elenco */
.kv { list-style: none; padding: 0; margin: 0; font-size: 13.5px; }
.kv li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid #22272e; }
.kv li:last-child { border-bottom: none; }
#tab-ses .grid { grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) {
  #tab-ses .grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
  #tab-ses #ses-form { grid-row: span 3; }
}
#tab-ses .card, #tab-ses form, #tab-ses fieldset { min-width: 0; }
#tab-ses fieldset { border: 0; padding: 0; margin: 14px 0 0; }
#tab-ses .kv li { flex-wrap: wrap; align-items: flex-start; }
#tab-ses .kv b { min-width: 0; overflow-wrap: anywhere; }
#tab-ses .kv small { display: block; color: var(--muted); margin-top: 4px; }
#tab-ses [hidden] { display: none !important; }
#tab-ses label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); margin: 12px 0; }
#tab-ses input, #tab-ses textarea, #tab-ses select { width: 100%; max-width: 100%; box-sizing: border-box; padding: 10px 12px; min-height: 42px; border: 1px solid var(--line); border-radius: 9px; background: #121417; color: #eee; }
#tab-ses .section-head { flex-wrap: wrap; }
#tab-ses .section-head select { width: auto; }
#tab-ses .inline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
#tab-ses p { line-height: 1.55; margin: 12px 0; }
#tab-ses .compact-panel { margin: 16px 0; }
#tab-ses .ses-subnav { margin: 18px 0; }
#tab-ses .ses-subnav [aria-pressed="true"] { border-color: #d32636; background: #48171d; }
#tab-ses .ses-toggle { flex-direction: row; align-items: center; }
#tab-ses .ses-toggle input { width: 20px; min-height: 20px; flex: 0 0 20px; }
#tab-ses .ses-message-preview { border: 1px solid var(--line); border-radius: 12px; padding: 22px; overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.65; }
#tab-ses .ses-message-list { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin: 18px 0; }
#tab-ses .ses-message-list button { min-width: 0; padding: 14px 16px; text-align: left; font: inherit; color: var(--text); background: #181b20; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
#tab-ses .ses-message-list button[aria-pressed="true"] { border-color: #d32636; background: #35171c; }
#tab-ses .ses-message-list button:focus-visible { outline: 2px solid #f0c5ca; outline-offset: 3px; }
#tab-ses .ses-message-list span, #tab-ses .ses-message-list small { display: block; overflow-wrap: anywhere; }
#tab-ses .ses-message-list small { color: var(--muted); margin-top: 6px; font-size: 12px; }
@media (max-width: 760px) { #tab-ses .ses-message-list { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 420px) { #tab-ses .ses-message-list { grid-template-columns: minmax(0,1fr); } }
@media (max-width: 760px) {
  #tab-ses input, #tab-ses textarea, #tab-ses select { font-size: 16px; }
  #tab-ses button { min-height: 44px; }
}

/* gift form */
.gift-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.gift-form select, .gift-form input { padding: 8px 10px; border-radius: 8px; border: 1px solid #333; background: #121417; color: #eee; }
.gift-form input[type="number"] { width: 90px; }
#gift-new, #log-content { background: #0d0f12; border: 1px solid #2a2f36; border-radius: 8px; padding: 14px; white-space: pre-wrap; font-size: 12px; max-height: 420px; overflow: auto; margin-top: 10px; }
#log-buttons button { margin: 0 6px 6px 0; }

.active-log { border-color: #e30f18 !important; color: #fff !important; }

/* richieste commerciali Adv Center */
.advreq-stats { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 12px; }
.advreq-stat { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border: 1px solid #2a2f36; border-radius: 11px; background: #1b1f24; }
.advreq-stat span { color: #8a919b; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.advreq-stat b { font-size: 23px; color: #fff; }
.advreq-stat.red b { color: #ff6b6b; }
.advreq-stat.green b { color: #4caf7d; }
.advreq-toolbar { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 14px; }
.advreq-toolbar label { display: flex; flex-direction: column; gap: 4px; color: #8a919b; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.advreq-toolbar select { min-width: 190px; padding: 8px 10px; color: #eee; border: 1px solid #333; border-radius: 8px; background: #121417; }
.advreq-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.advreq-detail-head h2 { margin: 3px 0; font-size: 21px; }
.advreq-detail-head p { color: #aab2bd; }
.advreq-detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.advreq-detail-grid section, .advreq-placements article { min-width: 0; padding: 15px; border: 1px solid #2a2f36; border-radius: 10px; background: #15181c; }
.advreq-detail-grid h3, .advreq-placements h3 { margin-bottom: 10px; color: #fff; font-size: 14px; }
.advreq-detail-grid .kv li, .advreq-placements .kv li { align-items: flex-start; }
.advreq-detail-grid .kv span, .advreq-placements .kv span { flex: 0 0 42%; color: #8a919b; }
.advreq-detail-grid .kv b, .advreq-placements .kv b { max-width: 58%; overflow-wrap: anywhere; text-align: right; white-space: normal; }
.advreq-notes { color: #c9cdd2; white-space: pre-wrap; overflow-wrap: anywhere; }
.advreq-placements { margin-top: 18px; }
.advreq-placements > article { display: grid; grid-template-columns: 180px 1fr; gap: 15px; margin-top: 8px; }
.advreq-manage { display: grid; grid-template-columns: minmax(170px, .35fr) minmax(320px, 1fr) auto; align-items: end; gap: 14px; margin-top: 20px; padding: 18px; border: 1px solid #443033; border-radius: 11px; background: #1a171a; }
.advreq-manage textarea { padding: 9px 11px; color: #eee; border: 1px solid #333; border-radius: 8px; background: #121417; resize: vertical; }
#tab-feedback .advreq-detail-grid section:first-child { grid-column: span 2; }
#tab-feedback .advreq-detail-grid section:first-child .advreq-notes { font-size: 15px; line-height: 1.6; }

@media (max-width: 900px) {
  .advreq-stats { grid-template-columns: repeat(2, 1fr); }
  .advreq-detail-grid { grid-template-columns: 1fr; }
  #tab-feedback .advreq-detail-grid section:first-child { grid-column: auto; }
  .advreq-manage { grid-template-columns: 1fr; }
  .advreq-placements > article { grid-template-columns: 1fr; }
}

/* checkbox posizioni banner + permessi admin */
.bn-positions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 10px 0; font-size: 13px; }
.bn-positions b { color: #8a919b; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.bn-positions label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: #ddd; }
.bn-actions { display: flex; align-items: center; gap: 8px; margin: 8px 0 12px; flex-wrap: wrap; }
.right-actions { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }
.right-actions a.mini { text-decoration: none; display: inline-block; padding: 4px 10px; }

/* edit inline nelle tabelle (collaboratori) */
.inline-edit {
  width: 100%; min-width: 140px;
  background: #121417; border: 1px solid #333; border-radius: 6px;
  color: #eee; padding: 5px 8px; font-size: 12.5px;
}
.inline-edit:focus { outline: 1px solid #e30f18; }

/* barrette analytics */
.mini-bar { height: 8px; background: #262b32; border-radius: 5px; overflow: hidden; }
.mini-bar div { height: 100%; background: #e30f18; border-radius: 5px; }

/* analytics: il pubblico umano resta distinto dal traffico tecnico */
.analytics-control-card { overflow: visible; }
.analytics-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) repeat(3, minmax(130px, .18fr)) auto;
  align-items: end;
  gap: 14px;
}
.analytics-toolbar-copy h2 { margin: 3px 0 5px; font-size: 18px; }
.analytics-toolbar-copy p { max-width: 670px; line-height: 1.5; }
.analytics-toolbar select, .analytics-toolbar input { width: 100%; min-height: 40px; }
.analytics-export-actions { display: flex; align-items: center; gap: 7px; }
.analytics-export-actions .mini { min-height: 40px; margin: 0; white-space: nowrap; }
.analytics-definitions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.analytics-definitions > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(9, 11, 14, .42);
}
.analytics-definitions b { color: #e9ebee; font-size: 10px; letter-spacing: .055em; text-transform: uppercase; }
.analytics-definitions span { color: var(--muted); font-size: 10px; line-height: 1.42; }
.analytics-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
}
.analytics-kpi {
  display: flex;
  min-height: 92px;
  flex-direction: column;
  justify-content: center;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(29, 33, 39, .96), rgba(20, 23, 28, .96));
}
.analytics-kpi span { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .065em; text-transform: uppercase; }
.analytics-kpi b { color: #fff; font-size: 25px; line-height: 1.2; }
.analytics-kpi small { color: #737b85; font-size: 9px; }
.analytics-kpi.green b { color: var(--green); }
.analytics-kpi.red b { color: #ff777d; }
.analytics-kpi.amber b { color: var(--amber); }
.analytics-kpis.compact { margin: 14px 0; }
.analytics-kpis.compact .analytics-kpi { min-height: 76px; }
.analytics-quality {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(79, 208, 138, .2);
  border-radius: 999px;
  color: #9edbb9;
  background: rgba(79, 208, 138, .06);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.analytics-quality.bot { border-color: rgba(255, 98, 104, .27); color: #ff9297; background: rgba(227, 15, 24, .08); }
.analytics-quality.warning { border-color: rgba(240, 181, 74, .27); color: var(--amber); background: rgba(240, 181, 74, .07); }
.analytics-row-note { display: block; margin-top: 3px; color: #ff9ca0; font-size: 9px; }
.analytics-row-bot { background: rgba(227, 15, 24, .035); }
.analytics-volume { min-width: 100px; }
.analytics-meter-note { display: block; margin-top: 6px; color: #8a919b; font-size: 10px; line-height: 1.35; }
.meter-fill.traffic-human { background: var(--green); }
.meter-fill.traffic-bot { background: var(--red); }
.meter-fill.traffic-unknown { background: var(--amber); }
.analytics-day-card { scroll-margin-top: 82px; }
.analytics-day-head { align-items: center; margin-bottom: 12px; }
.analytics-day-head h2 { margin: 2px 0 0; font-size: 20px; }
.analytics-signal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 15px;
  border: 1px solid rgba(79, 208, 138, .18);
  border-radius: 11px;
  background: rgba(79, 208, 138, .045);
}
.analytics-signal > div { display: flex; flex-direction: column; }
.analytics-signal span, .analytics-signal small { color: var(--muted); font-size: 10px; }
.analytics-signal.bot { border-color: rgba(227, 15, 24, .3); background: rgba(227, 15, 24, .055); }
.analytics-signal.bot b { color: #ff8c92; }
.analytics-signal.warning { border-color: rgba(240, 181, 74, .28); background: rgba(240, 181, 74, .05); }
.analytics-incident {
  display: grid;
  gap: 3px;
  margin-top: 9px;
  padding: 14px 15px;
  border-left: 3px solid var(--red);
  border-radius: 0 10px 10px 0;
  background: rgba(227, 15, 24, .055);
}
.analytics-incident > span { color: #ff8e94; font-size: 9px; font-weight: 800; letter-spacing: .07em; }
.analytics-incident p { color: #c4c8ce; font-size: 11px; }
.analytics-incident small { color: var(--muted); font-size: 10px; }
.analytics-day-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.analytics-day-grid section { min-width: 0; overflow-x: auto; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: rgba(9, 11, 14, .38); }
.analytics-day-grid section.wide { grid-column: 1 / -1; }
.analytics-day-grid h3 { margin-bottom: 10px; color: #eef0f2; font-size: 12px; }
.analytics-day-grid h4 { margin: 12px 0 6px; color: var(--muted); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.analytics-day-grid h4:first-child { margin-top: 0; }

@media (max-width: 1050px) {
  .analytics-toolbar { grid-template-columns: 1fr 1fr; }
  .analytics-toolbar-copy { grid-column: 1 / -1; }
  .analytics-export-actions { justify-content: flex-end; }
  .analytics-definitions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .analytics-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .analytics-kpi { min-height: 78px; padding: 12px; }
  .analytics-kpi b { font-size: 21px; }
  .analytics-day-grid { grid-template-columns: 1fr; }
  .analytics-day-grid section.wide { grid-column: auto; }
  .analytics-signal { align-items: flex-start; flex-direction: column; gap: 5px; }
}

@media (max-width: 500px) {
  .analytics-toolbar { grid-template-columns: 1fr; }
  .analytics-toolbar-copy { grid-column: auto; }
  .analytics-export-actions { justify-content: stretch; }
  .analytics-export-actions .mini { flex: 1; }
  .analytics-definitions { grid-template-columns: 1fr; }
}

/* righe impostazioni */
.setting-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #22272e; flex-wrap: wrap; }
.setting-row:last-child { border-bottom: none; }
.setting-info { flex: 1; min-width: 240px; display: flex; flex-direction: column; }
.setting-input { flex: 1.4; min-width: 220px; background: #121417; border: 1px solid #333; border-radius: 8px; color: #eee; padding: 9px 12px; font-size: 13px; }
.setting-input:focus { outline: 2px solid #e30f18; border-color: transparent; }
.settings-batch-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px; margin-bottom: 8px; border: 1px solid #343a43; border-radius: 10px; background: #171a1f; }
.settings-batch-head > div { display: flex; flex-direction: column; gap: 4px; }
.settings-batch-head .mini { flex: 0 0 auto; }
.setting-clear { display: inline-flex; align-items: center; gap: 5px; color: #aeb4bd; font-size: 12px; }
@media (max-width: 700px) {
  .settings-batch-head { align-items: stretch; flex-direction: column; }
  .settings-batch-head .mini { width: 100%; }
}
#cf-output { background: #0d0f12; border: 1px solid #2a2f36; border-radius: 8px; padding: 12px; margin-top: 10px; font-size: 12px; }
#whoami { margin-right: 10px; }

/* anteprima upload (banner/collaboratori — via il campo URL, si carica soltanto) */
.upload-preview { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: #8a919b; }
.upload-thumb { height: 30px; max-width: 80px; object-fit: contain; border-radius: 4px; background: #fff; padding: 2px; }

/* date scheduling banner: etichette visibili */
.bn-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 4px 0 12px; font-size: 13px; color: #ccc; }
.bn-dates label { display: inline-flex; align-items: center; gap: 6px; }
.bn-dates input { padding: 7px 9px; border-radius: 8px; border: 1px solid #333; background: #121417; color: #eee; font-size: 13px; }

/* multi-select parser articoli: barra salva + evidenziazione scelte */
.lc-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
#lc-save { background: #e30f18; border-color: #e30f18; color: #fff; padding: 7px 16px; font-size: 13px; }
#lc-save:disabled { background: #333; border-color: #333; color: #888; cursor: default; }
.lc-pick { min-width: 62px; }
.lc-on { border-color: #4caf7d; }               /* label attuale dell'articolo */
.lc-pick.lc-sel { background: #e30f18; border-color: #e30f18; color: #fff; } /* scelta pendente */
tr.lc-changed { background: rgba(227, 15, 24, 0.08); }
.lc-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.lc-pagination .mini { margin: 0; }
.article-sync-card { overflow: visible; }
.article-sync-card .section-head { margin-bottom: 10px; }
.article-sync-status { min-height: 28px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: rgba(9, 11, 14, .38); font-size: 12px; white-space: pre-wrap; }
.article-sync-status.running { color: #f0c36d; border-color: rgba(240, 181, 74, .3); }
.article-sync-status.completed { color: var(--green); border-color: rgba(79, 208, 138, .25); }
.article-sync-status.failed { color: #ff858b; border-color: rgba(227, 15, 24, .3); }

/* ===== Modal overlay (form banner crea/modifica) ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
body.modal-open { overflow: hidden; }
.modal-box {
  position: relative; background: #1b1f24; border: 1px solid #2a2f36; border-radius: 14px;
  width: 100%; max-width: 720px; max-height: 90vh; overflow-y: auto; padding: 24px 26px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-box h3 { color: #fff; font-size: 17px; margin-bottom: 16px; }
.modal-close {
  position: absolute; top: 12px; right: 16px; background: none; border: none;
  color: #888; font-size: 26px; line-height: 1; cursor: pointer;
}
.modal-close:hover { color: #fff; }
.modal-body { display: flex; gap: 22px; flex-wrap: wrap; }
.modal-preview { flex: 0 0 200px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.modal-preview-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #8a919b; align-self: flex-start; }
.modal-preview-box {
  width: 100%; display: flex; align-items: center; justify-content: center;
  background: #0d0f12; border: 1px dashed #333; border-radius: 8px; overflow: hidden;
}
.modal-preview-h { height: 90px; }        /* proporzione orizzontale */
.modal-preview-v { height: 240px; width: 150px; align-self: center; }  /* proporzione verticale */
.modal-preview-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.modal-preview-empty { color: #555; font-size: 12px; }
.modal-fields { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 12px; }
.fld { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: #8a919b; }
.fld input, .fld select {
  padding: 9px 11px; border-radius: 8px; border: 1px solid #333; background: #121417; color: #eee; font-size: 13.5px;
}
.fld textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid #333;
  background: #121417; color: #eee; font-size: 13.5px; line-height: 1.5; resize: vertical;
}
.fld input:focus, .fld select:focus, .fld textarea:focus { outline: 2px solid #e30f18; border-color: transparent; }
.fld-lbl { font-size: 12px; color: #8a919b; }
.fld-row { display: flex; gap: 12px; }
.fld-row .fld { flex: 1; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
button.mini.primary { background: #e30f18; border-color: #e30f18; color: #fff; padding: 8px 20px; font-size: 13px; }
button.mini.primary:hover { background: #c00d15; }
.modal-preview-sq { height: 120px; width: 120px; align-self: center; }

/* ===== Redattori ===== */
.author-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
}
.author-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(29, 33, 39, .96), rgba(20, 23, 28, .96));
  box-shadow: 0 10px 28px rgba(0, 0, 0, .12);
}
.author-stat span { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.author-stat b { color: #fff; font-size: 24px; }
.author-stat.green b { color: var(--green); }
.author-stat.red b { color: #ff777d; }
.author-admin-head { margin-bottom: 16px; }
.author-admin-head h2 { margin-bottom: 6px; }
.author-admin-head p { max-width: 720px; line-height: 1.5; }
.author-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(150px, 220px) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 16px;
}
.author-toolbar input, .author-toolbar select,
.author-article-search input, .author-article-select {
  width: 100%; min-height: 39px; padding: 8px 10px; color: #eee;
  border: 1px solid #333; border-radius: 8px; background: #121417;
}
.author-toolbar .mini { min-height: 39px; margin: 0; }
.author-admin-avatar, .author-admin-initials {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
}
.author-admin-avatar { object-fit: cover; border: 1px solid var(--line-strong); background: #252a31; }
.author-admin-initials { color: #fff; background: linear-gradient(145deg, var(--red), #7e1117); font-size: 12px; font-weight: 800; }
.author-bio-cell { min-width: 220px; max-width: 420px; color: #c4c8ce; font-size: 12px; line-height: 1.45; }
.author-row-actions { min-width: 240px; }
.mini-link {
  display: inline-flex; align-items: center; min-height: 32px; margin-right: 4px; padding: 6px 11px;
  color: #e3e6ea; border: 1px solid var(--line-strong); border-radius: 9px;
  background: rgba(12, 14, 17, .72); font-size: 12px; text-decoration: none;
}
.mini-link:hover { color: #fff; border-color: var(--red); }
.author-modal-box { width: min(720px, 100%); }
.author-avatar-preview { width: 148px; height: 148px; border-radius: 50%; border-style: solid; }
.author-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.author-avatar-fallback {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
  color: #fff; background: linear-gradient(145deg, var(--red), #641116);
  font-size: 34px; font-weight: 850; letter-spacing: -.04em;
}
.author-enabled-check {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(10, 12, 15, .38); cursor: pointer;
}
.author-enabled-check input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--red); }
.author-enabled-check span, .author-enabled-check b, .author-enabled-check small { display: block; }
.author-enabled-check b { color: #f2f3f4; font-size: 13px; }
.author-enabled-check small { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.author-article-search {
  display: grid; grid-template-columns: minmax(240px, 520px) auto; gap: 9px;
  justify-content: start; margin-bottom: 14px;
}
.author-article-search .mini { min-height: 39px; margin: 0; }
.author-article-select { min-width: 200px; }
.author-empty { display: flex; flex-direction: column; gap: 4px; padding: 28px 10px; color: var(--muted); text-align: center; }
.author-empty b { color: #e6e8eb; }

/* ===== Infrastructure Center ===== */
.infra-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px 32px;
  padding: clamp(22px, 3vw, 34px);
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 22px;
  overflow: hidden;
  background:
    radial-gradient(circle at 86% 6%, rgba(255, 255, 255, .12), transparent 24rem),
    linear-gradient(135deg, #321317 0%, #211419 48%, #15181d 100%);
  box-shadow: 0 24px 72px rgba(0, 0, 0, .28);
}
.infra-hero::after {
  content: '';
  position: absolute;
  width: 340px;
  height: 340px;
  right: -150px;
  bottom: -240px;
  border: 48px solid rgba(227, 15, 24, .13);
  border-radius: 50%;
  pointer-events: none;
}
.infra-hero h2 { max-width: 820px; margin: 6px 0 8px; font-size: clamp(24px, 2.35vw, 34px); line-height: 1.1; letter-spacing: -.025em; }
.infra-hero p { max-width: 760px; color: #b6bbc2; font-size: 13px; }
.eyebrow { display: block; color: #f36d73; font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.infra-mode { align-self: start; display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border: 1px solid rgba(79, 208, 138, .23); border-radius: 999px; background: rgba(13, 31, 24, .6); color: #9ee2bd; font-size: 11px; font-weight: 700; white-space: nowrap; }
.infra-mode span { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(79, 208, 138, .1); }
.infra-flow { position: relative; z-index: 1; grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
.infra-flow > div { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px; padding: 9px 14px; border: 1px solid rgba(255, 255, 255, .11); border-radius: 12px; background: rgba(7, 9, 12, .35); text-align: center; }
.infra-flow > div:not(:last-child)::after { content: '→'; position: absolute; right: -13px; z-index: 2; color: #e46e73; font-weight: 800; }
.infra-flow small { color: #9198a1; font-size: 9px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.infra-flow b { margin-top: 1px; font-size: 12px; }

.infra-status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.dev-web-access-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 22px; align-items: center; border-color: rgba(150, 157, 167, .22); }
.dev-web-access-card.is-open { border-color: rgba(79, 208, 138, .35); background: linear-gradient(135deg, rgba(23, 26, 31, .98), rgba(15, 37, 28, .82)); }
.dev-web-access-card p { max-width: 780px; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.dev-web-access-card > small { grid-column: 1 / -1; }
.dev-access-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.dev-access-switch input { position: absolute; opacity: 0; pointer-events: none; }
.dev-access-switch span { position: relative; width: 46px; height: 25px; border: 1px solid var(--line-strong); border-radius: 999px; background: #30343a; transition: .2s ease; }
.dev-access-switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #d8dce1; transition: .2s ease; }
.dev-access-switch input:checked + span { border-color: rgba(79, 208, 138, .7); background: rgba(79, 208, 138, .35); }
.dev-access-switch input:checked + span::after { transform: translateX(21px); background: #7ce5aa; }
.dev-access-switch input:disabled + span { opacity: .45; cursor: wait; }
.dev-access-switch b { font-size: 12px; white-space: nowrap; }
.infra-state { display: flex; align-items: center; gap: 13px; min-height: 78px; padding: 15px 17px; border: 1px solid var(--line); border-radius: 14px; background: rgba(23, 26, 31, .82); }
.infra-state-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 6px rgba(150, 157, 167, .08); }
.infra-state.ok .infra-state-dot { background: var(--green); box-shadow: 0 0 0 6px rgba(79, 208, 138, .09); }
.infra-state.bad .infra-state-dot { background: #ff6268; box-shadow: 0 0 0 6px rgba(255, 98, 104, .09); }
.infra-state small, .infra-state b { display: block; }
.infra-state small { margin-bottom: 3px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.infra-state b { overflow-wrap: anywhere; font-size: 13px; line-height: 1.3; }

.infra-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(290px, .72fr); gap: 16px; align-items: start; }
.infra-config-card, .infra-guard-card { overflow: visible; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 { margin: 4px 0 0; font-size: 19px; letter-spacing: -.015em; }
.infra-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.infra-form-grid .fld { min-width: 0; }
.infra-form-grid .fld input { width: 100%; min-height: 42px; border-color: var(--line-strong); background: rgba(8, 10, 13, .62); }
.infra-form-grid .fld small { color: #747c86; font-size: 9px; line-height: 1.4; }
.infra-span-2 { grid-column: 1 / -1; }
.infra-field-group { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(8, 10, 13, .28); }
.infra-field-group h3 { margin-bottom: 11px; color: #d8dce1; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.infra-field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.infra-field-group .infra-check { margin-top: 12px; }
.infra-overrides { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.infra-overrides summary { color: #d8dce1; cursor: pointer; font-size: 11px; font-weight: 800; letter-spacing: .03em; }
.infra-overrides > p { margin: 8px 0 12px; color: #8f959d; font-size: 11px; line-height: 1.5; }
.infra-plan-mode { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.infra-check { display: inline-flex; align-items: center; gap: 9px; margin-top: 16px; color: #b9bec5; cursor: pointer; font-size: 12px; }
.infra-check input, .guard-check input { accent-color: var(--red); }
.infra-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 17px; }
.infra-actions button { margin-right: 0; }
.infra-actions .primary { min-height: 38px; }
.infra-copy { margin: -6px 0 13px; line-height: 1.55; }
.guard-check { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: start; gap: 10px; padding: 12px 0; border-bottom: 1px solid rgba(255, 255, 255, .065); cursor: pointer; }
.guard-check input { width: 17px; height: 17px; margin-top: 2px; }
.guard-check span, .guard-check b, .guard-check small { display: block; }
.guard-check b { color: #f2f3f4; font-size: 13px; }
.guard-check small { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.infra-plan-button { width: 100%; justify-content: center; margin: 18px 0 0 !important; min-height: 42px !important; }
.infra-note { margin-top: 12px; padding: 11px 12px; border-left: 2px solid var(--amber); background: rgba(240, 181, 74, .055); color: #b6bbc3; font-size: 11px; line-height: 1.5; }
.infra-note b { color: #e2e5e8; }

#infra-plan-title code { color: #ff989d; font: 600 12px/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.infra-plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.infra-plan-grid > section, .infra-rules-section, .infra-invariants { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: rgba(10, 12, 15, .37); }
.infra-rule-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.infra-rule { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; align-items: start; }
.infra-rule > span { display: flex; align-items: center; justify-content: center; width: 27px; height: 27px; border: 1px solid rgba(227, 15, 24, .25); border-radius: 8px; background: rgba(227, 15, 24, .07); color: #ff858a; font: 700 10px/1 ui-monospace, monospace; }
.infra-rule b { font-size: 12px; text-transform: uppercase; }
.infra-rule p { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.infra-rules-section, .infra-invariants { margin-top: 14px; }
.infra-alert { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; margin-top: 10px; }
.infra-alert.bad { border-color: rgba(255, 98, 104, .2); background: rgba(255, 98, 104, .055); }
.infra-alert.warn { border-color: rgba(240, 181, 74, .2); background: rgba(240, 181, 74, .05); }
.infra-alert b { display: block; margin-bottom: 7px; }
.infra-list { padding-left: 18px; color: #b5bbc2; font-size: 12px; }
.infra-list li + li { margin-top: 5px; }
.infra-invariants > b { display: block; margin-bottom: 8px; }
.infra-safety-card { background: linear-gradient(135deg, rgba(26, 29, 35, .98), rgba(34, 20, 24, .93)); }
.infra-principles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 15px; }
.infra-principles article { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: rgba(10, 12, 15, .34); }
.infra-principles b { font-size: 13px; }
.infra-principles p { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.infra-doc-links { margin-top: 14px; }
.table-shell { overflow-x: auto; }

@media (max-width: 1080px) {
  .author-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .infra-status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .infra-layout { grid-template-columns: 1fr; }
  .infra-guard-card { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
  .infra-guard-card .section-head, .infra-guard-card .infra-copy, .infra-guard-card .infra-plan-button, .infra-guard-card .infra-note { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  main { padding-top: 18px; }
  .card { padding: 18px; }
  .infra-hero { grid-template-columns: 1fr; border-radius: 18px; }
  .infra-mode { justify-self: start; }
  .infra-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .infra-flow > div:not(:last-child)::after { display: none; }
  .infra-plan-grid, .infra-principles { grid-template-columns: 1fr; }
  .infra-guard-card { display: block; }
}

@media (max-width: 600px) {
  header { gap: 8px; padding-inline: 12px; }
  header h1 { font-size: 15px; }
  #whoami { display: none; }
  #logout { padding-inline: 10px; }
  .nav-toggle { width: 36px; height: 36px; }
  main { padding: 14px 12px 40px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px; border-radius: 14px; }
  .infra-hero { padding: 22px 18px; }
  .infra-hero h2 { font-size: 26px; }
  .infra-status-grid, .infra-form-grid, .infra-field-pair { grid-template-columns: 1fr; }
  .dev-web-access-card { grid-template-columns: 1fr; }
  .dev-web-access-card > small { grid-column: auto; }
  .infra-span-2 { grid-column: auto; }
  .infra-state { min-height: 68px; }
  .infra-flow > div { min-height: 46px; padding-inline: 8px; }
  .infra-actions { align-items: stretch; }
  .infra-actions button { flex: 1 1 140px; }
  .section-head { flex-direction: column; }
  .advreq-stats { grid-template-columns: 1fr 1fr; }
  .advreq-toolbar { align-items: stretch; flex-direction: column; }
  .modal-overlay { padding: 10px; }
  .modal-box { padding: 20px 16px; }
  .author-toolbar, .author-article-search { grid-template-columns: 1fr; }
  .author-toolbar .mini, .author-article-search .mini { width: 100%; }
  .author-stats { gap: 8px; }
  .author-stat { min-height: 62px; padding: 12px 13px; }
  .author-stat span { font-size: 9px; }
  .author-stat b { font-size: 20px; }
  .author-row-actions { min-width: 210px; }
  th, td { padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ===== Admin shell: navigazione stabile e gerarchia leggibile ===== */
.nav-group-label {
  color: #707985;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.admin-page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
  margin-bottom: 22px;
  padding-bottom: 19px;
  border-bottom: 1px solid var(--line);
}
.admin-page-head h2 { font-size: clamp(23px, 2.5vw, 34px); line-height: 1.1; letter-spacing: -.035em; }
.admin-page-head p { max-width: 760px; color: #a5acb5; font-size: 13px; }

@media (min-width: 821px) {
  header { padding-inline: 20px; }
  header h1 { margin-right: auto; }
  #tabs {
    position: fixed;
    top: 66px;
    bottom: 0;
    left: 0;
    z-index: 18;
    width: 238px;
    height: calc(100vh - 66px);
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    padding: 18px 13px 24px;
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    background: rgba(18, 21, 25, .94);
    backdrop-filter: blur(18px) saturate(130%);
    scrollbar-width: thin;
  }
  #tabs .nav-group-label { padding: 17px 12px 5px; }
  #tabs .nav-group-label:first-child { padding-top: 2px; }
  #tabs button {
    position: relative;
    width: 100%;
    min-height: 39px;
    padding: 9px 12px;
    text-align: left;
  }
  #tabs button.active {
    background: rgba(227, 15, 24, .13);
    color: #fff;
    box-shadow: none;
  }
  #tabs button.active::before {
    content: '';
    position: absolute;
    top: 9px;
    bottom: 9px;
    left: 0;
    width: 3px;
    border-radius: 4px;
    background: var(--red);
  }
  #dash-view main {
    width: calc(100% - 238px);
    max-width: 1680px;
    margin: 0 0 0 238px;
    padding: 30px clamp(22px, 3vw, 48px) 58px;
  }
}

@media (max-width: 820px) {
  header { z-index: 60; }
  #tabs {
    top: 66px;
    height: calc(100vh - 66px);
    padding: 16px 12px 24px;
  }
  #tabs .nav-group-label { padding: 17px 16px 5px; }
  #tabs .nav-group-label:first-child { padding-top: 3px; }
  .nav-backdrop { top: 66px; z-index: 40; }
  .admin-page-head { margin-bottom: 16px; padding-bottom: 15px; }
}

/* ===== Inventario copertine programmi ===== */
.program-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 10px;
}
.program-stat {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(29, 33, 39, .96), rgba(20, 23, 28, .96));
}
.program-stat span { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.program-stat b { font-size: 23px; }
.program-stat.green b { color: var(--green); }
.program-stat.red b { color: #ff777d; }
.program-stat.amber b { color: var(--amber); }
.program-admin-card { overflow: visible; }
.program-admin-head { margin-bottom: 17px; }
.program-admin-head h2 { margin: 4px 0 6px; font-size: 19px; }
.program-admin-head p { max-width: 760px; }
.program-toolbar {
  display: grid;
  grid-template-columns: minmax(230px, 1.2fr) minmax(190px, .7fr) minmax(170px, .6fr);
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}
.program-toolbar input, .program-toolbar select {
  width: 100%;
  min-height: 42px;
  margin: 0;
  padding: 9px 11px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(9, 11, 14, .72);
}
.program-source-status { display: flex; flex-wrap: wrap; gap: 7px; margin: 4px 0 18px; }
.program-source {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 27px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #aeb4bc;
  background: rgba(10, 12, 15, .55);
  font-size: 10px;
  font-weight: 700;
}
.program-source i { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.program-source.ok i { background: var(--green); box-shadow: 0 0 0 4px rgba(79, 208, 138, .08); }
.program-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.program-cover-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(13, 15, 18, .72);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .12);
  transition: transform .18s ease, border-color .18s ease;
}
.program-cover-card:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, .18); }
.program-media-compare { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(96px, .65fr); min-height: 190px; background: #090b0d; }
.program-cover-image { position: relative; aspect-ratio: 1 / 1; overflow: hidden; background: #090b0d; }
.program-cover-image > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.program-broadcast-reference {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 11px;
  border-left: 1px solid var(--line);
  background: rgba(22, 25, 30, .96);
}
.program-broadcast-reference > span { color: #aab1ba; font-size: 9px; font-weight: 800; letter-spacing: .055em; text-transform: uppercase; }
.program-broadcast-reference > div { position: relative; overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 7px; background: #090b0d; }
.program-broadcast-reference img { display: block; width: 100%; height: 100%; object-fit: cover; }
.program-broadcast-reference .program-cover-fallback b { font-size: 15px; }
.program-broadcast-reference .program-cover-fallback small { display: none; }
.program-broadcast-reference > small { color: #68717b; font-size: 8px; }
.program-cover-state {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 999px;
  color: #d0d4d9;
  background: rgba(8, 10, 12, .78);
  backdrop-filter: blur(8px);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.program-cover-state.custom { border-color: rgba(227, 15, 24, .34); color: #fff; background: rgba(139, 14, 21, .86); }
.program-cover-fallback {
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #fff;
  background: radial-gradient(circle at 50% 15%, rgba(227, 15, 24, .28), transparent 55%), #111419;
}
.program-cover-fallback b { font-size: 26px; letter-spacing: -.06em; }
.program-cover-fallback small { color: #8f969f; font-size: 10px; }
.program-cover-body { display: flex; min-height: 162px; flex-direction: column; gap: 12px; padding: 15px; }
.program-cover-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.program-cover-title h3 { min-width: 0; font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
.program-cover-title > span { flex: 0 0 auto; color: #737b85; font: 700 10px/1.4 ui-monospace, monospace; }
.program-surface-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.program-surface-badges span { padding: 3px 7px; border: 1px solid var(--line); border-radius: 6px; color: #68717b; font-size: 9px; font-weight: 750; }
.program-surface-badges span.on { border-color: rgba(79, 208, 138, .18); color: #9edbb9; background: rgba(79, 208, 138, .055); }
.program-cover-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: auto; }
.program-cover-actions .mini-link, .program-cover-actions .mini { min-height: 34px; margin: 0; }
.program-cover-actions .mini { margin-left: auto; }
.program-empty, .program-match-ok {
  grid-column: 1 / -1;
  display: flex;
  min-height: 130px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  text-align: center;
}
.program-empty b, .program-match-ok b { color: #e8eaed; }
.program-unmatched-card { padding-block: 0; }
.program-unmatched-card summary {
  display: flex;
  min-height: 67px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
}
.program-unmatched-card summary::-webkit-details-marker { display: none; }
.program-unmatched-card summary span:first-child { display: flex; flex-direction: column; gap: 2px; }
.program-unmatched-card summary small { color: var(--muted); font-weight: 400; }
.program-unmatched-card[open] { padding-bottom: 18px; }
.program-unmatched-card[open] summary > span:last-child { transform: rotate(45deg); }
.program-unmatched-card > p { margin-bottom: 13px; }
.program-modal-box { width: min(880px, 100%); }
.program-modal-heading { padding-right: 38px; }
.program-modal-heading h3 { margin: 4px 0 3px; font-size: 21px; }
.program-cover-previews {
  display: grid;
  grid-template-columns: minmax(180px, .72fr) minmax(280px, 1.28fr);
  gap: 13px;
  align-items: end;
  margin: 20px 0;
}
.program-cover-previews > div { min-width: 0; }
.program-cover-previews > div > span { display: block; margin-bottom: 6px; color: #8f969f; font-size: 10px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.program-preview { overflow: hidden; border: 1px solid var(--line-strong); border-radius: 11px; background: #090b0d; }
.program-preview-square { aspect-ratio: 1 / 1; }
.program-preview-wide { aspect-ratio: 16 / 9; }
.program-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.program-cover-form { display: flex; flex-direction: column; gap: 12px; }
.program-cover-form .fld input { min-height: 43px; }
.program-cover-form .fld small { color: #7f8791; line-height: 1.4; }
.program-upload-row, .program-origin-note { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.program-upload-row .mini { margin: 0; }
.program-origin-note { justify-content: space-between; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(9, 11, 14, .45); font-size: 11px; }
.disabled-link { pointer-events: none; text-decoration: none; }
.program-form-status { min-height: 20px; color: #aeb4bc; font-size: 12px; }
.program-form-status.ok { color: var(--green); }
.program-form-status.error { color: #ff777d; }
.program-modal-actions { align-items: center; }
.program-modal-actions #program-modal-cancel { margin-left: auto; }

/* ===== Shorts homepage ===== */
.shorts-admin-card { overflow: visible; }
.shorts-admin-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.shorts-admin-actions .mini { margin: 0; }
.shorts-admin-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 16px; }
.shorts-admin-summary span {
  display: inline-flex; align-items: baseline; gap: 5px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
  background: rgba(9, 11, 14, .48); font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
}
.shorts-admin-summary b { color: #fff; font-size: 13px; }
.shorts-admin-list { display: flex; flex-direction: column; gap: 8px; }
.short-admin-item {
  display: grid; grid-template-columns: 76px minmax(150px, .65fr) minmax(260px, 1.6fr) auto;
  gap: 14px; align-items: center; padding: 12px 13px; border: 1px solid var(--line);
  border-radius: 12px; background: rgba(11, 13, 16, .58);
}
.short-admin-item.disabled { opacity: .58; }
.short-admin-order { display: grid; grid-template-columns: 25px 20px 25px; align-items: center; gap: 2px; text-align: center; }
.short-admin-order .mini { width: 25px; min-height: 27px; margin: 0; padding: 2px; }
.short-admin-order span { color: var(--muted); font: 700 10px/1 ui-monospace, monospace; }
.short-admin-source { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; gap: 5px; }
.short-admin-source code { max-width: 100%; overflow: hidden; color: #98a0aa; text-overflow: ellipsis; }
.short-admin-copy { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.short-admin-copy > span { color: #ff8b91; font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.short-admin-copy b { overflow: hidden; color: #f1f2f4; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.short-admin-copy small { color: var(--muted); font-size: 10px; }
.short-admin-row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.short-admin-row-actions .mini, .short-admin-row-actions .mini-link { margin: 0; }
.short-modal-box { width: min(680px, 100%); }
.short-form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.short-form .fld input { width: 100%; min-height: 42px; }
.short-form .fld small { color: #7f8791; font-size: 10px; line-height: 1.4; }

.admin-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 180;
  max-width: min(390px, calc(100vw - 28px));
  padding: 12px 15px;
  border: 1px solid rgba(79, 208, 138, .28);
  border-radius: 11px;
  color: #dff8ea;
  background: rgba(17, 47, 34, .96);
  box-shadow: 0 16px 44px rgba(0, 0, 0, .36);
  font-size: 12px;
  font-weight: 650;
}
.admin-toast.error { border-color: rgba(255, 98, 104, .3); color: #ffe6e7; background: rgba(67, 23, 27, .97); }

@media (max-width: 1200px) {
  .program-stats { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
}

@media (max-width: 760px) {
  .program-toolbar { grid-template-columns: 1fr; }
  .program-cover-previews { grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr); }
  .short-admin-item { grid-template-columns: 64px minmax(0, 1fr); }
  .short-admin-copy, .short-admin-row-actions { grid-column: 1 / -1; }
  .short-admin-row-actions { justify-content: flex-start; }
}

/* ===== MFA amministratori ===== */
.mfa-setup,
.mfa-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin: 12px 0;
}
.mfa-setup input,
.mfa-confirm input { min-width: min(100%, 240px); }
.mfa-confirm .muted { flex-basis: 100%; margin: 0; }
.mfa-secret {
  max-width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #fff;
  background: #0c0e11;
  font-size: 13px;
  letter-spacing: .08em;
  overflow-wrap: anywhere;
  user-select: all;
}

@media (max-width: 620px) {
  .mfa-setup > *,
  .mfa-confirm > * { width: 100%; }
  .mfa-setup input,
  .mfa-confirm input { min-width: 0; }
  .mfa-confirm .mfa-secret { width: auto; }
}

@media (max-width: 520px) {
  .program-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .program-stat { min-height: 62px; padding: 12px; }
  .program-stat span { font-size: 8px; }
  .program-stat b { font-size: 20px; }
  .program-grid { grid-template-columns: minmax(0, 1fr); }
  .program-media-compare { grid-template-columns: minmax(0, 1.45fr) minmax(92px, .55fr); }
  .program-cover-previews { grid-template-columns: 1fr 1fr; gap: 8px; }
  .program-cover-previews > div > span { min-height: 28px; }
  .program-modal-actions { flex-wrap: wrap; }
  .program-modal-actions #program-modal-cancel { width: 100%; margin-left: 0; }
  .admin-toast { right: 14px; bottom: 14px; }
  .shorts-admin-actions { width: 100%; }
  .shorts-admin-actions .mini { flex: 1; }
  .short-admin-item { padding: 11px; }
  .short-admin-copy b { white-space: normal; }
}

/* ===== Impostazioni avanzate e cache ===== */
.infra-overview-card,
.cache-reset-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.infra-overview-card > div,
.cache-reset-card > div:first-child { max-width: 760px; }
.infra-overview-card h2,
.cache-reset-card h2,
.advanced-settings-intro h2 { margin: 5px 0 8px; }
.infra-overview-card p,
.cache-reset-card p,
.advanced-settings-intro p { margin: 0; color: var(--muted); line-height: 1.6; }
.advanced-settings-intro {
  border-color: rgba(255,255,255,.12);
  background: linear-gradient(135deg, rgba(255,255,255,.055), rgba(255,255,255,.018));
}
.cache-reset-actions {
  min-width: min(100%, 250px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
}
.cache-reset-actions .mini { margin: 0; }
.cache-reset-actions .muted { max-width: 360px; text-align: right; line-height: 1.4; }

@media (max-width: 760px) {
  .infra-overview-card,
  .cache-reset-card { align-items: stretch; flex-direction: column; gap: 16px; }
  .infra-overview-card .mini,
  .cache-reset-actions .mini { width: 100%; }
  .cache-reset-actions { width: 100%; align-items: stretch; }
  .cache-reset-actions .muted { max-width: none; text-align: left; }
}

/* ===== Sorgenti e carico origin ===== */
.sources-toolbar-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.sources-toolbar-card h2 { margin: 5px 0 7px; }
.sources-toolbar-card p { max-width: 820px; margin: 0; color: var(--muted); line-height: 1.55; }
.sources-toolbar-actions { display: grid; justify-items: end; gap: 8px; flex: 0 0 auto; }
.sources-toolbar-actions .mini { margin: 0; min-width: 126px; }
.sources-auto { display: inline-flex; align-items: center; gap: 8px; color: #c8cdd4; font-size: 12px; cursor: pointer; }
.sources-auto input { accent-color: var(--red); }
.sources-summary { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; }
.source-kpi {
  min-height: 88px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(25, 29, 35, .82);
}
.source-kpi small { color: var(--muted); text-transform: uppercase; letter-spacing: .055em; font-size: 10px; }
.source-kpi b { font-size: 25px; line-height: 1; }
.source-kpi.ok b { color: var(--green); }
.source-kpi.bad b { color: #ff7272; }
.sources-path-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 0 3px; color: var(--muted); font-size: 11px; }
.sources-path-legend span { display: inline-flex; align-items: center; gap: 7px; }
.sources-path-legend i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.sources-path-legend i.direct { background: var(--green); }
.sources-path-legend i.metadata { background: var(--blue); }
.sources-path-legend i.origin { background: var(--amber); }
.sources-path-legend i.attention { background: #ff7272; }
.sources-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.source-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(28, 32, 38, .97), rgba(18, 21, 25, .97));
  box-shadow: 0 10px 32px rgba(0, 0, 0, .12);
}
.source-card.degraded { border-color: rgba(255, 107, 107, .34); }
.source-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.source-card-head small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.source-card-head h3 { margin: 3px 0 0; font-size: 16px; line-height: 1.25; }
.source-health { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; color: #b9c0c9; font-size: 11px; white-space: nowrap; }
.source-health i { width: 8px; height: 8px; border-radius: 50%; background: #7c838d; box-shadow: 0 0 0 4px rgba(124, 131, 141, .1); }
.source-card.healthy .source-health i { background: var(--green); box-shadow: 0 0 0 4px rgba(79, 208, 138, .1); }
.source-card.degraded .source-health i { background: #ff7272; box-shadow: 0 0 0 4px rgba(255, 114, 114, .1); }
.source-path { display: inline-flex; margin-top: 13px; padding: 4px 8px; border-radius: 6px; background: rgba(150, 157, 167, .1); color: #b9c0c9; font-size: 9px; font-weight: 800; letter-spacing: .055em; }
.source-path.direct { background: rgba(79, 208, 138, .1); color: #7be1a8; }
.source-path.metadata { background: rgba(120, 183, 255, .1); color: #9bcbff; }
.source-path.origin { background: rgba(240, 181, 74, .1); color: #f5c56d; }
.source-path.attention { background: rgba(255, 107, 107, .12); color: #ff8b8b; }
.source-detail { margin: 12px 0 13px; color: #e2e5e9; font-size: 13px; }
.source-facts { display: grid; gap: 0; margin: 0; }
.source-facts > div { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-top: 1px solid rgba(255,255,255,.055); }
.source-facts dt { color: #7f8791; font-size: 10px; text-transform: uppercase; letter-spacing: .045em; }
.source-facts dd { min-width: 0; margin: 0; color: #b9c0c9; font-size: 11px; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .sources-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sources-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .sources-toolbar-card { align-items: stretch; flex-direction: column; gap: 16px; }
  .sources-toolbar-actions { justify-items: stretch; }
  .sources-toolbar-actions .mini { width: 100%; }
  .sources-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .source-kpi { min-height: 76px; padding: 13px; }
  .source-kpi b { font-size: 21px; }
  .source-card { padding: 15px; }
  .source-card-head { flex-direction: column; gap: 9px; }
  .source-health { white-space: normal; }
  .source-facts > div { grid-template-columns: 84px minmax(0, 1fr); }
}
/* GAM configuration: contain long unit paths, JSON filenames and ads.txt. */
#tab-gam .infra-form-grid label { display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
#tab-gam input, #tab-gam select, #tab-gam textarea { max-width: 100%; box-sizing: border-box; }
#tab-gam input:not([type=file]), #tab-gam select, #tab-gam textarea {
  width: 100%; padding: 10px 12px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line-strong); border-radius: 8px; font: inherit;
}
#tab-gam .section-head select { width: auto; }
#tab-gam .section-head { gap: 1rem; }
#tab-gam .infra-form-grid { margin: 1rem 0; }
#tab-gam .compact-panel { padding: 1rem 0; }
#tab-gam .card > p { margin: .75rem 0; line-height: 1.55; }
#tab-gam textarea { width: 100%; resize: vertical; font-family: monospace; }
#tab-gam .kv b, #gam-account-status { overflow-wrap: anywhere; }
#tab-gam .inline-actions { display: flex; align-items: center; gap: .75rem; margin: 1rem 0; flex-wrap: wrap; }
@media (max-width: 760px) {
  #tab-gam input, #tab-gam select, #tab-gam textarea { font-size: 16px; }
  #tab-gam button { min-height: 44px; }
}
