/* ==========================================================================
   RARITEX — admin.css
   "LA REGIA" · pannello di controllo di Canale 151.
   Estetica: sala regia broadcast — rack, monitor wall, tally, timecode.
   Si appoggia ai token di base.css; qui solo ciò che è specifico dell'admin.
   ========================================================================== */

.admin-body {
  --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --tally: #ff4d5e;
  --adm-sidebar-w: 264px;
  --adm-topbar-h: 64px;
  display: grid;
  grid-template-columns: var(--adm-sidebar-w) 1fr;
  min-height: 100vh;
  overflow-x: clip;
}

[data-theme="dark"] .admin-body {
  --adm-rack: #12101a;
  --adm-line: rgba(255, 255, 255, 0.07);
  --st-ok: #6fe0c0;
  --st-warn: #f5c162;
  --st-bad: #ff7a8a;
  --st-info: #9fb3f2;
}
[data-theme="light"] .admin-body {
  --adm-rack: #efecf5;
  --adm-line: rgba(36, 31, 46, 0.08);
  --st-ok: #0e8a63;
  --st-warn: #9c6500;
  --st-bad: #c22940;
  --st-info: #4553b8;
}

/* ---------- sfondo console: griglia tecnica + vignetta ---------- */
#adm-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--adm-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--adm-line) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, #000 30%, transparent 100%);
  opacity: 0.5;
}

/* ==========================================================================
   SIDEBAR — il rack della regia
   ========================================================================== */
.adm-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--adm-rack);
  border-right: 1px solid var(--border);
  padding: 22px 16px 16px;
  z-index: 60;
}

.adm-logo {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 10px 18px;
  text-decoration: none;
}
.adm-logo:hover { text-decoration: none; }
.adm-logo-word {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  line-height: 1;
}
.adm-logo-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.adm-tally-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tally);
  box-shadow: 0 0 8px var(--tally);
  animation: tally-pulse 2.4s ease-in-out infinite;
}
@keyframes tally-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.adm-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 6px;
}
.adm-nav-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.7;
  margin: 18px 10px 6px;
}
.adm-nav-label:first-child { margin-top: 4px; }

.adm-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.18s ease, background-color 0.18s ease, transform 0.15s ease;
}
.adm-nav a:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--brand-teal) 8%, transparent);
  text-decoration: none;
  transform: translateX(2px);
}
.adm-nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }

.adm-nav a.is-active {
  color: var(--text);
  background: linear-gradient(100deg,
    color-mix(in srgb, var(--brand-purple) 20%, transparent),
    color-mix(in srgb, var(--brand-teal) 14%, transparent));
  font-weight: 600;
}
.adm-nav a.is-active::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 3px;
  background: var(--grad-brand);
  box-shadow: 0 0 10px var(--glow-teal);
}

.adm-nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-teal) 20%, transparent);
  color: var(--accent-2);
}
.adm-nav-count.is-warn {
  background: color-mix(in srgb, var(--st-warn) 18%, transparent);
  color: var(--st-warn);
}

.adm-sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.adm-back-site {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: none;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.adm-back-site:hover { color: var(--accent-2); border-color: var(--brand-teal); text-decoration: none; }
.adm-back-site svg { width: 17px; height: 17px; }

.adm-user { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.adm-avatar {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--btn-primary-text);
  background: var(--grad-brand);
  flex: none;
}
.adm-user-info { display: flex; flex-direction: column; line-height: 1.25; }
.adm-user-info strong { font-size: 0.86rem; }
.adm-user-info small { color: var(--text-muted); font-size: 0.7rem; }

/* ==========================================================================
   TOPBAR — timecode, tally, strumenti
   ========================================================================== */
.adm-main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }

.adm-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--adm-topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.adm-burger { display: none; }

.adm-crumb {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.adm-crumb small {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-left: 10px;
  letter-spacing: 0.08em;
}

.adm-top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.adm-onair {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #fff;
  background: linear-gradient(120deg, #d92638, var(--tally));
  padding: 7px 13px;
  border-radius: 999px;
  box-shadow: 0 4px 18px -4px rgba(255, 77, 94, 0.6);
}
.adm-onair i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: tally-pulse 1.1s ease-in-out infinite;
}

.adm-clock {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.adm-clock-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  color: var(--text-muted);
}
.adm-timecode {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--accent-2);
}

/* icone tema: mostra quella giusta */
[data-theme="dark"] #theme-toggle .icon-sun { display: none; }
[data-theme="light"] #theme-toggle .icon-moon { display: none; }

.adm-bell-dot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tally);
  box-shadow: 0 0 6px var(--tally);
}

.adm-bell-pop {
  position: fixed;
  top: calc(var(--adm-topbar-h) + 8px);
  right: 22px;
  z-index: 90;
  width: min(340px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 10px;
  animation: adm-pop-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes adm-pop-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
}
.bp-head {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 10px 8px;
}
.bp-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text);
  transition: background-color 0.15s ease;
}
.bp-item:hover { background: var(--surface-2); }
.bp-item .bp-ico { flex: none; font-size: 1rem; line-height: 1.3; }
.bp-item small { display: block; color: var(--text-muted); font-size: 0.72rem; }
.bp-empty { padding: 18px 10px; color: var(--text-muted); font-size: 0.85rem; text-align: center; }

/* ==========================================================================
   VISTA — contenitore, intestazioni pagina
   ========================================================================== */
.adm-view {
  flex: 1;
  padding: 26px 26px 40px;
  max-width: 1460px;
  width: 100%;
  margin-inline: auto;
  outline: none;
}

.adm-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  justify-content: space-between;
  padding: 14px 26px 20px;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.adm-foot-medusa strong { color: var(--accent); }

.adm-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 18px;
  margin-bottom: 22px;
}
.adm-page-title {
  font-size: clamp(1.3rem, 2.4vw, 1.7rem);
  margin: 0;
}
.adm-page-sub {
  flex-basis: 100%;
  order: 3;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
  max-width: 72ch;
}
.adm-page-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

.btn-sm { padding: 8px 16px; font-size: 0.85rem; }

/* ==========================================================================
   CARD "MONITOR" — il modulo base della regia
   ========================================================================== */
.adm-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.adm-card-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.adm-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-teal);
  box-shadow: 0 0 7px var(--glow-teal);
  flex: none;
}
.adm-led.is-warn { background: var(--st-warn); box-shadow: 0 0 7px color-mix(in srgb, var(--st-warn) 60%, transparent); }
.adm-led.is-live { background: var(--tally); box-shadow: 0 0 7px var(--tally); animation: tally-pulse 1.2s ease-in-out infinite; }
.adm-card-title {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.adm-card-head .adm-card-cta {
  margin-left: auto;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent-2);
}
.adm-card-body { padding: 18px; }
.adm-card-body.is-flush { padding: 0; }

/* entrata scenografica in cascata */
.adm-in {
  opacity: 0;
  animation: adm-in 0.55s cubic-bezier(0.2, 0.8, 0.25, 1) forwards;
  animation-delay: var(--d, 0ms);
}
@keyframes adm-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ==========================================================================
   DASHBOARD — KPI wall, grafici, feed
   ========================================================================== */
.adm-grid-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.kpi-card { padding: 16px 18px 14px; }
.kpi-card::after {
  /* scanline sottilissima da monitor CRT */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(127, 127, 127, 0.05) 3px 4px);
}
.kpi-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 2.4vw, 1.85rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  font-size: 0.74rem;
  font-weight: 600;
}
.kpi-trend.up { color: var(--st-ok); }
.kpi-trend.down { color: var(--st-bad); }
.kpi-trend small { color: var(--text-muted); font-weight: 400; }

.adm-row {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}
.adm-row.cols-main { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.adm-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.adm-row.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- grafici SVG ---------- */
.chart-area { width: 100%; height: auto; display: block; }
.chart-fill { opacity: 0.9; }
.chart-line {
  fill: none;
  stroke: var(--brand-teal);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: chart-draw 1.4s cubic-bezier(0.4, 0, 0.2, 1) 0.25s forwards;
  filter: drop-shadow(0 4px 8px var(--glow-teal));
}
@keyframes chart-draw { to { stroke-dashoffset: 0; } }
.chart-dot { fill: var(--brand-teal); }
.chart-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  fill: var(--text-muted);
}
.chart-gridline { stroke: var(--adm-line); stroke-width: 1; }

.bars-chart .bar {
  fill: url(#adm-bar-grad);
  rx: 3;
  transform-origin: bottom;
  transform-box: fill-box;
  animation: bar-in 0.7s cubic-bezier(0.2, 0.8, 0.25, 1) backwards;
  animation-delay: var(--d, 0ms);
}
@keyframes bar-in { from { transform: scaleY(0); } }

.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut-svg { flex: none; }
.donut-seg {
  fill: none;
  stroke-width: 3.6;
  stroke-linecap: butt;
  animation: seg-in 1s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  animation-delay: var(--d, 0ms);
}
@keyframes seg-in { from { stroke-dasharray: 0 100; } }
.donut-center {
  font-family: var(--font-mono);
  font-weight: 700;
  fill: var(--text);
  font-size: 6.5px;
}
.donut-center-sub { font-family: var(--font-mono); fill: var(--text-muted); font-size: 2.6px; letter-spacing: 0.12em; }

.legend { display: flex; flex-direction: column; gap: 9px; min-width: 150px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 0.84rem; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend-row strong { margin-left: auto; font-family: var(--font-mono); font-size: 0.8rem; }
.legend-row small { color: var(--text-muted); font-size: 0.72rem; }

/* barre orizzontali (canali) */
.hbar-row { display: grid; grid-template-columns: 74px 1fr 60px; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 0.84rem; }
.hbar-row:last-child { margin-bottom: 0; }
.hbar-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.hbar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--grad-brand);
  animation: vu-in 0.9s cubic-bezier(0.2, 0.8, 0.25, 1) backwards;
  animation-delay: var(--d, 0ms);
}
.hbar-val { font-family: var(--font-mono); font-size: 0.78rem; text-align: right; }

/* funnel */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-step { display: grid; grid-template-columns: 110px 1fr 74px; gap: 12px; align-items: center; font-size: 0.84rem; }
.funnel-bar-track { height: 22px; border-radius: 7px; background: var(--surface-2); overflow: hidden; }
.funnel-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(100deg,
    color-mix(in srgb, var(--brand-purple) 75%, transparent),
    color-mix(in srgb, var(--brand-teal) 75%, transparent));
  animation: vu-in 0.9s cubic-bezier(0.2, 0.8, 0.25, 1) backwards;
  animation-delay: var(--d, 0ms);
}
.funnel-val { font-family: var(--font-mono); font-size: 0.78rem; text-align: right; }
.funnel-val small { display: block; color: var(--text-muted); font-size: 0.66rem; }

/* ---------- card prossima diretta ---------- */
.live-card .adm-card-body { display: flex; flex-direction: column; gap: 12px; }
.live-count {
  font-family: var(--font-mono);
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
[data-theme="dark"] .live-count { background: linear-gradient(100deg, #c9a6d6, #8fe0e4); -webkit-background-clip: text; background-clip: text; }
.live-ep { font-weight: 600; font-size: 0.95rem; line-height: 1.4; }
.live-meta { color: var(--text-muted); font-size: 0.8rem; display: flex; flex-direction: column; gap: 4px; }
.live-onair-note {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--tally);
  letter-spacing: 0.14em;
}

/* ---------- VU meter scorte ---------- */
.vu-row {
  display: grid;
  grid-template-columns: 34px 1fr 44px;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
}
.vu-row + .vu-row { border-top: 1px dashed var(--border); }
.vu-thumb {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--vetrina);
  padding: 3px;
}
.vu-info { min-width: 0; }
.vu-name {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}
.vu-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  container-type: inline-size;
}
.vu-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--st-bad), var(--st-warn) 40%, var(--st-ok) 75%);
  /* gradiente scalato sull'INTERA track: il colore in punta indica il livello */
  background-size: 100cqw 100%;
  background-repeat: no-repeat;
  animation: vu-in 0.9s cubic-bezier(0.2, 0.8, 0.25, 1) backwards;
  animation-delay: var(--d, 0ms);
}
@keyframes vu-in { from { width: 0; } }
.vu-val {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.vu-val.is-low { color: var(--st-bad); font-weight: 700; }

/* il backdrop mobile resta fuori dal flusso del grid a QUALSIASI larghezza
   (senza questa regola base, sopra 960px un backdrop non-hidden diventerebbe
   un grid item e schiaccerebbe tutto il pannello nella colonna della sidebar) */
.adm-backdrop { position: fixed; inset: 0; }

/* ---------- wishlist ---------- */
.wish-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 0;
  font-size: 0.84rem;
}
.wish-row + .wish-row { border-top: 1px dashed var(--border); }
.wish-row .wish-n {
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
}
.wish-note { font-size: 0.72rem; color: var(--text-muted); margin: 10px 0 0; }

/* ---------- feed di regia ---------- */
.feed { display: flex; flex-direction: column; }
.feed-item {
  position: relative;
  display: flex;
  gap: 14px;
  padding: 10px 0 10px 22px;
  font-size: 0.85rem;
  line-height: 1.5;
}
.feed-item::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.feed-item:first-child::before { top: 18px; }
.feed-item:last-child::before { bottom: auto; height: 18px; }
.feed-dot {
  position: absolute;
  left: 0;
  top: 15px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--brand-teal);
}
.feed-dot.is-warn { background: var(--st-warn); }
.feed-dot.is-bad { background: var(--tally); }
.feed-dot.is-purple { background: var(--brand-purple); }
.feed-time {
  flex: none;
  width: 92px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  padding-top: 2px;
}
.feed-txt { min-width: 0; }
.feed-txt a { font-weight: 600; }

/* ==========================================================================
   TABELLE
   ========================================================================== */
.adm-table-wrap { overflow-x: auto; }
.adm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.adm-table th {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.adm-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.adm-table tbody tr { transition: background-color 0.15s ease, transform 0.15s ease; }
.adm-table tbody tr:hover { background: color-mix(in srgb, var(--brand-teal) 5%, transparent); }
.adm-table tbody tr[data-href] { cursor: pointer; }
.adm-table tbody tr:last-child td { border-bottom: 0; }
.adm-table .ta-r { text-align: right; }
.adm-table td.ta-r { font-family: var(--font-mono); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.id-mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-2);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.thumb {
  width: 42px;
  height: 42px;
  border-radius: 9px;
  object-fit: contain;
  background: var(--vetrina);
  padding: 3px;
  flex: none;
}
.thumb-ph {
  width: 42px;
  height: 42px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--grad-brand-soft);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--accent);
  flex: none;
}
.cell-prod { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.cell-prod .cp-t { font-weight: 600; line-height: 1.3; }
.cell-prod small { display: block; color: var(--text-muted); font-size: 0.72rem; font-weight: 400; }

.adm-empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- chip di stato ---------- */
.chip-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.chip-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-status.ok   { color: var(--st-ok);   background: color-mix(in srgb, var(--st-ok) 13%, transparent); }
.chip-status.warn { color: var(--st-warn); background: color-mix(in srgb, var(--st-warn) 13%, transparent); }
.chip-status.bad  { color: var(--st-bad);  background: color-mix(in srgb, var(--st-bad) 13%, transparent); }
.chip-status.info { color: var(--st-info); background: color-mix(in srgb, var(--st-info) 13%, transparent); }
.chip-status.muted { color: var(--text-muted); background: var(--surface-2); }

.src-chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
}
.src-chip.is-site { color: var(--accent-2); border-color: color-mix(in srgb, var(--brand-teal) 45%, transparent); }

/* ---------- toolbar filtri ---------- */
.adm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.adm-tabs { display: flex; flex-wrap: wrap; gap: 7px; }
.adm-tab {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  transition: all 0.18s ease;
}
.adm-tab:hover { color: var(--text); border-color: var(--brand-teal); }
.adm-tab.is-active {
  background: var(--grad-brand);
  border-color: transparent;
  color: var(--btn-primary-text);
}
.adm-tab .n { font-family: var(--font-mono); font-size: 0.7rem; margin-left: 5px; opacity: 0.8; }

.adm-search-input {
  margin-left: auto;
  min-width: 200px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
}
.adm-search-input:focus { outline: 2px solid var(--brand-teal); outline-offset: 1px; }

/* ==========================================================================
   DETTAGLI (ordine / cliente / prodotto)
   ========================================================================== */
.adm-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr);
  gap: 16px;
  align-items: start;
}

.adm-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.adm-back:hover { color: var(--accent-2); text-decoration: none; }

.order-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
}
.order-item + .order-item { border-top: 1px dashed var(--border); }
.order-item .oi-t { font-weight: 600; font-size: 0.88rem; line-height: 1.35; }
.order-item .oi-t small { display: block; color: var(--text-muted); font-weight: 400; font-size: 0.74rem; }
.order-item .oi-price { margin-left: auto; font-family: var(--font-mono); font-size: 0.85rem; white-space: nowrap; }

.order-totals { border-top: 1px solid var(--border-strong); margin-top: 6px; padding-top: 12px; }
.order-totals .kv-row { display: flex; justify-content: space-between; font-size: 0.86rem; padding: 4px 0; }
.order-totals .kv-row span:last-child { font-family: var(--font-mono); }
.order-totals .kv-row.total { font-weight: 700; font-size: 1rem; padding-top: 10px; }
.order-totals .kv-row.disc span:last-child { color: var(--st-ok); }

.adm-kv { display: flex; flex-direction: column; gap: 10px; font-size: 0.86rem; }
.adm-kv .kv { display: flex; justify-content: space-between; gap: 14px; }
.adm-kv .kv b { font-weight: 600; }
.adm-kv .kv span:first-child { color: var(--text-muted); }
.adm-kv .kv .mono { font-family: var(--font-mono); font-size: 0.78rem; }

.tl-item { position: relative; padding: 0 0 16px 22px; font-size: 0.84rem; line-height: 1.45; }
.tl-item::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: -6px;
  width: 1px;
  background: var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-dot {
  position: absolute;
  left: 0;
  top: 5px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--brand-purple);
  border: 2px solid var(--surface);
}
.tl-item:first-child .tl-dot { background: var(--brand-teal); box-shadow: 0 0 8px var(--glow-teal); }
.tl-time { display: block; font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-muted); margin-top: 2px; }

.adm-btn-row { display: flex; flex-wrap: wrap; gap: 9px; }
.adm-btn-row .btn { flex: 1 1 auto; }
.btn-danger {
  border: 1px solid color-mix(in srgb, var(--st-bad) 50%, transparent);
  color: var(--st-bad);
  background: transparent;
}
.btn-danger:hover { background: color-mix(in srgb, var(--st-bad) 10%, transparent); transform: translateY(-1px); }

/* ==========================================================================
   FORM
   ========================================================================== */
.adm-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.adm-field { display: flex; flex-direction: column; gap: 6px; }
.adm-field.span-2 { grid-column: span 2; }
.adm-field > label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.adm-input, .adm-select, .adm-textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.18s ease;
}
.adm-input:focus, .adm-select:focus, .adm-textarea:focus {
  outline: none;
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-teal) 18%, transparent);
}
.adm-textarea { resize: vertical; min-height: 90px; }
.adm-select { appearance: auto; }
.adm-field .hint { font-size: 0.7rem; color: var(--text-muted); }

/* switch */
.adm-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.adm-switch input { position: absolute; opacity: 0; pointer-events: none; }
.adm-switch .sw {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  transition: background-color 0.2s ease, border-color 0.2s ease;
  flex: none;
}
.adm-switch .sw::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 4px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--text-muted);
  transform: translateY(-50%);
  transition: transform 0.22s cubic-bezier(0.3, 1.2, 0.4, 1), background-color 0.2s ease;
}
.adm-switch input:checked + .sw { background: var(--grad-brand); border-color: transparent; }
.adm-switch input:checked + .sw::after { transform: translate(17px, -50%); background: #fff; }
.adm-switch input:focus-visible + .sw { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ==========================================================================
   PRODOTTI — editor
   ========================================================================== */
.prod-preview { display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.prod-preview img {
  max-height: 240px;
  object-fit: contain;
  background: var(--vetrina);
  border-radius: 12px;
  padding: 14px;
}
.prod-preview .pp-price { font-family: var(--font-mono); font-size: 1.2rem; font-weight: 700; }
.prod-preview .pp-price s { color: var(--text-muted); font-size: 0.85rem; font-weight: 400; margin-right: 8px; }

.variant-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  font-size: 0.85rem;
}
.variant-row .src-chip { margin-left: auto; }

/* ==========================================================================
   SCONTI
   ========================================================================== */
.disc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}
.disc-card { display: flex; flex-direction: column; }
.disc-card .adm-card-body { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.disc-code {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.disc-desc { font-size: 0.83rem; color: var(--text-muted); margin: 0; flex: 1; }
.disc-usage { display: flex; flex-direction: column; gap: 6px; font-size: 0.76rem; color: var(--text-muted); }
.disc-usage .du-track { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.disc-usage .du-fill { height: 100%; background: var(--grad-brand); border-radius: inherit; }
.disc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.disc-new {
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 600;
  gap: 4px;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}
.disc-new:hover { border-color: var(--brand-teal); color: var(--accent-2); background: color-mix(in srgb, var(--brand-teal) 5%, transparent); }
.disc-new .plus { font-size: 1.6rem; line-height: 1; }

/* ==========================================================================
   LIVE & PRENOTAZIONI
   ========================================================================== */
.ep-row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 13px 0;
}
.ep-row + .ep-row { border-top: 1px dashed var(--border); }
.ep-date {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--accent-2);
  text-transform: uppercase;
}
.ep-date b { display: block; font-size: 1.05rem; color: var(--text); }
.ep-title { font-weight: 600; font-size: 0.9rem; line-height: 1.35; }
.ep-title small { display: block; color: var(--text-muted); font-weight: 400; font-size: 0.74rem; margin-top: 2px; }

.book-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  font-size: 0.86rem;
}
.book-row + .book-row { border-top: 1px dashed var(--border); }
.book-slot-chip {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent);
  background: color-mix(in srgb, var(--brand-purple) 14%, transparent);
  padding: 4px 10px;
  border-radius: 8px;
  flex: none;
}
.book-row .book-name { font-weight: 600; }
.book-row .book-when { color: var(--text-muted); font-size: 0.74rem; }
.book-row .adm-btn-mini { margin-left: auto; }

.adm-btn-mini {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.adm-btn-mini:hover { border-color: var(--brand-teal); color: var(--accent-2); }
.adm-btn-mini.is-done { border-color: transparent; background: color-mix(in srgb, var(--st-ok) 14%, transparent); color: var(--st-ok); }

/* ==========================================================================
   IMPOSTAZIONI
   ========================================================================== */
.set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 16px;
  align-items: start;
}
.set-list { display: flex; flex-direction: column; }
.set-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  font-size: 0.87rem;
}
.set-item + .set-item { border-top: 1px dashed var(--border); }
.set-item .si-desc { min-width: 0; }
.set-item .si-desc small { display: block; color: var(--text-muted); font-size: 0.74rem; }
.set-item .adm-switch, .set-item .chip-status, .set-item .mono-val { margin-left: auto; }
.mono-val { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent-2); }

.api-key {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 10px 14px;
  overflow-x: auto;
  white-space: nowrap;
}
.api-key button { margin-left: auto; }

.medusa-map { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.medusa-map td { padding: 8px 6px; border-bottom: 1px dashed var(--border); }
.medusa-map td:last-child {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--accent-2);
  text-align: right;
}
.medusa-map tr:last-child td { border-bottom: 0; }

.adm-danger { border-color: color-mix(in srgb, var(--st-bad) 35%, transparent); }
.adm-danger .adm-card-title { color: var(--st-bad); }
.adm-danger .adm-led { background: var(--st-bad); box-shadow: 0 0 7px color-mix(in srgb, var(--st-bad) 60%, transparent); }

/* ==========================================================================
   RICERCA GLOBALE (Ctrl+K)
   ========================================================================== */
#adm-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 18px 18px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
#adm-search-overlay.is-open { opacity: 1; }

.adm-search-panel {
  width: min(620px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  transform: translateY(-10px) scale(0.98);
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
#adm-search-overlay.is-open .adm-search-panel { transform: none; }

.adm-search-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.adm-search-head svg { width: 19px; height: 19px; color: var(--text-muted); flex: none; }
.adm-search-head input {
  flex: 1;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  outline: none;
}
.adm-search-head kbd {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 3px 7px;
}

.adm-search-results { max-height: 52vh; overflow-y: auto; padding: 8px; }
.adm-search-group {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 12px 5px;
}
.adm-search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.87rem;
  transition: background-color 0.12s ease;
}
.adm-search-row:hover, .adm-search-row.is-selected { background: var(--surface-2); }
.adm-search-row .sr-main { min-width: 0; }
.adm-search-row .sr-main small { display: block; color: var(--text-muted); font-size: 0.72rem; }
.adm-search-row .sr-side { margin-left: auto; flex: none; }
.adm-search-empty { padding: 30px 16px; text-align: center; color: var(--text-muted); font-size: 0.88rem; }

/* ==========================================================================
   MODALI + TOAST
   ========================================================================== */
.adm-modal {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: grid;
  place-items: center;
  padding: 20px;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.adm-modal-box {
  width: min(480px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 24px;
  animation: adm-pop-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.adm-modal-box h3 { font-size: 1.05rem; margin-bottom: 16px; }
.adm-modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.adm-modal-actions .btn { flex: 1; }

#adm-toasts {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.adm-toast {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-pop);
  animation: adm-toast-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2), adm-toast-out 0.3s ease 2.8s forwards;
}
@keyframes adm-toast-in { from { opacity: 0; transform: translateY(14px) scale(0.95); } }
@keyframes adm-toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ==========================================================================
   FATTURE — overlay + foglio "carta" (sempre chiaro, in entrambi i temi)
   ========================================================================== */
#invoice-overlay {
  position: fixed;
  inset: 0;
  z-index: 340;
  overflow-y: auto;
  background: color-mix(in srgb, var(--bg) 65%, transparent);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  padding: 4vh 16px 6vh;
  opacity: 0;
  transition: opacity 0.2s ease;
}
#invoice-overlay.is-open { opacity: 1; }

.inv-wrap { width: min(680px, 100%); margin-inline: auto; }

.inv-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.inv-tb-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-right: auto;
}
.inv-tb-title b { color: var(--accent-2); }

.inv-sheet {
  position: relative;
  background: #ffffff;
  color: #221d2c;
  border-radius: 14px;
  padding: 0 44px 30px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  transform: translateY(10px) scale(0.985);
  transition: transform 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
#invoice-overlay.is-open .inv-sheet { transform: none; }
.inv-sheet p { margin: 0; }

.inv-watermark {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%) rotate(-32deg);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(3.2rem, 12vw, 5.4rem);
  letter-spacing: 0.08em;
  color: rgba(90, 70, 110, 0.07);
  pointer-events: none;
  white-space: nowrap;
}

.inv-bar {
  height: 7px;
  margin: 0 -44px;
  background: linear-gradient(90deg, #9f72ac, #74cace);
}

.inv-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 26px 0 18px;
  border-bottom: 1px solid #e8e4ee;
}
.inv-brand {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  color: #7a5187;
}
.inv-tagline { font-size: 0.68rem; color: #6a6377; margin-top: 4px; }
.inv-doc { text-align: right; }
.inv-doc-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.03em;
}
.inv-doc-title.is-fattura { color: #7a5187; }
.inv-doc-title.is-proforma { color: #9c6500; }
.inv-doc-title.is-nota { color: #c22940; }
.inv-doc-meta { font-size: 0.76rem; color: #6a6377; margin-top: 7px; line-height: 1.65; }
.inv-doc-meta b { color: #221d2c; font-family: var(--font-mono); font-size: 0.72rem; }

.inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 18px 0;
}
.inv-parties h5 {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #8d8698;
  margin: 0 0 7px;
}
.inv-parties strong { font-size: 0.88rem; display: block; margin-bottom: 4px; }
.inv-parties p { font-size: 0.76rem; color: #6a6377; line-height: 1.6; }

.inv-table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.inv-table th {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8d8698;
  background: #f5f2f8;
  text-align: right;
  padding: 9px 12px;
}
.inv-table th:first-child { text-align: left; border-radius: 8px 0 0 8px; }
.inv-table th:last-child { border-radius: 0 8px 8px 0; }
.inv-table td {
  padding: 12px;
  border-bottom: 1px solid #eee9f2;
  text-align: right;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
  vertical-align: top;
}
.inv-table td:first-child { text-align: left; }
.inv-table td b { font-size: 0.85rem; }
.inv-table td small { display: block; color: #8d8698; font-size: 0.7rem; margin-top: 3px; }

.inv-totals { margin-left: auto; width: min(280px, 100%); padding: 14px 0 4px; }
.inv-tot-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #6a6377;
  padding: 3px 0;
  font-variant-numeric: tabular-nums;
}
.inv-tot-row span:last-child { color: #221d2c; }
.inv-tot-row.is-disc span:last-child { color: #0e8a63; }
.inv-tot-row.is-total {
  border-top: 1px solid #ddd6e4;
  margin-top: 8px;
  padding-top: 10px;
  font-weight: 700;
  font-size: 0.98rem;
  color: #221d2c;
}
.inv-tot-row.is-total span:last-child { color: #7a5187; font-size: 1.08rem; }
.inv-tot-sub {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #8d8698;
  padding: 2px 0;
}
.inv-fiscal-note { font-size: 0.7rem; color: #8d8698; max-width: 46ch; line-height: 1.55; margin: 2px 0 0; }

.inv-pay {
  position: relative;
  background: #f5f2f8;
  border-radius: 10px;
  padding: 14px 16px 12px 20px;
  margin-top: 18px;
  overflow: hidden;
}
.inv-pay::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: #7a5187; }
.inv-pay.is-warn::before { background: #c98a00; }
.inv-pay.is-bad::before { background: #c22940; }
.inv-pay-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.inv-pay-head b { font-size: 0.85rem; }
.inv-pay-status {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #0e8a63;
}
.inv-pay.is-warn .inv-pay-status { color: #9c6500; }
.inv-pay.is-bad .inv-pay-status { color: #c22940; }
.inv-pay p { font-size: 0.76rem; color: #6a6377; line-height: 1.7; }

.inv-foot { border-top: 1px solid #e8e4ee; margin-top: 20px; padding-top: 12px; }
.inv-foot p { font-size: 0.68rem; color: #8d8698; line-height: 1.7; }
.inv-foot p b { color: #221d2c; }

@media (max-width: 560px) {
  .inv-sheet { padding: 0 20px 22px; }
  .inv-bar { margin: 0 -20px; }
  .inv-parties { grid-template-columns: 1fr; gap: 14px; }
}

/* stampa: solo il foglio, su carta */
@media print {
  body.inv-printing > *:not(#invoice-overlay) { display: none !important; }
  body.inv-printing #invoice-overlay {
    position: static;
    padding: 0;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    opacity: 1;
    overflow: visible;
  }
  body.inv-printing .inv-toolbar { display: none; }
  body.inv-printing .inv-wrap { width: 100%; }
  body.inv-printing .inv-sheet { box-shadow: none; border-radius: 0; transform: none; }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1120px) {
  .adm-row.cols-3 { grid-template-columns: 1fr 1fr; }
  .adm-row.cols-main { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .admin-body { grid-template-columns: 1fr; }
  .adm-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 84vw);
    transform: translateX(-102%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.25, 1);
    box-shadow: var(--shadow-pop);
  }
  .admin-body.nav-open .adm-sidebar { transform: none; }
  .adm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: color-mix(in srgb, var(--bg) 55%, transparent);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }
  .adm-burger { display: inline-flex; }
  .adm-clock { display: none; }
  .adm-view { padding: 18px 16px 32px; }
  .adm-topbar { padding: 0 16px; }
  .adm-detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .adm-row.cols-3, .adm-row.cols-2 { grid-template-columns: 1fr; }
  .adm-form-grid { grid-template-columns: 1fr; }
  .adm-field.span-2 { grid-column: auto; }
  .adm-onair { display: none; }
  .funnel-step { grid-template-columns: 84px 1fr 64px; }
  .adm-page-actions { margin-left: 0; }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .adm-in, .chart-line, .bars-chart .bar, .donut-seg, .vu-fill, .hbar-fill,
  .funnel-bar, .adm-toast, .adm-tally-dot, .adm-onair i, .adm-led.is-live {
    animation: none !important;
  }
  .chart-line { stroke-dashoffset: 0; }
  .adm-in { opacity: 1; }
  .adm-sidebar { transition: none; }
}

/* ==========================================================================
   === F5 documenti ===
   Overlay documenti fiscali (RegiaDocs, js/api-documenti.js): righe
   PF/FT/NC con azioni PDF. Solo token esistenti — estetica invariata.
   ========================================================================== */
.docs-list { display: flex; flex-direction: column; }
.doc-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 0; }
.doc-row + .doc-row { border-top: 1px dashed var(--border); }
.doc-row .doc-info b { font-size: 0.82rem; }
.doc-row .doc-info small { display: block; color: var(--text-muted); font-size: 0.68rem; margin-top: 2px; }
.doc-row .doc-actions { display: flex; gap: 8px; flex-shrink: 0; }
.docs-emit-note { font-size: 0.74rem; color: var(--text-muted); margin: 0 0 10px; }

@media (max-width: 680px) {
  .doc-row { grid-template-columns: auto 1fr; }
  .doc-row .doc-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
