/* AT-Driver · Revisione immagini — stile condiviso (nessuna dipendenza esterna) */

:root {
  --navy: #011637;
  --navy-700: #0a2550;
  --navy-600: #163566;
  --navy-100: #e6ebf3;
  --yellow: #fdbc1f;
  --yellow-600: #e2a409;
  --yellow-50: #fff6dc;
  --white: #ffffff;

  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --line: #dde3ec;
  --line-strong: #c3ccda;
  --text: #0d1b30;
  --muted: #5a6880;

  --ok: #13784a;
  --ok-bg: #e2f3e9;
  --danger: #c3362b;
  --danger-bg: #fce8e6;
  --warn: #8f5d00;
  --warn-bg: #fff1cc;
  --info: #1f5fbf;
  --info-bg: #e4edfb;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(1, 22, 55, .06), 0 2px 8px rgba(1, 22, 55, .06);
  --shadow-lg: 0 8px 30px rgba(1, 22, 55, .22);
  --font: "Avenir Next", -apple-system, Helvetica, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --topbar-h: 54px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--navy-600); }
img { display: block; max-width: 100%; }
code, pre, .mono { font-family: var(--mono); font-size: 12px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 700; color: var(--navy); }
h3 { font-size: 13px; font-weight: 700; color: var(--navy); text-transform: uppercase; letter-spacing: .04em; }
h4 { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }
kbd {
  display: inline-block;
  min-width: 18px;
  padding: 0 4px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  line-height: 15px;
  text-align: center;
  opacity: .7;
  margin-left: 4px;
}

/* ------------------------------------------------------------ barra superiore */
.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--topbar-h);
  padding: 8px 20px;
  background: var(--navy);
  color: var(--white);
  border-bottom: 3px solid var(--yellow);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: .01em; white-space: nowrap; color: var(--white); text-decoration: none; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 7px;
  background: var(--yellow);
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -.02em;
}
.brand .sep { color: var(--yellow); margin: 0 2px; }
.appbar .spacer { flex: 1; }
.appbar-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: #c9d3e4; flex-wrap: wrap; }
.appbar-meta .key { font-family: var(--mono); color: var(--white); background: rgba(255,255,255,.08); padding: 2px 7px; border-radius: 5px; }
.appbar a { color: var(--white); }
.worker-now { display: inline-flex; align-items: center; gap: 6px; }
.user-box { white-space: nowrap; }
.user-box b { color: var(--white); }
.linklike { border: 0; background: none; padding: 0; font: inherit; color: var(--yellow); cursor: pointer; text-decoration: underline; }
.worker-now a { color: var(--yellow); }

.provider-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 700;
  white-space: nowrap;
}
.provider-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.provider-badge.openai { background: var(--yellow); color: var(--navy); }
.provider-badge.mock { background: #d9f2e4; color: #0d5e39; }
.provider-badge.locale { background: rgba(255,255,255,.14); color: var(--white); }

/* ------------------------------------------------------------ elementi comuni */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--navy);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover:not(:disabled) { border-color: var(--navy-600); background: var(--surface-2); }
.btn:focus-visible, .seg button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--yellow); outline-offset: 2px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--yellow); border-color: var(--yellow-600); color: var(--navy); }
.btn.primary:hover:not(:disabled) { background: #ffc93f; border-color: var(--yellow-600); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: var(--white); }
.btn.navy:hover:not(:disabled) { background: var(--navy-600); }
.btn.danger { color: var(--danger); border-color: #e3aaa5; }
.btn.danger:hover:not(:disabled) { background: var(--danger); color: var(--white); border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--navy-600); }
.btn.ghost:hover:not(:disabled) { background: var(--navy-100); border-color: transparent; }
.btn.sm { min-height: 28px; padding: 3px 10px; font-size: 12px; }
.btn.lg { min-height: 42px; padding: 8px 18px; font-size: 15px; }
.btn.block { width: 100%; }
.appbar .chip.attn { background: var(--yellow); color: var(--navy); }
.appbar .btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.22); color: var(--white); }
.appbar .btn:hover:not(:disabled) { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.4); }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button {
  border: 0; background: transparent; padding: 4px 10px; font: inherit; font-size: 12px; font-weight: 600;
  color: var(--muted); cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--navy); color: var(--white); }

input[type="text"], input[type="search"], input[type="number"], input[type="password"], input[type="datetime-local"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 6px 9px;
  min-height: 34px;
}
textarea { width: 100%; resize: vertical; min-height: 64px; line-height: 1.4; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  line-height: 18px;
  white-space: nowrap;
  background: var(--navy-100); color: #33435e;
}
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.attn { background: var(--navy); color: var(--yellow); }
.chip.muted { background: #eceef2; color: #77819a; }
.chip.agent { background: var(--yellow-50); color: #7a5400; border: 1px solid #f3d27a; }
.chip.draft { background: #f1f3f7; color: #5a6880; border: 1px dashed var(--line-strong); }
.chip.type-scene { background: #e9e4fb; color: #4a2fa0; }
.chip.type-graphic { background: #e0f2f1; color: #0c6158; }
.chip.type-gif { background: #fde7f1; color: #9b1e5c; }
.chip.type-copy { background: #eef0f3; color: #3f4a5c; border: 1px solid #c9d0db; }
.chip.type-banner { background: #e6ebf3; color: #0a2550; border: 1px solid #b9c6dc; }
.chip.type-none { background: #eceef2; color: #77819a; }
.chip.lock { background: #fde2c4; color: #7a3d00; border: 1px solid #f2b573; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -2px;
}
.spinner.lg { width: 22px; height: 22px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.panel + .panel { margin-top: 14px; }
.panel-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head .tools { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.notice { padding: 9px 12px; border-radius: 8px; font-size: 13px; border: 1px solid; }
.notice.warn { background: var(--warn-bg); color: #6e4700; border-color: #f0d48b; }
.notice.danger { background: var(--danger-bg); color: #8e2219; border-color: #f0b9b3; }
.notice.ok { background: var(--ok-bg); color: #0d5e39; border-color: #a9dbc0; }
.notice.info { background: var(--info-bg); color: #194d9a; border-color: #b6cdf1; }
.notice + .notice { margin-top: 8px; }

/* ------------------------------------------------------------ toast */
#toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 100;
  display: flex; flex-direction: column-reverse; gap: 8px;
  max-width: min(440px, calc(100vw - 36px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px 10px 14px;
  border-radius: 9px;
  background: var(--navy); color: var(--white);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  border-left: 4px solid var(--yellow);
  animation: toast-in .16s ease-out;
}
.toast.error { background: #3d0f0b; border-left-color: #ff6b5e; }
.toast.ok { border-left-color: #4ade80; }
.toast.warn { border-left-color: var(--yellow); }
.toast .msg { flex: 1; white-space: pre-line; word-break: break-word; }
.toast button { border: 0; background: transparent; color: inherit; opacity: .7; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.toast button:hover { opacity: 1; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ============================================================ DASHBOARD / ELENCO */
.page { padding: 16px 20px 90px; max-width: 2200px; margin: 0 auto; }

.pause-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--danger); color: var(--white);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.pause-banner .reason { font-weight: 400; opacity: .95; }
.pause-banner .btn { margin-left: auto; background: var(--white); color: var(--danger); border-color: var(--white); }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.metric {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px 8px;
  min-height: 64px;
  text-align: left;
  font: inherit;
  color: inherit;
}
button.metric { cursor: pointer; }
button.metric:hover { border-color: var(--navy-600); box-shadow: var(--shadow); }
.metric.active { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.metric .m-label { font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; line-height: 1.25; }
.metric .m-value { font-size: 21px; font-weight: 700; color: var(--navy); line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.metric .m-value small { font-size: 13px; font-weight: 600; color: var(--muted); }
.metric .m-sub { font-size: 11px; color: var(--muted); margin-top: 1px; line-height: 1.3; }
.metric.hl { border-color: #f3d27a; background: var(--yellow-50); }
.metric.bad .m-value { color: var(--danger); }
.metric.wide { grid-column: span 2; }
.bar { height: 6px; background: var(--navy-100); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--yellow); border-radius: inherit; transition: width .3s; }
.bar.over > span { background: var(--danger); }
.bar.navy > span { background: var(--navy-600); }

.settings { margin-bottom: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.settings > summary {
  list-style: none; cursor: pointer; padding: 10px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-weight: 700; color: var(--navy);
}
.settings > summary::-webkit-details-marker { display: none; }
.settings > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.settings[open] > summary::before { transform: rotate(90deg); }
.settings .summary-vals { font-weight: 500; font-size: 12px; color: var(--muted); }
.settings-body { display: flex; gap: 22px; flex-wrap: wrap; align-items: flex-start; padding: 4px 16px 14px; border-top: 1px solid var(--line); }
.settings-body .field-label { margin-top: 10px; }
.settings-body .hint { font-size: 11px; color: var(--muted); margin-top: 3px; max-width: 260px; }
.inline { display: inline-flex; align-items: center; gap: 6px; }
.budget-field { flex: 1 1 320px; max-width: 420px; }
.budget-field input[type=range] { display: block; width: 100%; margin: 10px 0 0; accent-color: var(--navy); cursor: pointer; }
.budget-field .range-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.settings-body .budget-field .hint { max-width: none; }
.budget-field .inline { flex-wrap: wrap; }
.settings-body .hint.warn { color: #b42318; font-weight: 600; }

.filters {
  position: sticky; top: calc(var(--topbar-h) + 3px); z-index: 30;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px;
  margin: 0 -4px 12px;
  background: rgba(238, 241, 246, .96);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.filters select { max-width: 280px; }
.filters input[type="search"] { width: 240px; }
.filters .count { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.filters .count b { color: var(--navy); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 12px;
}
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.card:hover { border-color: var(--navy-600); box-shadow: 0 4px 16px rgba(1,22,55,.14); }
.card.selected { border-color: var(--yellow-600); box-shadow: 0 0 0 2px var(--yellow); }
.card.busy { border-color: var(--info); }
.card.locked { border-color: #f2b573; }
.card.locked .thumb img { opacity: .75; }
.card-link { display: block; color: inherit; text-decoration: none; }
.card .thumb { position: relative; aspect-ratio: 16 / 9; background: #d8dee8; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .thumb-over { position: absolute; inset: 0; pointer-events: none; }
.card .thumb .t-type { position: absolute; left: 6px; bottom: 6px; }
.card .thumb .t-type .chip { box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.card .thumb .t-busy { position: absolute; right: 6px; top: 6px; background: var(--info); color: var(--white); border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 700; display: inline-flex; gap: 5px; align-items: center; }
.card-check {
  position: absolute; left: 6px; top: 6px; z-index: 2;
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: 7px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  cursor: pointer;
}
.card-check input { width: 16px; height: 16px; margin: 0; cursor: pointer; accent-color: var(--navy); }
.card-body { padding: 8px 10px 10px; }
.card-title { font-weight: 700; font-size: 13px; color: var(--navy); text-transform: uppercase; letter-spacing: .01em; display: flex; gap: 5px; align-items: baseline; min-height: 19px; }
.card-title .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title .none { text-transform: none; font-weight: 500; color: var(--muted); font-style: italic; }
.warn-icon { color: #d18b00; font-size: 13px; flex: none; }
/* ellissi all'inizio: resta visibile la parte finale del nome (es. «_02.jpg») */
.card-file { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 1px 0 6px; direction: rtl; text-align: left; }

.empty { padding: 60px 20px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

.pager { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 18px 0 0; flex-wrap: wrap; }
.pager input { width: 64px; text-align: center; }

.bulkbar {
  position: fixed; left: 12px; right: 12px; bottom: 16px; z-index: 50;
  width: fit-content;
  margin: 0 auto;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  padding: 10px 14px;
  background: var(--navy); color: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--navy-600);
}
.bulkbar .n { font-weight: 700; margin-right: 6px; white-space: nowrap; }
.bulkbar .n b { color: var(--yellow); font-size: 16px; }
.bulkbar .btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.25); color: var(--white); }
.bulkbar .btn:hover:not(:disabled) { background: rgba(255,255,255,.18); }
.bulkbar .btn.primary { background: var(--yellow); color: var(--navy); border-color: var(--yellow); }
.bulkbar .btn.primary:hover:not(:disabled) { background: #ffc93f; }
.bulkbar .divider { width: 1px; align-self: stretch; background: rgba(255,255,255,.2); margin: 0 4px; }

/* ============================================================ PAGINA IMMAGINE */
.topbar .nav-group { display: inline-flex; align-items: center; gap: 6px; }
.topbar .pos { min-width: 84px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.topbar .pos small { color: #c9d3e4; font-weight: 500; }
.topbar .tb-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.topbar .tb-title .fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.topbar label.check { color: #c9d3e4; }
.topbar .spend { font-size: 12px; color: #c9d3e4; white-space: nowrap; }
.topbar .spend b { color: var(--white); }

.item-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: 16px;
  padding: 14px 20px 40px;
  max-width: 2400px;
  margin: 0 auto;
  align-items: start;
}
.col-side {
  position: sticky;
  top: calc(var(--topbar-h) + 17px);
  max-height: calc(100vh - var(--topbar-h) - 30px);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding-right: 2px;
  scrollbar-width: thin;
}
.col-side .panel + .panel { margin-top: 0; }
.claim-notice .btn-row { margin-top: 8px; }

.img-pair { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.img-pair.side { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.fig { margin: 0; min-width: 0; }
.fig-cap { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--navy); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.fig-cap .muted { text-transform: none; letter-spacing: 0; font-weight: 500; }
.fig-cap .right { margin-left: auto; }
.stage {
  position: relative;
  background: #1a2233;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}
.stage img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage .placeholder {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #c9d3e4; font-size: 13px; text-align: center; padding: 20px;
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }
.legend .sw.protect { border: 2px solid var(--yellow); background: rgba(253,188,31,.2); }
.legend .sw.bottom { border: 2px dashed #38bdf8; }

/* confronto a cursore */
.slider-stage { position: relative; aspect-ratio: 16 / 9; background: #1a2233; border-radius: 8px; overflow: hidden; cursor: ew-resize; user-select: none; touch-action: none; }
.slider-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.slider-stage .after { position: absolute; inset: 0; }
.slider-stage .handle { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--yellow); transform: translateX(-1.5px); box-shadow: 0 0 0 1px rgba(1,22,55,.5); pointer-events: none; }
.slider-stage .handle::after {
  content: "◂ ▸"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--yellow); color: var(--navy); font-size: 11px; font-weight: 800;
  padding: 5px 7px; border-radius: 999px; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.slider-stage .lbl { position: absolute; top: 8px; padding: 2px 8px; border-radius: 5px; background: rgba(1,22,55,.8); color: var(--white); font-size: 11px; font-weight: 700; pointer-events: none; }
.slider-stage .lbl.l { left: 8px; }
.slider-stage .lbl.r { right: 8px; background: var(--yellow); color: var(--navy); }
input[type="range"].cmp-range { width: 100%; margin: 8px 0 0; accent-color: var(--navy); }

.post-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; margin-top: 14px; }
.qa-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; }
.qa-list li { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.qa-list .ic { width: 18px; flex: none; font-weight: 800; text-align: center; }
.qa-list .yes .ic { color: var(--ok); }
.qa-list .no { color: var(--danger); font-weight: 600; }
.qa-list .no .ic { color: var(--danger); }
.notes-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; font-size: 13px; margin: 6px 0 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.pre-wrap { white-space: pre-wrap; }
details.fold { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
details.fold > summary { cursor: pointer; padding: 7px 10px; font-size: 12px; font-weight: 700; color: var(--navy); }
details.fold > pre, details.fold > .fold-body { margin: 0; padding: 8px 10px 10px; border-top: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; }

/* scheda dati */
.meta { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 8px 14px; align-items: start; margin: 0; }
.meta dt { font-size: 12px; font-weight: 600; color: var(--muted); padding-top: 7px; }
.meta dd { margin: 0; min-width: 0; }
.meta dd.text { padding-top: 6px; overflow-wrap: anywhere; }
.meta code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
.meta input[type="text"] { width: 100%; font-weight: 600; }
.meta .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.meta .hint b { color: var(--navy); }
.readonly-box { padding: 7px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; font-size: 13px; }
.dirty-flag { color: var(--warn); font-size: 12px; font-weight: 600; }

/* azioni laterali */
.action-card h3 { display: flex; align-items: center; gap: 8px; }
.action-card .state { margin: 8px 0 2px; }
.action-card.inactive { background: var(--surface-2); }
.action-card.inactive h3 { color: var(--muted); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn-row .btn.grow { flex: 1; }
.cost-line { font-size: 13px; margin-top: 10px; padding: 7px 10px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); }
.cost-line.paid { background: var(--yellow-50); border-color: #f3d27a; }
.cost-line b { color: var(--navy); }
.gen-status { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--info); }

.proposal .core { font-size: 14px; font-weight: 600; color: var(--navy); margin: 8px 0 0; }
.proposal ul { margin: 2px 0 0; padding-left: 18px; }
.proposal li { margin: 1px 0; }
.proposal .risk { background: var(--warn-bg); color: #6e4700; border-radius: 7px; padding: 7px 10px; font-size: 13px; }
.proposal .qa-ok { background: #e7f6ec; color: #14532d; border-radius: 7px; padding: 7px 10px; font-size: 13px; margin-top: 6px; }
.proposal > div > .risk:first-child, .proposal .qa-ok + .core { margin-top: 6px; }

.history { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.hist-item {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; cursor: pointer; padding: 0;
}
.hist-item:hover { border-color: var(--navy-600); }
.hist-item.viewing { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.hist-item .h-thumb { aspect-ratio: 16 / 9; background: #d8dee8; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.hist-item .h-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hist-item .h-body { padding: 6px 9px 8px; font-size: 12px; }
.hist-item .h-body .err { color: var(--danger); margin-top: 3px; }

.events { width: 100%; border-collapse: collapse; font-size: 12px; }
.events td { padding: 5px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.events td:first-child { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.events td:nth-child(2) { white-space: nowrap; font-weight: 600; color: var(--navy); }
.events td:last-child { color: var(--muted); overflow-wrap: anywhere; }

/* lightbox e guida tasti */
.overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(1, 10, 25, .92);
  display: flex; flex-direction: column;
}
.overlay .ov-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: var(--white); flex-wrap: wrap; }
.overlay .ov-bar .btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.25); color: var(--white); }
.overlay .ov-bar .btn.on { background: var(--yellow); color: var(--navy); border-color: var(--yellow); }
.overlay .ov-img { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 16px 16px; }
.overlay .ov-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.help-box { margin: auto; background: var(--surface); color: var(--text); border-radius: 12px; padding: 18px 22px; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
.help-box table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.help-box td { padding: 5px 0; border-top: 1px solid var(--line); }
.help-box td:first-child { width: 120px; }
.help-box kbd { opacity: 1; font-size: 11px; padding: 0 6px; margin: 0 2px 0 0; }

.fatal { max-width: 640px; margin: 60px auto; }

/* ------------------------------------------------------------ accesso */
.login-wrap { display: grid; place-items: start center; padding: 8vh 16px 40px; }
.login-card { width: 100%; max-width: 380px; }
.login-card input { width: 100%; }
.login-card .notice { margin-top: 12px; }
.pw-wrap { position: relative; }
.login-card .pw-wrap input { padding-right: 104px; }
.pw-toggle {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--navy); font: 600 13px var(--font); cursor: pointer;
}
.pw-toggle:hover { background: var(--navy-100); }
.pw-toggle:focus-visible { outline: 2px solid var(--yellow); outline-offset: 1px; }
.pw-toggle .eye-closed, .pw-toggle[aria-pressed="true"] .eye-open { display: none; }
.pw-toggle[aria-pressed="true"] .eye-closed { display: inline; }

/* ------------------------------------------------------------ larghezze ridotte */
@media (max-width: 1180px) {
  .item-layout { grid-template-columns: minmax(0, 1fr); }
  .col-side { position: static; max-height: none; overflow: visible; }
  .post-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .page, .item-layout { padding-left: 12px; padding-right: 12px; }
  .appbar { padding: 8px 12px; }
  .img-pair.side { grid-template-columns: minmax(0, 1fr); }
  .meta { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .meta dt { padding-top: 10px; }
  .filters input[type="search"] { width: 100%; }
  .filters select { max-width: 100%; flex: 1 1 140px; }
  .filters .count { margin-left: 0; }
  .metric.wide { grid-column: span 1; }
  .bulkbar .divider { display: none; }
  .topbar .tb-title { order: 5; flex-basis: 100%; }
}

/* ---- Area titolare + note del titolare ---- */
.chip.owner-note { background: var(--yellow); color: var(--navy); }
.appbar .owner-notes-btn { background: var(--yellow); border-color: var(--yellow); color: var(--navy); }
.appbar .owner-notes-btn:hover:not(:disabled) { background: #ffc93f; border-color: #ffc93f; }
.appbar .owner-notes-btn b { color: var(--navy); }
.appbar-link { font-size: 12px; color: #c9d3e4 !important; text-decoration: none; border-bottom: 1px dotted rgba(255,255,255,.4); white-space: nowrap; }
.appbar-link:hover { color: var(--white) !important; }

/* finestra «note del titolare» nella dashboard */
.owner-inbox-ov { justify-content: center; padding: 24px 16px; }
.owner-inbox { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; outline: none; }
.owner-inbox h2 { font-size: 18px; }
.oi-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.oi-item { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.oi-item.new { border-color: #f3d27a; background: var(--yellow-50); }
.oi-link { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; color: inherit; text-decoration: none; }
.oi-link:hover { background: rgba(1, 22, 55, .03); }
.oi-link img { width: 120px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: #d8dee8; }
.oi-title { font-weight: 700; color: var(--navy); text-transform: uppercase; font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.oi-body { margin-top: 4px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* pagina immagine: riquadro note del titolare */
.owner-notes-panel { background: var(--yellow-50); border-color: #f3d27a; border-left: 5px solid var(--yellow); }
.owner-notes-panel.all-closed { background: var(--surface); border-left-color: var(--line-strong); }
.owner-notes-panel .panel-head { margin-bottom: 6px; }
.onote { padding: 10px 12px; border-radius: 8px; background: var(--surface); border: 1px solid #f0d48b; }
.onote + .onote { margin-top: 8px; }
.onote.closed { border-color: var(--line); background: var(--surface-2); }
.onote-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.onote-body { margin-top: 6px; font-size: 14px; font-weight: 600; color: var(--navy); white-space: pre-wrap; overflow-wrap: anywhere; }
.onote.closed .onote-body { font-weight: 500; color: var(--text); }
.onote-reply { margin-top: 6px; font-size: 13px; color: var(--muted); }
.onote-reply-form { margin-top: 6px; }
.onote-how { margin: 10px 0 0; color: #6e4700; }

/* ------------------------------------------------------------ pagina del titolare */
.owner-page { max-width: 1480px; }
.owner-preview { margin-bottom: 14px; }
.owner-intro { margin: 6px 0 16px; }
.owner-intro h1 { font-size: 24px; color: var(--navy); letter-spacing: -.01em; }
.owner-intro p { margin: 6px 0 0; max-width: 780px; color: var(--muted); font-size: 14px; }

.owner-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.o-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; min-height: 92px; }
.o-tile.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); }
.o-tile.wide { grid-column: 1 / -1; min-height: 0; }
.o-tile.accent { border-top: 3px solid var(--yellow); }
.o-tile.attn { background: var(--yellow-50); border-color: #f3d27a; }
.o-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.o-value { font-size: 26px; font-weight: 700; color: var(--navy); line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.o-value small { font-size: 14px; font-weight: 600; color: var(--muted); }
.o-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.owner-hint { margin: 8px 2px 18px; font-size: 12px; color: var(--muted); max-width: 900px; }

.owner-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); }
.owner-tabs button {
  border: 0; background: transparent; font: inherit; font-size: 16px; font-weight: 700; color: var(--muted);
  padding: 10px 18px 9px; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px;
  display: inline-flex; align-items: center; gap: 8px; border-radius: 8px 8px 0 0;
}
.owner-tabs button:hover { color: var(--navy); background: rgba(1, 22, 55, .04); }
.owner-tabs button.on { color: var(--navy); border-bottom-color: var(--yellow); }
.owner-tabs button:focus-visible { outline: 2px solid var(--yellow); outline-offset: -2px; }
.owner-tabs .n { font-size: 12px; font-weight: 700; background: var(--navy-100); color: var(--navy); border-radius: 999px; padding: 1px 8px; min-width: 24px; text-align: center; }
.owner-tabs button.on .n { background: var(--navy); color: var(--yellow); }
.owner-cat-line { margin: 10px 2px 6px; font-size: 13px; color: var(--muted); }
.owner-cat-line b { color: var(--navy); }
.owner-filters { margin-top: 4px; }

.owner-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.owner-card .card-link { height: 100%; display: flex; flex-direction: column; }
.owner-card .card-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.owner-card.has-note { border-color: #f3d27a; box-shadow: 0 0 0 1px #f3d27a, var(--shadow); }
.owner-card .thumb .t-flags { position: absolute; right: 6px; top: 6px; display: flex; gap: 4px; }
.owner-card .thumb .t-flags .chip { box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.owner-card .thumb-missing { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.oc-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.oc-cost { font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.oc-notes { margin-left: auto; }
.owner-more { display: flex; justify-content: center; margin-top: 18px; }

/* dettaglio immagine (finestra sovrapposta) */
body.od-open { overflow: hidden; }
.od-wrap {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(1, 10, 25, .72);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 3vh 16px; overflow-y: auto;
}
.od { width: min(1360px, 100%); background: var(--bg); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: clip; outline: none; }
.od-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--navy); color: var(--white); border-bottom: 3px solid var(--yellow);
}
.od-head .btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.25); color: var(--white); }
.od-head .btn:hover:not(:disabled) { background: rgba(255,255,255,.18); }
.od-nav { display: inline-flex; align-items: center; gap: 6px; }
.od-pos { min-width: 70px; text-align: center; font-size: 12px; color: #c9d3e4; font-variant-numeric: tabular-nums; }
.od-title { flex: 1; min-width: 0; }
.od-title h2 { color: var(--white); font-size: 16px; text-transform: uppercase; letter-spacing: .01em; overflow-wrap: anywhere; }
.od-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 3px; font-size: 12px; color: #c9d3e4; }
.od-sub .chip.attn { background: var(--yellow); color: var(--navy); }
.od-body { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); gap: 16px; padding: 16px; align-items: start; }
.od-media { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; position: sticky; top: 76px; }
.od-media-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.od-media .slider-stage .lbl.r { background: var(--yellow); color: var(--navy); }
.od-side { grid-template-columns: minmax(0, 1fr); }
.od-side .stage img { cursor: default; }
.od-open-links { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; }
.od-info { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.od-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.od-sec h3 { margin-bottom: 6px; }
.od-sec h4 { margin-top: 10px; }
.od-list { margin: 4px 0 0; padding-left: 18px; font-size: 13.5px; }
.od-list li { margin: 3px 0; }
.od-list.checks { list-style: none; padding-left: 0; }
.od-list.checks li::before { content: "✓"; color: var(--ok); font-weight: 800; margin-right: 8px; }
.od-why { margin: 0; font-size: 13.5px; }
.od-notes { border-left: 4px solid var(--yellow); }
.on-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.on-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface-2); }
.on-item.s-aperta, .on-item.s-vista { background: var(--yellow-50); border-color: #f3d27a; }
.on-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.on-body { margin-top: 5px; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.on-reply { margin-top: 6px; font-size: 13px; padding: 6px 8px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); }
.on-form { margin-top: 6px; }
.on-form-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }

@media (max-width: 1000px) {
  .od-body { grid-template-columns: minmax(0, 1fr); }
  .od-media { position: static; }
}
@media (max-width: 640px) {
  .od-wrap { padding: 0; }
  .od { border-radius: 0; min-height: 100%; }
  .od-head { padding: 8px 10px; gap: 8px; }
  .od-title { order: 3; flex-basis: 100%; }
  .od-head #dClose { margin-left: auto; }
  .od-body { padding: 10px; gap: 10px; }
  .owner-intro h1 { font-size: 20px; }
  .owner-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .owner-summary .o-tile { min-height: 0; padding: 10px 11px; }
  .owner-summary .o-tile:first-child { grid-column: 1 / -1; }
  .o-label { font-size: 10px; }
  .o-sub { font-size: 11px; }
  .owner-tabs button { font-size: 15px; padding: 9px 12px 8px; }
  .o-value { font-size: 22px; }
  .oi-link { grid-template-columns: 84px minmax(0, 1fr); }
  .oi-link img { width: 84px; }
  .oi-link .btn { display: none; }
}

/* grafica ridisegnata: layout modificabile in pre-review */
.gfx-box { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.gfx-box h4 { margin: 0 0 6px; font-size: 14px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.gfx-modes { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.gfx-sec { font-weight: 600; font-size: 13px; margin: 12px 0 4px; }
.gfx-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; margin: 6px 0; }
.gfx-row.sub { margin-left: 18px; }
.gfx-row textarea, .gfx-row input[type="text"] { flex: 1 1 200px; min-width: 0; font-size: 13px; }
.gfx-row select { font-size: 13px; }
.gfx-role { font-size: 11px; color: var(--muted); min-width: 64px; padding-top: 6px; text-transform: uppercase; letter-spacing: .02em; }
.gfx-orig { padding-top: 5px; }
.gfx-ocr { flex-basis: 100%; margin-left: 70px; }
