/* ════════════════════════════════════════════════════════════════════
   v3.14.38 — RETURNS MANAGER: NUOVA INTERFACCIA (solo body.tw-rev)
   Aspetto del mockup REVAMP/twiza-fashion-returns-mockup, stesso sistema di
   Collection Manager, Sourcing & Compliance e Atelier Copydesk: stessi token
   --ld-* (valori identici a twiza-template/style.css, «LEGAL DRAFTER REVAMP»).
   Caricato SOLO da index.html, dopo style.css: customer-demo.html (storefront
   demo) non lo carica e resta com'era. Stessi id, stesse funzioni di app.js.
   ════════════════════════════════════════════════════════════════════ */

/* ---- Token (tema scuro = default, chiaro via :root[data-theme="light"]) ---- */
body.tw-rev {
  --ld-bg: #0a0b18; --ld-panel: #0d1123; --ld-surface: #161937; --ld-surface2: #1f2347;
  --ld-line: #272b52; --ld-divider: #353a66;
  --ld-text: #ecebf6; --ld-muted: #a8abc9; --ld-faint: #8b8eb2;
  --ld-accent: #d81b60; --ld-accent-hover: #c2185b; --ld-accent-text: #ff6aa2; --ld-accent-soft: rgba(216,27,96,.16);
  --ld-ok: #43d39a; --ld-warn: #f3bd4e; --ld-warn-text: #f3bd4e; --ld-blue: #7fb2ff; --ld-danger-text: #ff8484;
  --ld-shadow: 0 18px 48px rgba(0,0,0,.5);
  --sidebar-w: clamp(236px, 18vw, 300px); --sidebar-mini: 64px;
  /* Rimappa i token di style.css → modali, grafici e componenti esistenti ereditano la palette */
  --bg-deep: var(--ld-bg); --bg-base: var(--ld-bg); --bg-card: var(--ld-panel);
  --bg-elevated: var(--ld-surface); --bg-hover: var(--ld-surface2);
  --text-primary: var(--ld-text); --text-secondary: var(--ld-muted); --text-muted: var(--ld-faint);
  --border: var(--ld-line); --border-light: var(--ld-divider);
  --accent: var(--ld-accent); --accent-dark: var(--ld-accent-hover); --accent-soft: var(--ld-accent-soft);
  --ok: var(--ld-ok); --ok-soft: rgba(67,211,154,.16);
  --warn: var(--ld-warn); --warn-soft: rgba(243,189,78,.18);
  --danger: #e05555; --danger-soft: rgba(224,85,85,.18);
  --info: var(--ld-blue); --info-soft: rgba(127,178,255,.18);
  --radius: 14px; --radius-sm: 8px; --shadow: var(--ld-shadow);
  font-family: 'Titillium Web', 'Segoe UI', system-ui, sans-serif;
  font-size: 14.5px; line-height: 1.5;
  background: var(--ld-bg) !important; background-image: none !important;
  color: var(--ld-text); height: 100vh; overflow: hidden;
}
:root[data-theme="light"] body.tw-rev {
  --ld-bg: #eef0f6; --ld-panel: #ffffff; --ld-surface: #f6f7fb; --ld-surface2: #e9ebf4;
  --ld-line: #d9dce9; --ld-divider: #cfd3e3;
  --ld-text: #161831; --ld-muted: #50546f; --ld-faint: #62667f;
  --ld-accent: #c2185b; --ld-accent-hover: #ad1457; --ld-accent-text: #b0124f; --ld-accent-soft: rgba(194,24,91,.10);
  --ld-warn-text: #8a5a00; --ld-ok: #1c8a5c; --ld-blue: #2f6fd6; --ld-danger-text: #b03434;
  --ld-shadow: 0 18px 48px rgba(20,22,50,.18);
  --danger: #b03434;
}
body.tw-rev::before { display: none !important; }            /* niente aurora: fondo piatto come gli altri variant */
body.tw-rev .foot, body.tw-rev .shaka { display: none !important; }
body.tw-rev b, body.tw-rev strong { font-weight: 600; }
body.tw-rev ::selection { background: var(--ld-accent); color: #fff; }
body.tw-rev .rm-grow { flex: 1; }
body.tw-rev [hidden] { display: none !important; }

/* ---- Guscio: barra laterale | area principale ---- */
body.tw-rev .rm-app { display: flex; width: 100vw; height: 100vh; min-width: 0; overflow: hidden; }
body.tw-rev .rm-main { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; }
body.tw-rev .rm-scroll { flex: 1; min-height: 0; overflow-y: auto; max-width: none; margin: 0; padding: 24px 28px 40px; background: var(--ld-bg);
  scrollbar-width: thin; scrollbar-color: var(--ld-line) transparent; }

/* ---- Barra laterale ---- */
body.tw-rev .rm-sb { width: var(--sidebar-w); flex-shrink: 0; height: 100%; display: flex; flex-direction: column; background: var(--ld-panel); border-right: 1px solid var(--ld-line); transition: width .25s cubic-bezier(.2,.8,.2,1); }
body.tw-rev .rm-sb-top { padding: 18px 16px 16px; display: flex; flex-direction: column; gap: 14px; border-bottom: 1px solid var(--ld-line); }
body.tw-rev .rm-brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
body.tw-rev .rm-brand-lock { display: flex; align-items: flex-end; gap: 8px; min-width: 0; }
body.tw-rev .rm-brand-logo { height: 36px; width: auto; display: block; }                 /* come .sidebar-twiza-logo-img nel template */
body.tw-rev .rm-brand-mark { display: none; width: 34px; height: 34px; }
body.tw-rev .rm-brand-word { font-size: 19px; color: var(--ld-text); line-height: 1; padding-bottom: 2px; }
body.tw-rev .rm-iconbtn { width: 36px; height: 36px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; border: 0; background: none; color: var(--ld-muted); cursor: pointer; padding: 0; font: inherit; }
body.tw-rev .rm-iconbtn:hover { background: var(--ld-surface2); color: var(--ld-text); }
body.tw-rev #themeToggle { color: var(--ld-accent-text); }

body.tw-rev .rm-env { position: relative; }
body.tw-rev .rm-env-box { width: 100%; height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--ld-line); background: transparent; color: var(--ld-text); font: inherit; text-align: left; }
body.tw-rev button.rm-env-box { cursor: pointer; }
body.tw-rev button.rm-env-box:hover { background: var(--ld-surface2); }
body.tw-rev .rm-env-static, body.tw-rev .rm-env-text { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; line-height: 1.2; min-width: 0; }
body.tw-rev .rm-env-k { font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--ld-faint); font-weight: 600; }
body.tw-rev .rm-env-v { font-size: 15px; font-weight: 600; color: var(--ld-text); }
body.tw-rev .rm-env-box svg { color: var(--ld-muted); flex: none; }
body.tw-rev .rm-pop { position: absolute; z-index: 80; background: var(--ld-panel); border: 1px solid var(--ld-line); border-radius: 12px; box-shadow: var(--ld-shadow); padding: 8px; }
body.tw-rev .rm-env-menu { top: calc(100% + 6px); left: 0; width: 100%; min-width: 0; overflow: visible; }
body.tw-rev .rm-pop-label { padding: 6px 10px 8px; }
body.tw-rev .rm-mi { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; background: none; border: 0; color: var(--ld-text); font: inherit; font-size: 14px; cursor: pointer; text-align: left; }
body.tw-rev .rm-mi span { flex: 1; min-width: 0; }
body.tw-rev .rm-mi svg { color: var(--ld-muted); flex: none; }
body.tw-rev button.rm-mi:hover { background: var(--ld-surface2); }
body.tw-rev .rm-mi-cur { font-weight: 600; cursor: default; }
body.tw-rev .rm-mi-cur svg:last-child { color: var(--ld-accent-text); }
body.tw-rev .rm-pop-note { font-size: 12px; color: var(--ld-faint); padding: 6px 10px 4px; }

body.tw-rev .rm-sb-primary { height: 44px; justify-content: center; font-size: 15px; }
body.tw-rev .rm-sb-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 18px; scrollbar-width: thin; scrollbar-color: var(--ld-line) transparent; }
body.tw-rev .rm-sb-sec { display: flex; flex-direction: column; gap: 2px; }
body.tw-rev .rm-label { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--ld-faint); font-weight: 600; }
body.tw-rev .rm-sb-label { padding: 4px 12px 8px; }
body.tw-rev .nav.rm-nav { display: flex; flex-direction: column; gap: 2px; }
body.tw-rev .nav.rm-nav .navitem { display: flex; width: 100%; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 9px; border: 0; background: none; color: var(--ld-muted); font: inherit; font-size: 14.5px; font-weight: 400; cursor: pointer; text-align: left; }
body.tw-rev .nav.rm-nav .navitem .rm-lbl { flex: 1; }
body.tw-rev .nav.rm-nav .navitem:hover { background: var(--ld-surface2); color: var(--ld-text); }
body.tw-rev .nav.rm-nav .navitem.active { background: var(--ld-accent-soft); color: var(--ld-text); font-weight: 600; border: 0; }
body.tw-rev .nav.rm-nav .navitem.active svg { color: var(--ld-accent-text); }
body.tw-rev .countpill { min-width: 26px; height: 22px; padding: 0 8px; border-radius: 7px; background: var(--ld-surface2); color: var(--ld-muted); font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
body.tw-rev .rm-qf-sec { gap: 8px; padding: 0 2px; }
body.tw-rev .rm-sechead { display: flex; width: 100%; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border-radius: 8px; border: 0; background: none; color: var(--ld-text); font: inherit; cursor: pointer; text-align: left; }
body.tw-rev .rm-sechead:hover { background: var(--ld-surface2); }
body.tw-rev .rm-sechead-t { font-size: 14px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
body.tw-rev .rm-chev { display: inline-flex; color: var(--ld-faint); transition: transform .15s; }
body.tw-rev .rm-sechead[aria-expanded="true"] .rm-chev { transform: rotate(90deg); }
body.tw-rev .rm-quick { display: flex; flex-direction: column; gap: 6px; padding: 0 4px; }
body.tw-rev .rm-qf { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--ld-line); background: transparent; color: var(--ld-muted); font: inherit; font-size: 13.5px; cursor: pointer; }
body.tw-rev .rm-qf .n { color: var(--ld-faint); font-variant-numeric: tabular-nums; }
body.tw-rev .rm-qf:hover { color: var(--ld-text); background: var(--ld-surface2); }
body.tw-rev .rm-qf.on { border-color: var(--ld-accent); color: var(--ld-accent-text); background: var(--ld-accent-soft); }
body.tw-rev .rm-user { padding: 12px 14px; border-top: 1px solid var(--ld-line); display: flex; align-items: center; gap: 10px; }
body.tw-rev .rm-avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--ld-surface2); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--ld-muted); }
body.tw-rev .rm-user-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
body.tw-rev .rm-user-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.tw-rev .rm-user-role { font-size: 12px; color: var(--ld-faint); }

/* Barra compressa: solo icone */
body.tw-rev .rm-sb-mini .rm-sb { width: var(--sidebar-mini); }
body.tw-rev .rm-sb-mini .rm-sb-top { padding: 14px 10px; align-items: center; }
body.tw-rev .rm-sb-mini .rm-brand { flex-direction: column; }
body.tw-rev .rm-sb-mini .rm-brand-mark { display: block; }
body.tw-rev .rm-sb-mini .rm-brand-lock, body.tw-rev .rm-sb-mini .rm-env,
body.tw-rev .rm-sb-mini .rm-sb-label, body.tw-rev .rm-sb-mini .rm-qf-sec,
body.tw-rev .rm-sb-mini .rm-lbl, body.tw-rev .rm-sb-mini .countpill, body.tw-rev .rm-sb-mini .rm-user-txt { display: none !important; }
body.tw-rev .rm-sb-mini .rm-sb-primary { width: 44px; height: 44px; padding: 0; }
body.tw-rev .rm-sb-mini .rm-sb-scroll { padding: 12px 10px; align-items: center; }
body.tw-rev .rm-sb-mini .nav.rm-nav .navitem { width: 44px; justify-content: center; padding: 0; }
body.tw-rev .rm-sb-mini .rm-user { justify-content: center; padding: 12px 0; }

/* ---- Barra in alto ---- */
body.tw-rev .rm-top { height: 64px; flex-shrink: 0; display: flex; align-items: center; gap: clamp(4px, .8vw, 12px); padding: 0 16px; background: var(--ld-panel); border-bottom: 1px solid var(--ld-line); min-width: 0; }
body.tw-rev .rm-top #period { width: auto; min-width: 190px; height: 40px; padding: 0 34px 0 12px; }
body.tw-rev .rm-vdiv { width: 1px; height: 22px; background: var(--ld-line); flex-shrink: 0; }
body.tw-rev .rm-top .btn.rm-tb { height: 36px; padding: 0 12px; border: 0; background: transparent; color: var(--ld-muted); font-weight: 400; font-size: 14px; }
body.tw-rev .rm-top .btn.rm-tb:hover { background: var(--ld-surface2); color: var(--ld-text); }
body.tw-rev .ctx-badge { display: none; }
body.tw-rev .ctx-badge[data-demo] { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid rgba(243,189,78,.45); color: var(--ld-warn-text); font-size: 12.5px; white-space: nowrap; background: none; }
/* Stretta: i comandi di destra diventano solo icona (etichetta nel title). */
@media (max-width: 1320px) { body.tw-rev .rm-top .btn.rm-tb .rm-lbl { display: none; } body.tw-rev .rm-top .btn.rm-tb { padding: 0 9px; } }

/* Indicatore in tempo reale */
body.tw-rev .live-ind { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(67,211,154,.4); background: none; color: var(--ld-ok); font-size: 12.5px; font-weight: 400; white-space: nowrap; }
body.tw-rev .live-ind .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ld-ok); }
body.tw-rev .live-ind.off { border-color: var(--ld-line); color: var(--ld-faint); background: none; }
body.tw-rev .live-ind.off .dot { background: var(--ld-faint); }

/* ---- Controlli ---- */
body.tw-rev .btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent; background: var(--ld-accent); color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; filter: none; transition: background .15s; }
body.tw-rev .btn:hover { background: var(--ld-accent-hover); filter: none; }
body.tw-rev .btn.ghost { background: transparent; border-color: var(--ld-line); color: var(--ld-text); font-weight: 400; }
body.tw-rev .btn.ghost:hover { background: var(--ld-surface2); }
body.tw-rev .btn.sm { height: 32px; padding: 0 12px; font-size: 13.5px; }
body.tw-rev .btn:disabled { opacity: .5; cursor: default; }
body.tw-rev select, body.tw-rev input[type=text], body.tw-rev input[type=email], body.tw-rev input[type=number], body.tw-rev input[type=search], body.tw-rev textarea {
  width: 100%; height: 40px; background: var(--ld-surface); border: 1px solid var(--ld-line); border-radius: 8px; padding: 0 12px; color: var(--ld-text); font: inherit; font-size: 14px; }
body.tw-rev textarea { height: auto; min-height: 88px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
body.tw-rev select { cursor: pointer; }
body.tw-rev select:focus, body.tw-rev input:focus, body.tw-rev textarea:focus { outline: none; border-color: var(--ld-accent); box-shadow: 0 0 0 3px var(--ld-accent-soft); }
body.tw-rev ::placeholder { color: var(--ld-faint); }
body.tw-rev option { background: var(--ld-surface); color: var(--ld-text); }

/* ---- Pagine ---- */
body.tw-rev .page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: nowrap; }
body.tw-rev .page-head h1 { margin: 0; font-size: 28px; font-weight: 700; line-height: 1.2; }
body.tw-rev .page-head p { margin: 4px 0 0; font-size: 14.5px; color: var(--ld-muted); }
body.tw-rev .grid { display: grid; gap: 16px; }
body.tw-rev .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
body.tw-rev .charts { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); margin-top: 16px; }
body.tw-rev .rm-queue-grid { grid-template-columns: minmax(0, 1fr); margin-top: 16px; align-items: start; }
body.tw-rev .rm-side-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
@media (max-width: 1250px) { body.tw-rev .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } body.tw-rev .charts { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1100px) { body.tw-rev .rm-side-cards { grid-template-columns: minmax(0, 1fr); } }

body.tw-rev .card { display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: 14px; border: 1px solid var(--ld-line); background: var(--ld-panel); box-shadow: none; backdrop-filter: none; }
body.tw-rev .card h3 { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ld-faint); display: flex; align-items: center; justify-content: flex-start; gap: 10px; }
body.tw-rev .card > .btn, body.tw-rev .card > button { align-self: flex-start; }
body.tw-rev .card h3 .sub { margin-left: auto; font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 12px; color: var(--ld-faint); white-space: nowrap; }
body.tw-rev .muted { color: var(--ld-faint); font-size: 12.5px; line-height: 1.5; }
body.tw-rev .divider { border: none; border-top: 1px solid var(--ld-line); margin: 4px 0; }
body.tw-rev .rm-demo-note { margin: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(243,189,78,.45); background: rgba(243,189,78,.08); color: var(--ld-warn-text); font-size: 13px; line-height: 1.5; }

/* KPI */
body.tw-rev .kpi { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; }
body.tw-rev .kpi .ic { color: var(--ld-accent-text); display: inline-flex; font-size: inherit; opacity: 1; }
body.tw-rev .kpi .v { font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: 0; }
body.tw-rev .kpi .l { font-size: 12.5px; color: var(--ld-faint); margin: 0; }
body.tw-rev .kpi .d { font-size: 12px; font-weight: 600; margin: 0; }
body.tw-rev .kpi .d.up { color: var(--ld-ok); } body.tw-rev .kpi .d.down { color: var(--ld-danger-text); } body.tw-rev .kpi .d.flat { color: var(--ld-faint); }

/* Grafici */
body.tw-rev .chart-grid line { stroke: var(--ld-line); }
body.tw-rev .chart-axis { fill: var(--ld-faint); font-size: 11px; }
body.tw-rev .trend-line { stroke: var(--ld-accent); stroke-width: 2.2; }
body.tw-rev .trend-dot { fill: var(--ld-accent); stroke: var(--ld-panel); }
body.tw-rev .chart-tip { background: var(--ld-text) !important; color: var(--ld-bg) !important; border: 0 !important; border-radius: 8px !important; font-size: 12.5px; }
body.tw-rev .chart-tip .k { color: inherit; opacity: .75; }
body.tw-rev .donut-wrap { gap: 22px; flex-wrap: nowrap; }
body.tw-rev .legend .li { font-size: 13.5px; }
body.tw-rev .legend .vl { color: var(--ld-faint); }

/* Badge */
body.tw-rev .badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--ld-surface2); color: var(--ld-muted); border: 0; }
body.tw-rev .badge.fit, body.tw-rev .badge.review, body.tw-rev .badge.age-md { background: rgba(243,189,78,.18); color: var(--ld-warn-text); }
body.tw-rev .badge.defect, body.tw-rev .badge.age-hi { background: rgba(224,85,85,.18); color: var(--ld-danger-text); }
body.tw-rev .badge.look, body.tw-rev .badge.st-classified { background: rgba(127,178,255,.18); color: var(--ld-blue); }
body.tw-rev .badge.mind, body.tw-rev .badge.new { background: var(--ld-accent-soft); color: var(--ld-accent-text); border: 0; }
body.tw-rev .badge.ok, body.tw-rev .badge.st-decided { background: rgba(67,211,154,.16); color: var(--ld-ok); }
body.tw-rev .badge.other, body.tw-rev .badge.st-intake { background: var(--ld-surface2); color: var(--ld-muted); }
body.tw-rev .pill { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 4px 10px; border-radius: 10px; border: 1px solid var(--ld-line); background: transparent; color: var(--ld-muted); font-size: 13px; line-height: 1.3; }
body.tw-rev .pill b { color: var(--ld-text); }
body.tw-rev .quote { color: var(--ld-faint); font-size: 12px; font-style: italic; margin-top: 3px; }
body.tw-rev .bar { height: 8px; border-radius: 4px; background: var(--ld-surface2); overflow: hidden; }
body.tw-rev .bar > span { display: block; height: 100%; background: var(--ld-accent); }
body.tw-rev .break-row .badge { justify-self: start; }
body.tw-rev .break-row { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) 56px; margin: 0; gap: 10px; font-size: 13px; }
body.tw-rev .break-row .n { color: var(--ld-faint); font-size: 12.5px; }
body.tw-rev #breakdown, body.tw-rev #outcomes, body.tw-rev #intel { display: flex; flex-direction: column; gap: 10px; }

/* Coda */
body.tw-rev .toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; }
body.tw-rev .toolbar select { width: auto; height: 36px; }
body.tw-rev .rm-search { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--ld-line); background: var(--ld-surface); color: var(--ld-faint); }
body.tw-rev .rm-search:focus-within { border-color: var(--ld-accent); box-shadow: 0 0 0 3px var(--ld-accent-soft); }
body.tw-rev .rm-search input { flex: 1; min-width: 0; height: 34px; border: 0 !important; background: transparent; padding: 0; box-shadow: none !important; }
body.tw-rev .rm-table-wrap { overflow-x: auto; }
body.tw-rev table.q { width: 100%; border-collapse: collapse; font-size: 13.5px; }
body.tw-rev table.q th { text-align: left; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--ld-faint); font-weight: 600; padding: 0 10px 8px; border-bottom: 0; white-space: nowrap; }
body.tw-rev table.q td { padding: 10px; border-top: 1px solid var(--ld-line); border-bottom: 0; vertical-align: middle; }
body.tw-rev table.q tbody tr:hover td { background: var(--ld-surface); }
body.tw-rev table.q td.mono { white-space: nowrap; }
body.tw-rev table.q .muted { font-size: 12px; }
body.tw-rev table.q select.act { width: 190px; height: 32px; padding: 0 8px; font-size: 13px; }
body.tw-rev table.q .apply { margin-left: 6px; }
body.tw-rev tbody tr.row-new td { animation: rmRowFlash 2.4s ease; }
@keyframes rmRowFlash { 0% { background: var(--ld-accent-soft); } 100% { background: transparent; } }
/* Sotto i 1300 px «Applica» va sotto il menu invece di allargare la tabella. */
@media (max-width: 1300px) { body.tw-rev table.q td:last-child { white-space: normal !important; } body.tw-rev table.q .apply { margin: 6px 0 0; } body.tw-rev table.q select.act { width: 150px; } body.tw-rev table.q td { padding: 10px 8px; } }

/* Product intelligence */
body.tw-rev .rm-intel { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--ld-line); background: var(--ld-surface); }
body.tw-rev .rm-intel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; }
body.tw-rev .rm-intel .push { align-self: flex-start; margin-top: 2px; }

/* ---- Policy ---- */
body.tw-rev #viewPolicy { max-width: 1100px; }
body.tw-rev .tabs { display: flex; gap: 2px; flex-wrap: nowrap; overflow-x: auto; margin: 0 0 18px; border-bottom: 1px solid var(--ld-line); }
body.tw-rev .tabs button { height: 38px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--ld-muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; margin-bottom: -1px; white-space: nowrap; }
body.tw-rev .tabs button:hover { color: var(--ld-text); }
body.tw-rev .tabs button.active { color: var(--ld-text); background: none; border-color: transparent; border-bottom-color: var(--ld-accent); }
body.tw-rev .tabpane .card { gap: 14px; }
body.tw-rev .field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
body.tw-rev .field .lbl { font-size: 13px; color: var(--ld-muted); font-weight: 400; margin: 0; }
body.tw-rev .field .hint { font-size: 12px; color: var(--ld-faint); margin: 0; }
body.tw-rev .row { display: flex; gap: 16px; flex-wrap: wrap; }
body.tw-rev .row > * { flex: 1; min-width: 180px; }
body.tw-rev .section-title { display: block; font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--ld-faint); margin: 0; }
body.tw-rev .section-title .em { color: inherit; }
body.tw-rev .check { display: flex; align-items: center; gap: 10px; font-size: 14px; margin: 0; padding: 6px 0; }
body.tw-rev .check input { width: 18px; height: 18px; flex: none; accent-color: var(--ld-accent); }
body.tw-rev .test-note { margin: 0; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--ld-line); background: var(--ld-surface); color: var(--ld-muted); font-size: 13.5px; line-height: 1.55; }
body.tw-rev .test-note b { color: var(--ld-text); }
body.tw-rev #policyDoc { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.6; border-radius: 10px; padding: 14px; }
/* Regole per segmento: una riga-scheda come nel mockup, campi modificabili come prima */
body.tw-rev #rules { display: flex; flex-direction: column; gap: 8px; }
body.tw-rev #rules .row { align-items: flex-end !important; gap: 10px; margin: 0 !important; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--ld-line); background: var(--ld-surface); flex-wrap: nowrap; }
body.tw-rev #rules .row .field .lbl { font-size: 12px; color: var(--ld-faint); }
body.tw-rev #rules .row select, body.tw-rev #rules .row input { height: 36px; background: var(--ld-panel); }
body.tw-rev #rules .rx { width: 36px; height: 36px; padding: 0; justify-content: center; border: 0; color: var(--ld-muted); }
body.tw-rev #rules .rx:hover { color: var(--ld-text); }
body.tw-rev #clsOut .card { background: var(--ld-surface); }
body.tw-rev .ai-note { font-size: 12.5px; color: var(--ld-faint); }
body.tw-rev #demoLog { background: var(--ld-bg) !important; border-color: var(--ld-line) !important; border-radius: 10px !important; color: var(--ld-muted); }

/* ---- Modale import ---- */
body.tw-rev .imp-backdrop, body.tw-rev .help-backdrop { background: rgba(5,6,16,.62); backdrop-filter: none; }
:root[data-theme="light"] body.tw-rev .imp-backdrop, :root[data-theme="light"] body.tw-rev .help-backdrop { background: rgba(22,24,49,.35); }
body.tw-rev .imp-modal { width: min(820px, 94vw); max-height: min(620px, 90vh); background: var(--ld-panel); border: 1px solid var(--ld-line); border-radius: 16px; box-shadow: var(--ld-shadow); overflow: hidden; }
body.tw-rev .imp-head { padding: 18px 20px; border-bottom: 1px solid var(--ld-line); }
body.tw-rev .imp-title { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
body.tw-rev .imp-title b { font-size: 19px; font-weight: 600; }
body.tw-rev .imp-title span { font-size: 13px; color: var(--ld-faint); }
body.tw-rev .imp-x, body.tw-rev .help-x { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--ld-muted); }
body.tw-rev .imp-x:hover, body.tw-rev .help-x:hover { background: var(--ld-surface2); color: var(--ld-text); }
body.tw-rev .imp-body { padding: 18px 20px; }
body.tw-rev .imp-body .drop { border: 1px dashed var(--ld-line); border-radius: 12px; background: var(--ld-bg); color: var(--ld-muted); }
body.tw-rev .imp-body .drop:hover, body.tw-rev .imp-body .drop.over { border-color: var(--ld-accent); background: var(--ld-accent-soft); }
body.tw-rev .imp-body .drop-ico { display: inline-flex; color: var(--ld-accent-text); }
body.tw-rev .imp-body th { color: var(--ld-faint); border-bottom-color: var(--ld-line); }
body.tw-rev .imp-body td { border-bottom-color: var(--ld-line); }
body.tw-rev .imp-map .tag { background: var(--ld-surface2); border-color: var(--ld-line); color: var(--ld-muted); }
body.tw-rev .imp-foot { padding: 14px 20px; border-top: 1px solid var(--ld-line); }

/* ---- Guida (drawer) ---- */
body.tw-rev .help-drawer { width: 420px; background: var(--ld-panel); border-left: 1px solid var(--ld-line); box-shadow: var(--ld-shadow); }
body.tw-rev .help-head { padding: 18px 20px; border-bottom: 1px solid var(--ld-line); }
body.tw-rev .help-head .ht { font-size: 18px; font-weight: 600; }
body.tw-rev .help-body { padding: 18px 20px; }
body.tw-rev .help-intro { color: var(--ld-muted); }
body.tw-rev .help-sec { border-top-color: var(--ld-line); }
body.tw-rev .help-sec .hs-t { font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--ld-faint); }
body.tw-rev .help-sec p, body.tw-rev .help-sec li { color: var(--ld-muted); }
body.tw-rev .help-sec b { color: var(--ld-text); }
body.tw-rev .help-sec code { background: var(--ld-surface2); }
body.tw-rev .help-foot { border-top-color: var(--ld-line); color: var(--ld-faint); }
:root[data-theme="light"] body.tw-rev .help-foot img { filter: invert(1) brightness(.25); }

/* ---- Toast (come i mockup: invertito) ---- */
body.tw-rev .toast { background: var(--ld-text); color: var(--ld-bg); border: 0; border-radius: 10px; padding: 10px 18px; font-size: 14px; box-shadow: var(--ld-shadow); z-index: 90; }
body.tw-rev .toast.ok, body.tw-rev .toast.err { border: 0; }

/* ---- Focus visibile ---- */
body.tw-rev button:focus-visible, body.tw-rev a:focus-visible { outline: 2px solid var(--ld-accent); outline-offset: 2px; }
