:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  /* La barra laterale e' scura: l'accento pieno ci sparisce dentro, e serve la
     sua versione chiara. Cambia con il progetto come tutto il resto. */
  --accent-lite: #8b8ff5;
  --green: #067647;
  --red: #b42318;
  --amber: #b54708;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- guscio applicazione ---------- */
.app { display: flex; min-height: 100vh; }
.navtoggle { display: none; }

.side {
  width: 236px; flex: 0 0 236px;
  background: #101216; color: #d7dae0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-top { padding: 18px 18px 10px; }
.brand { font-weight: 700; font-size: 15px; color: #fff; letter-spacing: -.01em; display: block; }
.brand span { color: #8b8ff5; font-weight: 500; }
.brand:hover { text-decoration: none; }

.side-nav { flex: 1; padding: 8px 10px; overflow-y: auto; }
.side-group {
  margin: 18px 8px 6px; font-size: 10px; letter-spacing: .11em;
  text-transform: uppercase; color: #6a707c;
}
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px; margin-bottom: 1px;
  color: #b9bec9; font-size: 14px; font-weight: 500;
}
.side-nav a:hover { background: #1b1e25; color: #fff; text-decoration: none; }
.side-nav a.on { background: #24273a; color: #fff; }
.side-nav .ic { width: 16px; text-align: center; opacity: .75; font-size: 13px; }

.side-bottom { padding: 12px; border-top: 1px solid #22252c; }
.avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 600;
}
.side-bottom .btn.ghost { background: #1b1e25; border-color: #2b2f38; color: #c4c9d3; }
.side-bottom .btn.ghost:hover { background: #24273a; }

.content { flex: 1; min-width: 0; }
.wrap { max-width: 1180px; padding: 26px 26px 72px; }

.mobilebar { display: none; }
.scrim { display: none; }

.head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 15px; margin: 0 0 12px; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
}
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* Sotto i 900px la barra laterale diventa un pannello a scomparsa. */
@media (max-width: 900px) {
  .side {
    position: fixed; z-index: 30; left: 0; top: 0;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .navtoggle:checked ~ .side { transform: translateX(0); }
  .navtoggle:checked ~ .scrim {
    display: block; position: fixed; inset: 0; z-index: 20;
    background: rgba(16,18,22,.5);
  }
  .mobilebar {
    display: flex; align-items: center; gap: 12px;
    background: #fff; border-bottom: 1px solid var(--line);
    padding: 0 14px; min-height: 52px; position: sticky; top: 0; z-index: 10;
  }
  .burger { font-size: 22px; cursor: pointer; margin: 0; line-height: 1; user-select: none; }
  .mobilebar-title { font-weight: 600; font-size: 15px; }
  .wrap { padding: 18px 16px 64px; }
}

/* ---------- statistiche ---------- */
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .n { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- tabelle ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 0 12px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- controlli ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink); color: #fff; border: 1px solid var(--ink);
  padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 500;
  cursor: pointer; font-family: inherit;
}
.btn:hover { text-decoration: none; opacity: .88; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--red); border-color: #f2c8c2; }

label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 14px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
form.inline { display: inline; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; }
.filters input, .filters select { min-width: 180px; }

/* ---------- etichette ---------- */
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--bg); color: var(--muted);
  border: 1px solid var(--line); white-space: nowrap;
}
.tag.cliente { background: #ecfdf3; color: var(--green); border-color: #abefc6; }
.tag.fornitore { background: #eff8ff; color: #175cd3; border-color: #b2ddff; }
.tag.distributore { background: #fdf4ff; color: #9f1ab1; border-color: #f6d0fe; }
.tag.vinta { background: #ecfdf3; color: var(--green); border-color: #abefc6; }
.tag.persa { background: #fef3f2; color: var(--red); border-color: #fecdca; }
.tag.late { background: #fef3f2; color: var(--red); border-color: #fecdca; }

/* ---------- varie ---------- */
.flash {
  background: #ecfdf3; border: 1px solid #abefc6; color: var(--green);
  padding: 10px 14px; border-radius: 8px; margin-bottom: 18px; font-size: 14px;
}
.error {
  background: #fef3f2; border: 1px solid #fecdca; color: var(--red);
  padding: 10px 14px; border-radius: 8px; margin-bottom: 18px; font-size: 14px;
}
.empty { color: var(--muted); text-align: center; padding: 32px 12px; font-size: 14px; }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.muted { color: var(--muted); }
.strike { text-decoration: line-through; color: var(--muted); }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-box { width: 100%; max-width: 360px; }
.login-box .card { padding: 26px; margin: 0; }
.login-box h1 { margin-bottom: 4px; }

@media (max-width: 820px) {
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
}

/* ---------- creatives ---------- */
.cre-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.cre {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
}
.cre-thumb {
  position: relative; display: block; aspect-ratio: 4 / 3;
  background: #eef0f3; overflow: hidden;
}
.cre-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cre-ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 30px; color: #a8afba;
}
.cre-win {
  position: absolute; top: 8px; left: 8px;
  background: #b54708; color: #fff; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
}
.cre-body { padding: 12px; }
.cre-title {
  display: block; font-weight: 550; font-size: 14px; color: var(--ink);
  margin-bottom: 7px; line-height: 1.35;
}
.cre-title:hover { color: var(--accent); text-decoration: none; }
.cre-meta { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 4px; }

/* etichette di stato aggiuntive */
.tag.win { background: #fef0c7; color: #b54708; border-color: #fedf89; }
.tag.approvata, .tag.pubblicata { background: #ecfdf3; color: var(--green); border-color: #abefc6; }
.tag.in_revisione { background: #fef0c7; color: var(--amber); border-color: #fedf89; }
.tag.archiviata { background: #f2f4f7; color: #667085; }

label.check { display: flex; align-items: center; gap: 9px; font-weight: 400; }
label.check input { width: auto; }

/* ---------- barre di volume ---------- */
.bar {
  position: relative; height: 8px; border-radius: 999px;
  background: #eceef2; overflow: hidden; min-width: 90px;
}
.bar-fill, .bar-win {
  position: absolute; left: 0; top: 0; height: 100%; border-radius: 999px;
}
.bar-fill { background: #c7c9f7; }
.bar-win { background: var(--accent); }

/* ---------- istogramma mensile ---------- */
.months { display: flex; gap: 10px; align-items: flex-end; overflow-x: auto; padding-top: 8px; }
.month { flex: 1 0 46px; text-align: center; }
.month-bars {
  position: relative; height: 110px; display: flex; align-items: flex-end;
  justify-content: center; gap: 3px;
}
.mb-tot, .mb-win { width: 12px; border-radius: 3px 3px 0 0; min-height: 2px; }
.mb-tot { background: #c7c9f7; }
.mb-win { background: var(--accent); }
.month-lab { font-size: 11px; color: var(--muted); margin-top: 6px; }
.month-n { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.month-n small { font-weight: 400; color: var(--muted); }



.gen-wait, .gen-fail {
  margin-top: 8px; padding: 6px; border-radius: 7px; text-align: center;
  font-size: 12px; font-weight: 500;
}
.gen-wait { background: var(--accent-soft); color: var(--accent); }
.gen-fail { background: #fef3f2; color: var(--red); }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em; background: var(--bg); padding: 1px 5px;
  border-radius: 4px; border: 1px solid var(--line);
}

/* ---------- selettore workspace (stile Slack) ---------- */
.ws { position: relative; }
.ws > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 8px; cursor: pointer;
  list-style: none; user-select: none;
}
.ws > summary::-webkit-details-marker { display: none; }
.ws > summary:hover { background: #1b1e25; }
.ws-badge {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.ws-badge.sm { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 6px; font-size: 11px; }
.ws-txt { min-width: 0; line-height: 1.25; flex: 1; }
.ws-txt strong {
  display: block; font-size: 14px; color: #fff; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ws-txt small { display: block; font-size: 11px; color: #767d8a; }
.ws-caret { color: #767d8a; font-size: 13px; }

.ws-menu {
  position: absolute; left: 6px; right: -8px; top: 100%; z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(16, 18, 22, .28);
  padding: 8px; margin-top: 4px;
}
.ws-label {
  margin: 4px 8px 8px; font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.ws-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 8px; border-radius: 7px; border: 0; background: none;
  font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; text-align: left;
}
.ws-item:hover { background: var(--bg); }
.ws-item.on { background: var(--accent-soft); cursor: default; }
.ws-tick { margin-left: auto; color: var(--accent); }
.ws-add {
  display: block; margin-top: 6px; padding: 8px;
  border-top: 1px solid var(--line); font-size: 13px; color: var(--accent);
}
.ws-add:hover { text-decoration: none; background: var(--bg); border-radius: 7px; }

/* ---------- temi ricorrenti ---------- */
.themes { display: flex; flex-wrap: wrap; gap: 8px; }
.theme {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 500;
}
.theme-n {
  background: var(--accent); color: #fff; border-radius: 999px;
  font-size: 11px; padding: 0 6px; font-weight: 600;
}

/* ---------- pannello generazione, versione a prompt ---------- */



.cre-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ---------- accessi per workspace ---------- */
.access {
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.access:last-of-type { border-bottom: 0; padding-bottom: 0; }
.access-who { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; flex-wrap: wrap; }
.access-form { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.access-brand { font-size: 13px; margin: 0; }
.access-brand input { width: auto; }


/* ---------- spazio impostazioni ---------- */
.setwrap { display: flex; gap: 30px; align-items: flex-start; }
.setnav { flex: 0 0 190px; position: sticky; top: 26px; }
.setnav-group {
  margin: 0 0 8px; font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.setnav-group ~ .setnav-group { margin-top: 22px; }
.setnav a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 7px; margin-bottom: 1px;
  color: var(--muted); font-size: 14px; font-weight: 500;
}
.setnav a:hover { background: var(--panel); color: var(--ink); text-decoration: none; }
.setnav a.on { background: var(--accent-soft); color: var(--accent); }
.setnav .ic { width: 15px; text-align: center; font-size: 12px; opacity: .8; }
.setmain { flex: 1; min-width: 0; }
.setmain .card { max-width: 640px; }

@media (max-width: 820px) {
  .setwrap { flex-direction: column; gap: 18px; }
  .setnav { position: static; flex: 1 1 auto; width: 100%; display: flex; flex-wrap: wrap; gap: 4px; }
  .setnav-group { display: none; }
  .setnav-group ~ .setnav-group { margin-top: 0; }
}

/* ---------- blocco profilo: tutta la riga porta alle impostazioni ---------- */
.side-me {
  display: block; padding: 8px; border-radius: 8px; margin-bottom: 10px;
  color: inherit;
}
.side-me:hover { background: #1b1e25; text-decoration: none; }
.side-me:hover .side-me-gear,
.side-me:hover .side-me-hint { color: #fff; }
.side-me.on { background: #24273a; }

.side-me-row { display: flex; align-items: center; gap: 9px; min-width: 0; }
.side-me-txt { min-width: 0; line-height: 1.3; flex: 1; }
.side-me-txt strong {
  display: block; font-size: 13px; color: #eef0f4; font-weight: 550;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-me-txt small {
  display: block; font-size: 11px; color: #767d8a;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-me-gear { flex: 0 0 auto; color: #767d8a; font-size: 14px; line-height: 1; }
.side-me-hint {
  display: block; margin: 6px 0 0 39px;
  font-size: 12px; font-weight: 500; color: var(--accent-lite);
}

/* ---------- schede modello ---------- */
.modelgrid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.model { display: block; margin: 0; cursor: pointer; font-weight: 400; }
.model input { position: absolute; opacity: 0; pointer-events: none; }
.model-body {
  display: block; border: 1.5px solid var(--line); border-radius: 9px;
  padding: 12px 14px; background: #fff; height: 100%;
  transition: border-color .12s, background .12s;
}
.model:hover .model-body { border-color: #c7c9f7; }
.model input:checked + .model-body {
  border-color: var(--accent); background: var(--accent-soft);
}
.model input:focus-visible + .model-body { outline: 2px solid var(--accent); outline-offset: 2px; }
.model-name {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: 14px; font-weight: 550; margin-bottom: 3px;
}
.model-note { display: block; font-size: 12px; color: var(--muted); line-height: 1.45; }

/* ---------- schede a linguette ---------- */
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 9px; }
.tabs a {
  padding: 6px 16px; border-radius: 7px; font-size: 14px;
  font-weight: 500; color: var(--muted);
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16,18,22,.09); }



/* Performance sta un livello sopra le sezioni delle creative */
.side-nav a.lvl1 { margin-bottom: 4px; }

/* ---------- report per creative ---------- */
.report td { vertical-align: middle; }
.rep-cell { display: flex; align-items: center; gap: 10px; min-width: 240px; }
.rep-thumb {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 7px;
  background: #eef0f3; overflow: hidden; display: grid; place-items: center;
  color: #a8afba; font-size: 16px;
}
.rep-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- pezzi del nome della creative ---------- */
.namegrid {
  display: grid; gap: 8px;
  grid-template-columns: 90px 100px 90px minmax(180px, 1fr) minmax(180px, 1fr);
}
@media (max-width: 900px) {
  .namegrid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

.rawout {
  background: #16181d; color: #d7dae0; border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.5; margin: 12px 0 0;
}

/* ---------- template e identita ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--accent-soft); border-radius: 999px; padding: 4px 6px 4px 12px;
  font-size: 13px;
}
.chip a { color: var(--accent); font-weight: 500; }
.chip a:hover { text-decoration: none; }
.chip-x {
  border: 0; background: none; color: var(--accent); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0 5px; opacity: .5;
}
.chip-x:hover { opacity: 1; }

.idlist { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.idrow {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.idrow:last-child { border-bottom: 0; }
.idthumbs { display: flex; flex: 0 0 auto; }
.idthumbs img {
  width: 32px; height: 32px; border-radius: 6px; object-fit: cover;
  border: 2px solid #fff; margin-left: -8px;
}
.idthumbs img:first-child { margin-left: 0; }


/* ---------- barra di generazione ---------- */
.genhead {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.tplnote { font-size: 13px; color: var(--muted); }
.attach-item.from-tpl img { border-color: var(--accent); }
.attach-item.from-tpl::after {
  content: '▤'; position: absolute; bottom: -3px; right: -3px;
  background: var(--accent); color: #fff; border-radius: 4px;
  font-size: 8px; padding: 1px 3px; line-height: 1.3;
}

/* Il riferimento era una barra scura; qui vive in un'interfaccia chiara, e la
   forma compatta si tiene mentre i colori sono quelli dell'app. */
.genbar {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 18px;
}
.genbar .error { margin-bottom: 12px; }
.gen-prompt {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  background: #fcfcfd; color: var(--ink);
  font: inherit; font-size: 15px; line-height: 1.5;
  padding: 11px 13px; resize: vertical; min-height: 62px;
}
.gen-prompt::placeholder { color: #9aa1ad; }
.gen-prompt:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent); background: #fff;
}

.genrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Il controllo e' il menu stesso, non un contenitore che lo avvolge: cliccando
   il bordo di un'etichetta il menu non si apriva, perche' un label mette a
   fuoco un select senza aprirlo. Stesso raggio del pulsante Generate. */
.pill {
  appearance: none; -webkit-appearance: none;
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  color: var(--ink); font: inherit; font-size: 13px;
  height: 38px; padding: 0 30px 0 13px; margin: 0; cursor: pointer; width: auto;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  max-width: 260px; text-overflow: ellipsis;
}
.pill:hover { border-color: var(--accent); background-color: var(--accent-soft); }
.pill:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.pill option { background: #fff; color: var(--ink); }


.gen-btn { margin-left: auto; height: 38px; padding: 0 24px; border-radius: 9px; }

.gen-hint { flex-basis: 100%; font-size: 12px; color: var(--muted); padding: 2px 4px 0; }

.gen-name { margin: 12px 0 0; }
.gen-name > summary {
  cursor: pointer; font-size: 12px; color: var(--muted); padding: 4px 2px;
  user-select: none; list-style: none;
}
.gen-name > summary::-webkit-details-marker { display: none; }
.gen-name > summary:hover { color: var(--ink); }
.gen-name > summary::after {
  content: ' ›'; display: inline-block; color: var(--muted);
  transition: transform .15s ease;
}
.gen-name[open] > summary::after { transform: rotate(90deg); }
.gen-name .namegrid { margin: 10px 0; }
.gen-name small { display: block; color: var(--muted); }

/* sottolivelli nella barra laterale */
.side-nav a.sub { padding-left: 34px; font-size: 13px; color: #8a909c; }
.side-nav a.sub.on { background: #1b1e25; color: #fff; }

/* ---------- gruppo di menu a scomparsa ---------- */
/* I sottolivelli restano nascosti finche' non si apre la voce, e si aprono da
   se' quando la pagina corrente sta dentro il gruppo. */
.navgroup > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px; margin-bottom: 1px;
  color: #b9bec9; font-size: 14px; font-weight: 500;
  cursor: pointer; list-style: none; user-select: none;
}
.navgroup > summary::-webkit-details-marker { display: none; }
.navgroup > summary:hover { background: #1b1e25; color: #fff; }
.navgroup > summary.on { background: #24273a; color: #fff; }
.navgroup > summary .ic { width: 16px; text-align: center; opacity: .75; font-size: 13px; }
.navgroup-caret {
  margin-left: auto; font-size: 13px; color: #6a707c;
  transition: transform .15s ease;
}
.navgroup[open] .navgroup-caret { transform: rotate(90deg); }

/* ---------- selettore di file ---------- */
/* Il controllo nativo resta, perche' e' l'unico che mostra quanti file sono
   stati scelti senza JavaScript; ne viene curato l'aspetto. */
.filedrop {
  border: 1.5px dashed var(--line); border-radius: 9px;
  padding: 12px 14px; background: #fcfcfd;
}
.filedrop:hover { border-color: #c7c9f7; background: var(--accent-soft); }
.filedrop input[type="file"] {
  width: 100%; border: 0; background: none; padding: 0; font-size: 13px;
  color: var(--muted);
}
.filedrop input[type="file"]::file-selector-button {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 7px; padding: 6px 13px; margin-right: 11px;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.filedrop input[type="file"]::file-selector-button:hover {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}
.filedrop small { display: block; margin-top: 9px; font-size: 12px; }

/* ---------- sezioni che si aprono ---------- */
/* La freccia che ruota e' la stessa del gruppo Long Form nella barra laterale:
   un solo segnale in tutta l'app per 'questo si apre e si richiude'. */
.reveal > summary {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 500; color: var(--accent);
  cursor: pointer; list-style: none; padding: 7px 11px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
.reveal > summary::-webkit-details-marker { display: none; }
.reveal > summary::after {
  content: '›'; font-size: 15px; line-height: 1; color: var(--muted);
  transition: transform .15s ease;
}
.reveal > summary:hover {
  border-color: var(--accent); background: var(--accent-soft);
}
.reveal[open] > summary {
  border-color: var(--accent); background: var(--accent-soft);
}
.reveal[open] > summary::after { transform: rotate(90deg); }
.subform {
  margin-top: 12px; padding: 16px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
}
.subform .actions { margin-top: 4px; }
.subform > form + form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- identita ---------- */
.idrow { border-bottom: 1px solid var(--line); }
.idrow:last-of-type { border-bottom: 0; }
.idrow > summary {
  display: flex; align-items: center; gap: 12px; padding: 11px 0;
  cursor: pointer; list-style: none;
}
.idrow > summary::-webkit-details-marker { display: none; }
.idrow > summary:hover .idedit { color: var(--accent); }
.idedit::after {
  content: ' ›'; display: inline-block; transition: transform .15s ease;
}
.idrow[open] > summary .idedit { color: var(--accent); }
.idrow[open] > summary .idedit::after { transform: rotate(90deg); }
.idname { flex: 1; min-width: 0; line-height: 1.3; }
.idname strong { display: block; font-size: 14px; font-weight: 550; }
.idname small { display: block; font-size: 12px; color: var(--muted); }
.idedit { font-size: 13px; color: var(--muted); }

.idgallery { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 16px; }
.idpic { position: relative; }
.idpic img {
  width: 66px; height: 66px; border-radius: 8px; object-fit: cover;
  display: block; border: 1px solid var(--line);
}
.idpic form { position: absolute; top: -6px; right: -6px; }
.idpic button {
  width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; color: var(--red); cursor: pointer; line-height: 1;
  font-size: 13px; padding: 0; box-shadow: 0 1px 3px rgba(16,18,22,.14);
}
.idpic button:hover { background: #fef3f2; }

.chip.on { background: var(--accent); }
.chip.on a { color: #fff; }

/* ---------- prompt e allegati ---------- */
/* Nel riferimento gli allegati stanno sopra il prompt e si vedono: sono
   contenuto della richiesta, non un'impostazione fra le altre. Qui vivono nello
   stesso riquadro, cosi' si leggono come una cosa sola. */
.composer {
  border: 1px solid var(--line); border-radius: 11px;
  background: #fcfcfd; overflow: hidden;
}
.composer:focus-within { border-color: var(--accent); background: #fff; }
.composer .gen-prompt {
  border: 0; border-radius: 0; background: transparent; min-height: 66px;
}
.composer .gen-prompt:focus { outline: none; }

.attach {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 11px 12px 0;
}
.attach-add {
  display: inline-flex; align-items: center; gap: 7px; margin: 0;
  border: 1.5px dashed var(--line); border-radius: 9px;
  padding: 0 12px; height: 42px; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--muted); background: #fff;
}
.attach-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.attach-plus { font-size: 15px; line-height: 1; }

/* Senza JavaScript resta il controllo nativo, che almeno dice quanti file. */
.attach-add input[type="file"] { max-width: 190px; font-size: 12px; }
.attach-live .attach-add input[type="file"] { display: none; }

.attach-list { display: inline-flex; gap: 9px; flex-wrap: wrap; }
.attach-item { position: relative; }
.attach-item img {
  width: 42px; height: 42px; border-radius: 8px; object-fit: cover;
  display: block; border: 1px solid var(--line);
}
.attach-doc {
  width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 10px; font-weight: 700; border: 1px solid #d6d8f8;
}
.attach-item button {
  position: absolute; top: -6px; right: -6px;
  width: 19px; height: 19px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; color: var(--red); cursor: pointer; line-height: 1;
  font-size: 12px; padding: 0; box-shadow: 0 1px 3px rgba(16,18,22,.16);
}
.attach-item button:hover { background: #fef3f2; }
/* Il nome compare al passaggio: serve a distinguere due miniature simili. */
.attach-name {
  position: absolute; left: 50%; top: calc(100% + 5px); transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 11px; white-space: nowrap;
  padding: 3px 7px; border-radius: 5px; opacity: 0; pointer-events: none;
  transition: opacity .12s ease; z-index: 5; max-width: 220px; overflow: hidden;
  text-overflow: ellipsis;
}
.attach-item:hover .attach-name { opacity: 1; }
.attach-note { font-size: 12px; }

.idblank {
  width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
  font-size: 13px;
}
.inuse { color: var(--accent); font-weight: 600; }

/* ---------- quantita ---------- */
.stepper {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  height: 38px; padding: 0 4px;
}
.stepper button {
  width: 26px; height: 28px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 15px; line-height: 1;
  border-radius: 6px; padding: 0;
}
.stepper button:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.stepper button:disabled { opacity: .3; cursor: default; }
.stepper input {
  width: 26px; border: 0; background: none; padding: 0; text-align: right;
  font: inherit; font-size: 13px; color: var(--ink);
  -moz-appearance: textfield;
}
.stepper input:focus { outline: none; }
/* Con i pulsanti attivi le frecce native sono un doppione. */
.stepper-live input::-webkit-outer-spin-button,
.stepper-live input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-max { font-size: 13px; color: var(--muted); padding-right: 5px; }

/* ---------- disegno della maschera ---------- */
.drawbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line);
}
.drawbar .btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drawsize { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
.drawsize input[type="range"] { width: 130px; }

/* L'immagine e la tela stanno sovrapposte e scalate insieme: il pennello viene
   riportato ai pixel originali, altrimenti una maschera disegnata su
   un'anteprima piccola cadrebbe nel posto sbagliato. */
.drawstage {
  position: relative; display: inline-block; max-width: 100%;
  border-radius: 9px; overflow: hidden; background: var(--bg);
  border: 1px solid var(--line);
}
.drawstage img { display: block; max-width: 100%; height: auto; }
.drawstage canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  cursor: crosshair; touch-action: none;
}

/* ---------- trascinamento dei file ---------- */
.composer.dropping {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent-soft);
}
.composer.dropping .gen-prompt::placeholder { color: var(--accent); }
.composer.dropping .attach-add { border-color: var(--accent); color: var(--accent); }
.composer.drop-unsupported .attach-add::after {
  content: ' — use the button'; font-size: 11px; color: var(--red);
}

/* Il suggerimento sul trascinamento appare solo dove funziona. */
.attach-drag { display: none; }
.attach-live .attach-drag { display: inline; color: var(--muted); font-weight: 400; }
.composer.dropping .attach-drag { color: var(--accent); }

/* ---------- attesa e arrivo ---------- */
.spin {
  display: inline-block; width: 11px; height: 11px; vertical-align: -1px;
  border: 2px solid var(--accent); border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.cre-thumb.just-arrived { animation: arrive .45s ease; }
@keyframes arrive { from { opacity: 0; } to { opacity: 1; } }

.tag.generating { background: var(--accent-soft); color: var(--accent); border-color: #d6d8f8; }

/* ---------- griglia delle creative a confronto ----------
   La lettura parte dall'immagine: quando si giudica una creative si guarda
   prima cosa si vede, e solo dopo quanto ha reso. I numeri stanno sotto la
   miniatura, nello stesso ordine per tutte, cosi' si confrontano a colpo
   d'occhio scorrendo la griglia. */
.crgrid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.crcard {
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--panel); display: flex; flex-direction: column;
}
.crcard.is-winner { border-color: #fedf89; box-shadow: 0 0 0 2px #fef0c7; }
.crshot {
  position: relative; aspect-ratio: 4 / 5; background: #eef0f3;
  display: grid; place-items: center; color: #a8afba; font-size: 26px;
}
.crshot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.crshot .crrank {
  position: absolute; top: 8px; left: 8px; background: rgba(16,18,22,.72);
  color: #fff; font-size: 11px; font-weight: 600; border-radius: 20px; padding: 2px 8px;
}
.crshot .crstar {
  position: absolute; top: 8px; right: 8px; background: #fef0c7; color: #b54708;
  border: 1px solid #fedf89; font-size: 11px; font-weight: 600;
  border-radius: 20px; padding: 2px 8px;
}
.crbody { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.crname {
  font-size: 12.5px; font-weight: 600; line-height: 1.35; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.crmeta { font-size: 11px; color: var(--muted); }
.crstats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.crstats div { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; }
.crstats .k { color: var(--muted); }
.crstats .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.crstats .v.good { color: var(--green); }
.crstats .v.bad { color: var(--red); }

/* La barra della spesa da la proporzione fra una creative e la piu' cara del
   periodo: dice dove sono finiti i soldi senza dover leggere le cifre. */
.crspend { height: 4px; border-radius: 4px; background: #eef0f3; overflow: hidden; }
.crspend span { display: block; height: 100%; background: var(--accent); }

/* ---------- aperture proposte ----------
   Si leggono come si leggeranno sulla pagina: a piena larghezza, con il testo
   che va a capo dove andrebbe a capo davvero. */
.hookidea {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-top: 1px solid rgba(79,70,229,.15);
}
.hookidea:first-of-type { border-top: 0; }
.hookidea pre {
  flex: 1; margin: 0; white-space: pre-wrap; font: inherit; font-size: 14px; line-height: 1.5;
}
.hookbox { font-size: 15px; line-height: 1.5; }

/* La riga che modifica un template sta sotto quella che ci aggiunge: sono due
   gesti diversi — aggiungere accoda, cambiare riscrive — e vederli separati
   evita di scrivere una correzione nel posto in cui verrebbe appesa in fondo. */
.composer.tplchange {
  margin-top: 10px; padding-top: 12px; border-top: 1px dashed var(--line);
  display: block;
}
.composer.tplchange .gen-prompt { min-height: 52px; }
.composer.tplchange .tplnote { display: block; margin-top: 6px; }

/* ---------- selezione multipla nella griglia ----------
   La casella sta sulla miniatura perche' e' l'immagine che si guarda per
   decidere: si sceglie vedendo, non leggendo un codice. */
.cre { position: relative; }
.cre-pick { position: absolute; top: 10px; left: 10px; z-index: 2; cursor: pointer; }
.cre-pick input { position: absolute; opacity: 0; width: 0; height: 0; }
.cre-pick span {
  display: block; width: 22px; height: 22px; border-radius: 6px;
  background: rgba(255,255,255,.9); border: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(16,18,22,.18);
}
.cre-pick input:checked + span {
  background: var(--accent); border-color: var(--accent);
}
.cre-pick input:checked + span::after {
  content: '✓'; color: #fff; font-size: 14px; line-height: 20px;
  display: block; text-align: center;
}
.cre-pick input:disabled + span { opacity: .35; }

.pickbar {
  position: sticky; top: 8px; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px;
  box-shadow: 0 6px 20px rgba(16,18,22,.10);
}
.pickbar-n { font-size: 13px; color: var(--muted); }

/* Verde per 'funziona', ambra per 'vincente'. Erano lo stesso colore, e in una
   pagina di stati leggere una spunta gialla accanto a 'Connected' fa fermare
   l'occhio su qualcosa che va bene. */
.tag.ok { background: #ecfdf3; color: var(--green); border-color: #abefc6; }

/* ---------- CRO ----------
   Stessa piattaforma, altro mestiere. Il colore e' l'unica cosa che cambia, e
   basta: chi ha due schede aperte deve capire in quale sta senza leggere
   l'indirizzo, e un tema diverso costringerebbe a reimparare la stessa app. */
html[data-mode="cro"] {
  --accent: #067647;
  --accent-soft: #ecfdf3;
  --accent-lite: #5ec98f;
}
html[data-mode="cro"] .tag.generating {
  background: var(--accent-soft); color: var(--accent); border-color: #abefc6;
}
/* Il segno nella barra laterale: il primo posto dove l'occhio cade aprendo una
   scheda, e quindi il posto dove la differenza va vista. */
html[data-mode="cro"] .side-nav a.on { background: #0b3d28; }
html[data-mode="cro"] .side-nav summary.on { background: #0b3d28; color: #fff; }

/* ---------- CRO: la pagina in lavorazione ----------
   L'anteprima e' la cosa piu' grande della schermata perche' e' l'unica che
   conta: tutto il resto e' come cambiarla. */
.pageframe {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: #fff; transition: max-width .18s ease;
}
.pageframe iframe { display: block; width: 100%; height: 70vh; border: 0; }

.drawpad canvas {
  display: block; max-width: 100%; border: 1px solid var(--line);
  border-radius: 8px; margin: 12px 0; cursor: crosshair; touch-action: none;
}

/* Sul login la piattaforma va detta: due schede identiche, e chi sbaglia porta
   scopre di essere nel posto sbagliato solo dopo essere entrato. */
.login-mark { font-weight: 400; color: var(--muted); font-size: 15px; letter-spacing: 0; }

/* ---------- pannelli richiudibili sopra la generazione ----------
   Template, identita' e varianti sono aiuti: servono a volte, e chiusi lasciano
   la barra di generazione a portata di schermo invece di farla cercare in fondo
   a una pagina di cose che oggi non si stanno usando. */
.card.panel { padding: 0; margin-bottom: 0; }
.card.panel > summary {
  list-style: none; cursor: pointer; padding: 14px 18px;
  display: flex; align-items: center; gap: 8px;
}
.card.panel > summary::-webkit-details-marker { display: none; }
.card.panel > summary::after {
  content: '›'; margin-left: auto; color: var(--muted); font-size: 18px;
  transition: transform .15s ease;
}
.card.panel[open] > summary::after { transform: rotate(90deg); }
.card.panel > summary h2 { margin: 0; }
.card.panel > summary:hover { background: #fafbfc; }
.card.panel[open] > summary { border-bottom: 1px solid var(--line); }
.card.panel > *:not(summary) { padding-left: 18px; padding-right: 18px; }
.card.panel > *:not(summary):first-of-type { padding-top: 14px; }
.card.panel > *:not(summary):last-child { padding-bottom: 18px; }

/* La X sugli avvisi. Un messaggio che non si puo' chiudere resta sullo schermo
   fino al ricarico, e si smette di leggerlo. */
.notice { position: relative; padding-right: 40px; }
.notice-x {
  position: absolute; top: 50%; right: 10px; transform: translateY(-50%);
  border: 0; background: none; cursor: pointer; line-height: 1;
  font-size: 20px; color: inherit; opacity: .5; padding: 2px 6px;
}
.notice-x:hover { opacity: 1; }

/* La barra della selezione multipla e' un elemento flex, e 'flex' vince su
   [hidden]: senza questo restava visibile con zero creative scelte. */
.pickbar[hidden] { display: none; }

/* ---------- SRM ----------
   Il terzo prodotto. Il colore e' scelto per non somigliare agli altri due: fra
   indaco e verde un blu si confonderebbe, e chi tiene tre schede aperte deve
   capire dov'e' senza leggere l'indirizzo. */
html[data-mode="srm"] {
  --accent: #c2410c;
  --accent-soft: #fff3ed;
  --accent-lite: #f0925f;
}
html[data-mode="srm"] .side-nav a.on { background: #4a1c07; }
html[data-mode="srm"] .side-nav summary.on { background: #4a1c07; color: #fff; }
html[data-mode="srm"] .tag.generating {
  background: var(--accent-soft); color: var(--accent); border-color: #fcd9c4;
}

/* ---------- Dashboard ----------
   L'amministrazione non e' un quarto prodotto: e' il posto da cui si guardano
   gli altri tre. Il grigio la tiene neutra, cosi' nessuno dei tre colori
   sembra il padrone degli altri. */
html[data-mode="admin"] {
  --accent: #475569;
  --accent-soft: #f1f5f9;
  --accent-lite: #a7b2c2;
}
html[data-mode="admin"] .side-nav a.on { background: #2b3444; }
html[data-mode="admin"] .side-nav summary.on { background: #2b3444; color: #fff; }

/* Nella dashboard l'intestazione non e' un selettore: non c'e' niente da
   scegliere, e farlo sembrare cliccabile prometterebbe una scelta che non
   esiste. */
.ws-fixed { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: default; }

/* Un video nella griglia si comporta come la miniatura che sostituisce, e
   dichiara di essere un video con un segno che non copre l'immagine. */
.cre-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.cre-play {
  position: absolute; bottom: 8px; left: 8px; z-index: 1;
  background: rgba(16,18,22,.72); color: #fff; font-size: 11px;
  border-radius: 20px; padding: 2px 9px; pointer-events: none;
}
.cre-thumb { position: relative; }
