/* ============ base ============ */
:root {
  --bg: #f4f5f9;
  --surface: #fff;
  --border: #e3e6ee;
  --border-strong: #cfd4e0;
  --text: #1c2333;
  --muted: #6b7385;
  --primary: #3b5bdb;
  --primary-dark: #2f4bc0;
  --primary-soft: #eaeefd;
  --danger: #e03131;
  --danger-soft: #fdecec;
  --warn: #e67700;
  --warn-soft: #fff4e0;
  --ok: #2b8a3e;
  --ok-soft: #e6f6ea;
  --sidebar: #1a2033;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .05);
  color-scheme: light; /* controlli nativi (date, select, scrollbar) nel tema chiaro */
  /* superfici, passaggi del mouse e segnaposto */
  --surface-2: #f8f9fc;
  --surface-3: #fafbfc;
  --hover: #f1f3f9;
  --hover-soft: #fafbff;
  --hover-btn: #f0f2f8;
  --hover-strong: #e9ecf4;
  --placeholder: #e7eaf3;
  --placeholder-2: #eef0f6;
  --today-bg: #f2f5ff;
  --selected-bg: #f8faff;
  --auth-bg: linear-gradient(160deg, #eaeefd, #f4f5f9 60%);
  /* testi e icone tenui */
  --text-soft: #3a4258;
  --faint: #c5cad8;
  --faint-icon: #9aa1b3;
  --badge-ink: #000; /* colore con cui si scurisce il testo dei badge di stato */
  /* messaggi colorati */
  --danger-text: #a61e1e;
  --danger-border: #f5c2c2;
  --warn-text: #8a4b00;
  --warn-border: #f7d9a4;
  --ok-text: #1f6b30;
  /* pulsanti pieni: sempre con testo bianco, in entrambi i temi */
  --danger-strong: #e03131;
  --ok-strong: #2b8a3e;
  --warn-strong: #e67700;
  --toast-bg: #20263a;
  --plat-ink: #111; /* logo di X e TikTok */
}

/* ============ tema scuro ============ */
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0e1320;
  --surface: #171d2c;
  --surface-2: #1b2233;
  --surface-3: #1a2131;
  --border: #2b344a;
  --border-strong: #3a4562;
  --text: #e7eaf3;
  --text-soft: #c3cadb;
  --muted: #98a2bb;
  --faint: #75819f;
  --faint-icon: #7480a0;
  --primary: #5a78f5;
  --primary-dark: #4a68e6;
  --primary-soft: #222b4d;
  --danger: #ff6b6b;
  --danger-soft: #3a2027;
  --danger-text: #ff9c9c;
  --danger-border: #6b2f38;
  --warn: #ffa94d;
  --warn-soft: #382b16;
  --warn-text: #ffc078;
  --warn-border: #6b5122;
  --ok: #51cf66;
  --ok-soft: #173424;
  --ok-text: #8ce99a;
  --sidebar: #0a0e19;
  --hover: #212a3f;
  --hover-soft: #1a2235;
  --hover-btn: #212a3f;
  --hover-strong: #2a3550;
  --placeholder: #252e45;
  --placeholder-2: #232b40;
  --today-bg: #1a2447;
  --selected-bg: #1a2240;
  --auth-bg: linear-gradient(160deg, #141b30, #0e1320 60%);
  --badge-ink: #fff;
  --toast-bg: #2b344a;
  --plat-ink: #f1f3f9;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 8px rgba(0, 0, 0, .3);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
.icon { flex: none; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.pre { white-space: pre-wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row-end { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.row-end.wrap { flex-wrap: wrap; justify-content: flex-start; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.pad { padding: 4px 16px 12px; }
.boot-error, .form-error { color: var(--danger); font-weight: 500; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ============ controlli ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface); font-weight: 500;
}
.btn:hover:not(:disabled) { background: var(--hover-btn); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--ok-strong); border-color: var(--ok-strong); color: #fff; }
.btn-success:hover:not(:disabled) { background: #237032; }
.btn-danger { background: var(--danger-strong); border-color: var(--danger-strong); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c02525; }
.btn-danger-ghost { border-color: transparent; background: transparent; color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 36px; padding: 0; }
.btn-block { width: 100%; }
.btn-active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; flex: none;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--hover-strong); color: var(--text); }
.icon-btn.danger-hover:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.light { color: #aeb6cc; }
.icon-btn.light:hover { background: rgba(255,255,255,.1); color: #fff; }
.linklike { border: 0; background: none; padding: 0; color: var(--primary); text-align: left; }
.linklike:hover { text-decoration: underline; }

.input {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); font: inherit; color: inherit;
}
textarea.input { height: auto; min-height: 36px; padding: 8px 10px; resize: vertical; line-height: 1.4; }
.input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
select.input { padding-right: 6px; }
.input.plain { border-color: transparent; background: transparent; padding: 0 6px; }
.input.plain:hover { border-color: var(--border); }
.input.plain:focus { background: var(--surface); border-color: var(--primary); }
.muted-input { color: var(--muted); }
.title-input { font-size: 16px; font-weight: 600; }
.color-input { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.field-hint { font-size: 12px; color: var(--muted); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 40px; }
.pw-toggle { position: absolute; top: 0; right: 0; height: 36px; width: 38px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); border-radius: 0 8px 8px 0; }
.pw-toggle:hover { color: var(--text); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  color: color-mix(in srgb, var(--st, #64748b) 75%, var(--badge-ink)); background: color-mix(in srgb, var(--st, #64748b) 16%, var(--surface));
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st, #94a3b8); display: inline-block; flex: none; }
.st-in_preparazione { --st: #94a3b8; }
.st-da_approvare { --st: #f59f00; }
.st-approvato { --st: #2f9e44; }
.st-programmato { --st: #3b82f6; }
.st-pubblicato { --st: #8b5cf6; }
.st-idea { --st: #64748b; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--primary-soft); color: var(--primary); margin-left: 8px; }
.warn-tag { background: var(--warn-soft); color: var(--warn); margin: 0; }
.ok-tag { background: var(--ok-soft); color: var(--ok); margin: 0; }
.muted-tag { background: var(--placeholder-2); color: var(--muted); margin: 0; }
.count-badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: auto; border-radius: 999px; background: rgba(255,255,255,.16); font-size: 12px; text-align: center; line-height: 20px; }
.count-badge.warn { background: var(--warn-strong); color: #fff; }
.count-badge.neutral { margin-left: 8px; background: var(--placeholder); color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--placeholder-2); font-size: 12px; font-weight: 500; }
.pill.soft { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.clamp, .clamp2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; -webkit-line-clamp: 3; line-clamp: 3; white-space: pre-wrap; overflow-wrap: anywhere; }
.clamp2 { -webkit-line-clamp: 2; line-clamp: 2; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; min-height: 32px; }
.card-head h2, .card-head h3 { flex: 1; display: flex; align-items: center; }
.card-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.banner { display: flex; gap: 12px; padding: 12px 14px; border-radius: 8px; align-items: flex-start; }
.banner p { margin-top: 2px; }
.banner.danger { background: var(--danger-soft); color: var(--danger-text); border: 1px solid var(--danger-border); }
.banner.warn { background: var(--warn-soft); color: var(--warn-text); border: 1px solid var(--warn-border); margin-bottom: 14px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty p:first-child { font-size: 15px; color: var(--text); margin-bottom: 4px; }
.company-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.company-dot.lg { width: 16px; height: 16px; }
.save-ind { font-size: 12.5px; color: var(--muted); min-width: 90px; }
.save-ind.saved { color: var(--ok); }
.save-ind.error { color: var(--danger); }

/* ============ toast / modali ============ */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 300; align-items: center; }
.toast { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-radius: 8px; background: var(--toast-bg); color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast-error { background: #b02525; }
.toast-action { border: 0; background: none; color: #9db4ff; font-weight: 600; padding: 0; }
.overlay { position: fixed; inset: 0; background: rgba(20, 26, 44, .5); display: grid; place-items: center; z-index: 200; padding: 24px; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-height: calc(100vh - 48px); display: flex; flex-direction: column; box-shadow: 0 12px 48px rgba(0,0,0,.3); }
.modal-sm { max-width: 440px; }
.modal-md { max-width: 640px; }
.modal-lg { max-width: 760px; transition: max-width .2s; }
.modal-lg.has-preview { max-width: 1180px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px; overflow: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }

/* ============ login ============ */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--auth-bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 14px; padding: 32px; box-shadow: 0 8px 32px rgba(30, 40, 90, .12); display: flex; flex-direction: column; gap: 14px; }
.auth-logo { width: 48px; height: 48px; border-radius: 12px; background: var(--primary); color: #fff; display: grid; place-items: center; }
.remember { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.remember input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); flex: none; cursor: pointer; }
.remember span { display: flex; flex-direction: column; gap: 1px; }
.remember small { font-size: 12px; line-height: 1.35; }
.rules { list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--muted); display: grid; gap: 3px; }
.rules li::before { content: '○ '; }
.rules li.ok { color: var(--ok); }
.rules li.ok::before { content: '✓ '; }

/* ============ shell amministratore ============ */
.shell { display: grid; grid-template-columns: 250px 1fr; height: 100vh; min-width: 1100px; /* la parte amministratore è solo per desktop */ }
.sidebar { border-right: 1px solid rgba(255, 255, 255, .06); background: var(--sidebar); color: #d5daea; display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; font-size: 15px; padding: 4px 8px 16px; }
.brand-logo { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #d5daea; border: 0; background: none; text-align: left; width: 100%; }
.nav-item:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,.14); color: #fff; }
.sidebar-section { display: flex; align-items: center; justify-content: space-between; padding: 14px 8px 4px 10px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: #8c95b2; }
.company-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 2px; min-height: 0; padding-bottom: 6px; }
.company-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #d5daea; cursor: grab; user-select: none; position: relative; }
.company-item:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.company-item.active { background: rgba(255,255,255,.14); color: #fff; }
.company-item.dragging { z-index: 5; background: #2d3654; box-shadow: 0 6px 18px rgba(0,0,0,.4); cursor: grabbing; }
.company-list.sorting { cursor: grabbing; }
.company-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-warn { width: 18px; height: 18px; border-radius: 50%; background: var(--danger-strong); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.sidebar-empty { padding: 8px 10px; font-size: 13px; color: #8c95b2; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.user-box { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.06); color: #d5daea; }
.user-box:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.user-box.active { background: rgba(255,255,255,.18); color: #fff; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; display: grid; place-items: center; flex: none; }
.user-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.user-text strong { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-text small { color: #8c95b2; }
.account-card { max-width: 520px; }
.account-lead { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }
.field-hint.error { color: var(--danger); }
.main { overflow: auto; height: 100vh; min-width: 0; }
.page { padding: 24px 28px; }
.page-section { display: flex; flex-direction: column; gap: 14px; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
/* barra fissa in cima alla scheda (dentro .tab-content, che non ha padding superiore): top 0, altrimenti la prima riga resta tagliata */
.section-head.sticky { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 8px 0 12px; margin: 0 0 4px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; }
.inline-form .input { min-width: 260px; }

/* ============ calendario ============ */
.calendar-page { display: flex; flex-direction: column; gap: 14px; min-height: 100%; }
.alerts { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; display: flex; gap: 12px; align-items: flex-start; }
.alerts:empty { display: none; }
.alerts-head { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--danger); padding-top: 4px; }
.alerts-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 92px; overflow: auto; }
.alert-chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; color: var(--text); border: 1px solid; }
.alert-chip:hover { text-decoration: none; filter: brightness(.96); }
.alert-chip.danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }
.alert-chip.warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-text); }
.cal-toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cal-nav { display: flex; gap: 6px; flex: none; }
.cal-toolbar .seg { flex: none; }
.cal-title { white-space: nowrap; }
.legend { display: flex; gap: 14px; margin-left: auto; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-dow { padding: 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 112px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.has-posts { cursor: pointer; }
.cal-cell.has-posts:hover { background: var(--hover-soft); }
.cal-cell.other { background: var(--surface-3); color: var(--muted); }
.cal-cell.other .cal-entry { opacity: .6; }
.cal-num { font-size: 12px; font-weight: 600; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; }
.cal-cell.today .cal-num { background: var(--primary); color: #fff; font-weight: 700; }
/* giorno di oggi: il contorno blu sta sul bordo esterno della cella (offset negativo = dentro la cella, sopra il suo bordo) */
.cal-cell.today { background: var(--today-bg); outline: 3px solid var(--primary); outline-offset: -3px; }
/* dove la cella tocca un angolo del calendario ne prende l'arrotondamento (raggio interno della griglia = 10px - 1px di bordo) */
.cal-cell.r-tl { border-top-left-radius: 9px; }
.cal-cell.r-tr { border-top-right-radius: 9px; }
.cal-cell.r-bl { border-bottom-left-radius: 9px; }
.cal-cell.r-br { border-bottom-right-radius: 9px; }
.cal-entry { display: flex; align-items: center; gap: 6px; width: 100%; padding: 2px 4px; border: 0; border-radius: 4px; background: transparent; text-align: left; font-size: 12px; }
.cal-entry:hover { background: color-mix(in srgb, var(--st) 14%, var(--surface)); }
.cal-entry-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-more { font-size: 11.5px; color: var(--muted); padding-left: 4px; }
/* vista settimanale */
.cal-grid.week .cal-cell { min-height: 440px; padding: 8px; gap: 6px; }
.cal-grid.week .cal-cell.has-posts { cursor: default; }
.cal-grid.week .cal-cell.has-posts:hover { background: transparent; }
.cal-day-head { display: flex; align-items: center; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.cal-day-name { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.week-entry { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-left: 4px solid var(--st, #94a3b8); border-radius: 6px; background: var(--surface); text-align: left; }
.week-entry:hover { background: var(--hover); }
.week-entry-top { display: flex; align-items: center; gap: 6px; max-width: 100%; }
.week-entry-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.week-entry-title { font-size: 12.5px; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.week-entry-meta { font-size: 11.5px; color: var(--muted); }
.cal-empty { color: var(--faint); text-align: center; margin-top: 6px; }
.cal-side { display: flex; flex-direction: column; gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.panel h2 { display: flex; align-items: center; font-size: 14px; }
.side-list { display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow: auto; }
.side-item { display: flex; align-items: flex-start; gap: 8px; padding: 6px; border-radius: 6px; border: 0; background: none; text-align: left; color: inherit; width: 100%; }
.side-item:hover { background: var(--hover); text-decoration: none; }
.side-item .dot, .side-item .company-dot { margin-top: 5px; }
.side-item-main { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.side-item-main span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-group { margin-bottom: 14px; }
.day-group h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.day-post { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); margin-bottom: 4px; text-align: left; }
.day-post:hover { background: var(--hover); }
.day-post-title { flex: 1; font-weight: 500; }

/* ============ azienda ============ */
.company-page { height: 100vh; display: flex; flex-direction: column; gap: 14px; }
.company-head h1 { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab { position: relative; padding: 9px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-warn { position: absolute; top: 8px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.tab-content { flex: 1; min-height: 0; overflow: auto; padding-bottom: 8px; }
.tab-content.tab-ced { overflow: hidden; }

/* PED · CED */
.ced { height: 100%; display: flex; flex-direction: column; gap: 14px; }
.ped-section { flex: none; display: flex; flex-direction: column; gap: 10px; }
.ped-head { display: flex; align-items: center; gap: 14px; min-height: 34px; }
.ped-toggle { display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 5px 10px 5px 4px; border: 0; border-radius: 8px; background: none; color: var(--text); font-size: 16px; font-weight: 700; }
.ped-toggle:hover { background: var(--hover); }
/* riga di sintesi a PED ridotto */
.ped-summary { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.ped-summary:hover { border-color: var(--border-strong); }
.ped-sum-period { font-weight: 700; white-space: nowrap; }
.ped-sum-pct { display: flex; gap: 14px; white-space: nowrap; flex: none; }
.ped-sum-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; }
.ped-sum-chip i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.ped-sum-goals { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.ped-alert { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--danger-border); background: var(--danger-soft); color: var(--danger-text); font-size: 12.5px; font-weight: 600; }
.ped-row { flex: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.ped-card { max-height: 250px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.ped-card .card-head { margin-bottom: 0; }
.ped-period { font-weight: 700; font-size: 15px; }
.ped-goals { white-space: pre-wrap; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; color: var(--text-soft); }
.pct-legend { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; font-size: 12.5px; }
.pct-legend li { display: flex; align-items: center; gap: 6px; }
.pct-legend i, .pct-field i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.archive-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.archive-item { width: 100%; display: flex; flex-direction: column; gap: 2px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: none; text-align: left; }
.archive-item:hover { background: var(--hover); }
.archive-period { font-weight: 600; }
.archive-pct { display: flex; gap: 12px; font-size: 12.5px; font-weight: 600; }
.archive-full { padding: 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.archive-full.active { border-color: var(--primary); background: var(--selected-bg); }
.archive-full .card-head { margin: 0; }
.pct-fields { border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.pct-fields legend { font-weight: 600; font-size: 12.5px; padding: 0 6px; }
.pct-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; }
.pct-field span { display: flex; align-items: center; gap: 6px; }
.pct-input { display: flex; align-items: center; gap: 4px; }
.pct-total { margin-top: 10px; font-weight: 600; }
.pct-total.ok { color: var(--ok); }
.pct-total.ko { color: var(--danger); }
.ced-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.ced-toolbar { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.ced-toolbar .input { width: auto; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box .icon { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.search-box .input { padding-left: 32px; width: 220px; }
.select-wrap { position: relative; }
.select-btn { min-width: 150px; justify-content: space-between; }
.popover { position: absolute; top: 40px; right: 0; z-index: 30; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.pop-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.pop-item:hover { background: var(--hover); }
.popover .linklike { padding: 6px 8px; font-size: 12.5px; }
.table-scroll { flex: 1; min-height: 0; overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); padding: 0; white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.ced-table td:nth-child(4), .ced-table td:nth-child(5), .ced-table td:nth-child(6) { max-width: 260px; min-width: 130px; }
.th-plain { display: block; padding: 9px 12px; font-weight: 600; }
.col-thumb { width: 76px; padding-top: 7px; padding-bottom: 7px; }

/* miniature (CED, calendario) */
.thumb { position: relative; display: inline-block; flex: none; padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--placeholder); vertical-align: middle; }
button.thumb { cursor: zoom-in; }
button.thumb:hover { border-color: var(--primary); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-empty { display: inline-grid; place-items: center; background: var(--surface-2); color: var(--faint); border-style: dashed; }
.thumb-fluid { display: block; align-self: stretch; }
.cal-entry .thumb { border-width: 0; }
.cal-entry .thumb-count { display: none; }
.side-item .thumb, .day-post .thumb { align-self: flex-start; }
.thumb-count { position: absolute; right: 3px; bottom: 3px; padding: 0 5px; border-radius: 999px; background: rgba(0, 0, 0, .65); color: #fff; font-size: 10.5px; font-weight: 600; line-height: 16px; }
.thumb-play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, .22); pointer-events: none; }
.col-plats { min-width: 190px; }
/* piattaforme e formati: una riga per formato diverso, mai una riga lunghissima */
.pgroups { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.pgroup { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.pgroup-plats { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.pgroup-format { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.pgroup-more { font-size: 11.5px; color: var(--muted); }
.plat-pill { display: inline-flex; align-items: center; gap: 5px; }
.plat-pill-logo { display: inline-flex; }
.th-sort { display: flex; align-items: center; gap: 6px; width: 100%; padding: 9px 12px; border: 0; background: none; font-weight: 600; text-align: left; color: inherit; }
.th-sort:hover { color: var(--text); }
.th-sort.on { color: var(--primary); }
.sort-ind { font-size: 10px; opacity: .7; }
.post-row { cursor: pointer; }
.post-row:hover { background: var(--hover); }
.col-date { white-space: nowrap; font-weight: 500; }
.nodate { color: var(--warn); font-style: italic; }
.col-status { min-width: 150px; }
.status-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.client-badge { font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.client-badge.ok { background: var(--ok-soft); color: var(--ok); }
.client-badge.ko { background: var(--danger-soft); color: var(--danger); }
.client-note { font-size: 12px; color: var(--danger-text); max-width: 220px; }
.col-actions { width: 44px; text-align: right; }
.col-actions.wide { width: 210px; white-space: nowrap; }
.table-empty { caption-side: bottom; padding: 30px; color: var(--muted); }

/* Pagina Account: modulo a sinistra, registro accessi a destra */
.account-layout { display: grid; grid-template-columns: minmax(300px, 480px) minmax(0, 1fr); gap: 16px; align-items: start; }
.account-layout .account-card { max-width: none; }

/* Registro accessi (pagina Account) */
.log-card .table-scroll { max-height: calc(100vh - 300px); min-height: 220px; }
.log-table th .th-plain { display: block; padding: 8px 12px; }
.log-table .nowrap { white-space: nowrap; }
.log-table .small, .log-card .small { font-size: 12px; margin: 2px 0 0; }
.log-table .tag { margin-left: 0; }

/* post form */
.pf-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.modal-lg.has-preview .pf-layout { grid-template-columns: minmax(0, 1fr) 360px; }
.pf-preview { display: none; border-left: 1px solid var(--border); padding-left: 20px; }
.modal-lg.has-preview .pf-preview { display: block; }
.pf-preview h3 { margin-bottom: 10px; }
/* selettore piattaforme a loghi + tendina dei formati */
.plat-picker { position: relative; }
.plat-row { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-start; }
.plat { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 64px; }
.plat-btn { width: 50px; height: 50px; border-radius: 12px; border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--faint-icon); display: grid; place-items: center; padding: 0; transition: border-color .12s, background .12s, color .12s; }
.plat-btn:hover { border-color: var(--primary); color: var(--muted); }
.plat.on .plat-btn { border-width: 2px; background: color-mix(in srgb, currentColor 9%, var(--surface)); }
.plat.on .plat-btn:hover { filter: brightness(.96); }
.plat-format { font-size: 11.5px; font-weight: 600; max-width: 100px; text-align: center; line-height: 1.2; }
.plat-format.none { font-weight: 400; font-style: italic; color: var(--muted); }
.plat-pop { position: absolute; z-index: 40; min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 28px rgba(20, 30, 60, .22); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.plat-pop-title { display: flex; align-items: center; gap: 8px; padding: 6px 8px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 13px; }
.plat-pop-title .muted { margin-left: auto; font-size: 11.5px; }
.pop-opt { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: none; text-align: left; }
.pop-opt:hover, .pop-opt:focus-visible { background: var(--hover); outline: none; }
.pop-opt.sel { font-weight: 600; color: var(--primary); }
.pop-opt.subtle { color: var(--muted); }
.pop-opt.danger { color: var(--danger); margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0 0 6px 6px; }
.pop-opt.danger:hover { background: var(--danger-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-check { cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span { display: inline-block; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border-strong); font-weight: 500; }
.chip-check input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-check input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.origin { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.dropzone { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px; border: 1.5px dashed var(--border-strong); border-radius: 8px; color: var(--muted); }
.dropzone.over, .file-group.over { border-color: var(--primary); background: var(--primary-soft); }
.img-tiles { display: flex; flex-wrap: wrap; gap: 10px; }
.img-tiles:empty { display: none; }
.img-tile { width: 132px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-3); }
.img-tile img, .img-tile video { width: 100%; height: 96px; object-fit: cover; display: block; background: var(--placeholder); }
.img-name { display: block; padding: 4px 6px 0; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-actions { display: flex; justify-content: flex-end; padding: 2px; }
.img-actions .icon-btn { width: 26px; height: 26px; }
.client-reply { padding: 10px 12px; border-radius: 8px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.client-reply.ok { background: var(--ok-soft); color: var(--ok-text); }
.client-reply.ko { background: var(--danger-soft); color: var(--danger-text); }
.client-reply p { white-space: pre-wrap; color: var(--text); }

/* anteprima */
.pv { display: flex; flex-direction: column; gap: 10px; }
.pv-none { padding: 20px 0; }
.pv-format { font-size: 12px; text-align: center; }
.pv-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.pv-tab { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 6px; padding: 3px 10px; font-size: 12.5px; }
.pv-tab.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.pv-stage { display: flex; justify-content: center; }
/* i mockup dei social restano chiari anche nel tema scuro, come le vere schede delle piattaforme */
.pv-stage {
  color-scheme: light; color: #1c2333;
  --surface: #fff; --surface-2: #f8f9fc; --border: #e3e6ee; --text: #1c2333; --text-soft: #3a4258;
  --muted: #6b7385; --faint: #c5cad8; --placeholder: #e7eaf3; --primary: #3b5bdb;
}
.pv-card { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; font-size: 13px; }
.pv-head { display: flex; align-items: center; gap: 8px; padding: 10px; }
.pv-head-text { display: flex; flex-direction: column; line-height: 1.25; flex: 1; }
.pv-more { margin-left: auto; color: var(--muted); }
.pv-avatar { width: 36px; height: 36px; border-radius: 50%; color: #fff; font-weight: 700; display: inline-grid; place-items: center; flex: none; }
.pv-avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.pv-media { position: relative; width: 100%; background: var(--placeholder); overflow: hidden; }
.pv-media img, .pv-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-media-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--faint); font-size: 12px; }
.pv-count { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; }
.pv-actions { display: flex; gap: 12px; padding: 8px 10px 4px; align-items: center; }
.pv-likes { padding: 0 10px; font-weight: 600; }
.pv-caption { padding: 4px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pv-text-inline { white-space: pre-wrap; }
.pv-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.pv-placeholder { color: var(--faint); }
.pv-muted { color: var(--muted); padding: 0 10px 8px; }
.pv-muted.sm, .pv-head-text .pv-muted { font-size: 11.5px; padding: 0; }
.pv-pad { padding: 4px 12px 10px; }
.pv-reactions { display: flex; align-items: center; font-size: 12.5px; border-bottom: 1px solid var(--border); padding-top: 8px; }
.pv-fb-actions { display: flex; justify-content: space-around; padding: 6px; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.pv-fb-actions span { display: inline-flex; align-items: center; gap: 5px; }
.pv-linkcard { background: #f0f2f5; }
.pv-linkmeta { padding: 8px 12px; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.pv-btn { background: #dfe3ea; padding: 3px 12px; border-radius: 6px; font-weight: 600; font-size: 12px; }
.pv-clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; white-space: pre-wrap; }
.pv-clamp6 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; line-clamp: 6; overflow: hidden; white-space: pre-wrap; }
.pv-vertical { position: relative; width: 250px; border-radius: 16px; overflow: hidden; background: #111; box-shadow: 0 4px 16px rgba(0,0,0,.2); color: #fff; }
.pv-vertical .pv-media { background: #2a2f3e; }
.pv-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: 10px; background: linear-gradient(transparent 55%, rgba(0,0,0,.6)); font-size: 12px; }
.pv-story .pv-overlay { justify-content: space-between; background: linear-gradient(rgba(0,0,0,.4), transparent 25%, transparent 60%, rgba(0,0,0,.5)); }
.pv-story-bar { height: 3px; background: rgba(255,255,255,.4); border-radius: 2px; margin-bottom: 8px; }
.pv-story-bar i { display: block; width: 35%; height: 100%; background: var(--surface); border-radius: 2px; }
.pv-story-head { display: flex; align-items: center; gap: 6px; }
.pv-story-head span { opacity: .8; }
.pv-story-text { align-self: center; text-align: center; font-size: 17px; font-weight: 700; text-shadow: 0 1px 6px rgba(0,0,0,.7); padding: 0 6px; }
.pv-story-foot { display: flex; justify-content: center; }
.pv-story-reply { width: 100%; padding: 7px 12px; border: 1px solid rgba(255,255,255,.7); border-radius: 999px; }
.pv-pill { background: var(--surface); color: #111; padding: 6px 16px; border-radius: 999px; font-weight: 700; }
.pv-side { position: absolute; right: 8px; bottom: 70px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.pv-reel-info { display: flex; flex-direction: column; gap: 6px; padding-right: 40px; }
.pv-follow { border: 1px solid #fff; border-radius: 6px; padding: 0 8px; font-size: 11px; }
.pv-audio { display: flex; align-items: center; gap: 5px; font-size: 11px; opacity: .9; }
.pv-x-row { display: flex; gap: 10px; padding: 12px; }
.pv-x-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pv-x-name { display: flex; gap: 6px; flex-wrap: wrap; }
.pv-x-name .pv-muted { padding: 0; }
.pv-x-media { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.pv-x-actions { display: flex; justify-content: space-between; color: var(--muted); padding-right: 30px; }
.pv-yt-thumb { position: relative; }
.pv-duration { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.8); color: #fff; font-size: 11.5px; padding: 1px 5px; border-radius: 4px; }
.pv-yt-info { display: flex; gap: 10px; padding: 10px; }
.pv-yt-title { display: block; font-size: 14px; }
.pv-yt-desc { margin-top: 6px; white-space: pre-wrap; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; color: var(--text-soft); }

/* ============ idee ============ */
.rubrica { padding: 0; }
.rubrica .card-head { padding: 10px 12px 0; }
.rubrica-icon { color: var(--warn); display: grid; }
.ideas { display: flex; flex-direction: column; }
.idea-row { display: grid; grid-template-columns: minmax(200px, 1.4fr) minmax(160px, 1.6fr) 130px auto auto; gap: 8px; align-items: center; padding: 6px 12px; border-top: 1px solid var(--border); }
.idea-status { display: flex; }
.add-row { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface-3); border-radius: 0 0 var(--radius) var(--radius); }

/* ============ pillar ============ */
.pillar-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.pillar-card h3 { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 2px solid; }
.cat-identitari h3 { border-color: #6741d9; }
.cat-ispirazionali h3 { border-color: #d6336c; }
.cat-educativi h3 { border-color: #1c7ed6; }
.cat-commerciali h3 { border-color: #e8590c; }
.cat-interattivi h3 { border-color: #2f9e44; }
.cat-extra h3 { border-color: #868e96; }
.pillar-list { list-style: none; margin: 0; padding: 0; }
.pillar-item, .pillar-add { display: flex; align-items: flex-start; gap: 8px; padding: 2px 0; }
.pillar-item .icon-btn { opacity: 0; margin-top: 2px; }
.pillar-item:hover .icon-btn, .pillar-item:focus-within .icon-btn { opacity: 1; }
.bullet { width: 14px; text-align: center; color: var(--text); line-height: 26px; flex: none; }
.bullet.faint { color: var(--faint); }
.plain-text { flex: 1; width: 100%; border: 0; background: transparent; font: inherit; padding: 3px 4px; border-radius: 4px; resize: none; overflow: hidden; line-height: 1.45; color: inherit; }
.plain-text:hover { background: var(--surface-2); }
.plain-text:focus { background: var(--surface); outline: 2px solid var(--primary-soft); }
.bb-swatch { width: 16px; height: 16px; margin-top: 5px; border-radius: 4px; border: 1px solid var(--border-strong); flex: none; }
.bb-legacy { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border-strong); display: flex; flex-direction: column; gap: 8px; }
.pillar-missing { color: var(--danger); font-size: 12.5px; margin-bottom: 4px; }

/* ---------- formattazione ricca: grassetto/sottolineato/a capo (pillar, caption, call to action) ---------- */
.rich-field { display: flex; flex-direction: column; gap: 4px; }
.rich-toolbar { display: flex; gap: 2px; }
.rich-btn {
  width: 24px; height: 24px; border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--text-soft); font: 700 13px/1 inherit; cursor: pointer; display: grid; place-items: center; flex: none;
}
.rich-btn:hover { background: var(--hover-strong); color: var(--text); }
.rich-edit {
  min-height: 36px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); font: inherit; color: inherit; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere;
}
.rich-edit:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

/* variante senza bordo, in linea con bullet e pulsante elimina: usata nell'elenco dei pillar */
.rich-field.inline { flex-direction: row; align-items: flex-start; gap: 4px; flex: 1; }
.rich-field.inline .rich-toolbar { flex-direction: column; opacity: 0; }
.pillar-item:hover .rich-field.inline .rich-toolbar, .pillar-item:focus-within .rich-field.inline .rich-toolbar { opacity: 1; }
.rich-field.inline .rich-btn { width: 20px; height: 20px; font-size: 11px; }
.rich-field.inline .rich-edit { flex: 1; min-height: 0; border: 0; background: transparent; padding: 3px 4px; border-radius: 4px; }
.rich-field.inline .rich-edit:hover { background: var(--surface-2); }
.rich-field.inline .rich-edit:focus { background: var(--surface); outline: 2px solid var(--primary-soft); }

/* ============ domande ============ */
.q-list { display: flex; flex-direction: column; gap: 14px; }
.q-cat { padding: 0; }
.q-cat-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.q-cat-head .title-input { flex: 0 1 380px; min-width: 120px; }
.q-cat-title { font-size: 16px; padding: 0 6px; }
.q-cat-count { font-size: 12.5px; white-space: nowrap; }
.q-cat-head .card-actions { margin-left: auto; }
.q-cat-body { display: flex; flex-direction: column; gap: 10px; padding: 2px 12px 14px; }
.q-cat-empty { padding: 4px 6px; }
.q-toggle { flex: none; }
.q-row { display: grid; grid-template-columns: 30px 40px minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; align-items: start; }
.q-trash-spacer { width: 30px; flex: none; }
.q-num { color: var(--muted); font-size: 16px; font-weight: 600; text-align: right; padding-top: 6px; }
.q-row .icon-btn { margin-top: 3px; }
.q-row textarea { field-sizing: content; min-height: 36px; max-height: 320px; resize: none; }
.q-question { font-weight: 600; }

/* ============ file ============ */
.file-group { border: 1.5px solid var(--border); transition: border-color .15s, background .15s; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.drop-hint { padding: 16px; text-align: center; border: 1.5px dashed var(--border-strong); border-radius: 8px; }
.file-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-3); display: flex; flex-direction: column; }
.file-thumb { height: 110px; display: grid; place-items: center; background: var(--placeholder-2); overflow: hidden; color: var(--muted); }
.file-thumb img { width: 100%; height: 100%; object-fit: contain; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; }
.file-thumb:hover { text-decoration: none; }
.file-glyph { font-weight: 800; font-size: 20px; letter-spacing: .04em; }
.file-meta { padding: 8px 10px 0; display: flex; flex-direction: column; min-width: 0; }
.file-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.file-actions { display: flex; justify-content: flex-end; gap: 2px; padding: 2px 4px 4px; }

/* ============ info ============ */
.info-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.color-pick { gap: 8px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.checklist li { display: flex; align-items: center; gap: 4px; }
.check-row { position: relative; display: flex; align-items: center; gap: 8px; flex: 1; color: var(--muted); padding: 4px 0; cursor: pointer; user-select: none; }
.checklist .done .check-row { color: var(--text); }
.check-row input { position: absolute; opacity: 0; width: 20px; height: 20px; margin: 0; cursor: pointer; }
.check-box { width: 20px; height: 20px; border: 1.5px solid var(--border-strong); border-radius: 6px; display: grid; place-items: center; color: #fff; flex: none; background: var(--surface); }
.check-box .icon { opacity: 0; }
.check-row:hover .check-box { border-color: var(--ok); }
.check-row input:checked + .check-box { background: var(--ok-strong); border-color: var(--ok-strong); }
.check-row input:checked + .check-box .icon { opacity: 1; }
.check-row input:focus-visible + .check-box { outline: 2px solid var(--primary); outline-offset: 2px; }
.check-go { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; color: var(--muted); opacity: .5; }
.check-go:hover { opacity: 1; background: var(--hover-strong); text-decoration: none; }
.appt-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.appt-list li { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; padding-right: 4px; }
.appt-list li.past { opacity: .55; }
.appt-main { flex: 1; text-align: left; border: 0; background: none; padding: 8px 10px; display: flex; flex-direction: column; }
.appt-main span { color: var(--muted); }
.cred-notice { background: var(--warn-soft); border: 1px solid var(--warn-border); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.cred-notice dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 0; }
.cred-notice dt { color: var(--muted); }
.cred-notice dd { margin: 0; font-family: ui-monospace, Consolas, monospace; font-weight: 600; user-select: all; }
.danger-zone { border-color: var(--danger-border); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.company-tag { display: inline-flex; align-items: center; gap: 7px; }
.trash-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.trash-table th { padding: 9px 12px; position: static; }

/* ============ portale cliente ============ */
.client-page { max-width: 920px; margin: 0 auto; padding: 24px 24px 60px; }
.client-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.client-brand { display: flex; align-items: center; gap: 12px; }
.client-header-actions { display: flex; gap: 8px; }
.client-content { display: flex; flex-direction: column; gap: 22px; }
.client-ped { display: flex; flex-direction: column; gap: 10px; }
.client-ped .ped-goals { -webkit-line-clamp: unset; line-clamp: unset; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 14px; }
.seg button.on { background: var(--primary); color: #fff; }
.post-cards { display: flex; flex-direction: column; gap: 14px; }
.post-card { display: flex; flex-direction: column; gap: 10px; }
.post-card.reply-approvato { border-left: 4px solid var(--ok); }
.post-card.reply-modifiche { border-left: 4px solid var(--danger); }
.post-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.post-date { display: block; font-weight: 700; margin-bottom: 4px; }
.post-message { color: var(--text-soft); }
.gallery { display: grid; gap: 8px; }
.gallery.n1 { grid-template-columns: minmax(0, 360px); }
.gallery.n2 { grid-template-columns: repeat(2, minmax(0, 260px)); }
.gallery.n3 { grid-template-columns: repeat(3, minmax(0, 200px)); }
.gallery-item { position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: var(--placeholder); aspect-ratio: 1; cursor: zoom-in; }
.gallery-play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, .25); pointer-events: none; }
.gallery-item img, .gallery-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-block { display: flex; flex-direction: column; gap: 2px; }
.post-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.reply-area { border-top: 1px solid var(--border); padding-top: 12px; }
.reply-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pv-modal { max-width: 440px; margin: 0 auto; }
.pv-note { text-align: center; margin-bottom: 12px; }

/* ingrandimento immagini / video */
.lightbox { position: fixed; inset: 0; z-index: 400; background: rgba(0, 0, 0, .93); display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.lb-stage { display: flex; max-width: 100%; max-height: 100%; }
.lb-stage img, .lb-stage video { max-width: 100vw; max-height: 100vh; object-fit: contain; display: block; }
.lb-btn { position: absolute; z-index: 1; width: 46px; height: 46px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(255, 255, 255, .16); color: #fff; }
.lb-btn:hover { background: rgba(255, 255, 255, .28); }
.lb-close { top: 14px; right: 14px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 13px; background: rgba(0, 0, 0, .5); padding: 2px 12px; border-radius: 999px; }

/* pulsante del tema (chiaro / scuro), in basso a destra in tutte le pagine */
.theme-fab { position: fixed; right: 18px; bottom: 18px; z-index: 150; width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); box-shadow: 0 4px 14px rgba(0, 0, 0, .2); display: grid; place-items: center; transition: transform .12s, border-color .12s, color .12s; }
.theme-fab:hover { transform: scale(1.07); border-color: var(--primary); color: var(--primary); }
/* amministratore: pulsante in alto a destra (a destra della barra di scorrimento) e una fascia libera sopra le pagine, così non copre nulla */
body[data-role='admin'] .theme-fab { top: 8px; right: 26px; bottom: auto; width: 34px; height: 34px; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }
body[data-role='admin'] .page { padding-top: 46px; }

/* ===== portale cliente e schermate di accesso: tablet e telefono (l'amministratore resta solo desktop) ===== */
@media (pointer: coarse) {
  .client-page .btn, .auth-card .btn { min-height: 44px; }
  .client-page .seg button { min-height: 42px; }
}
@media (max-width: 900px) {
  .client-page { padding: 18px 16px 48px; }
  .gallery.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gallery.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .input, textarea.input, select.input { font-size: 16px; } /* sotto i 16px iPhone ingrandisce la pagina quando si tocca un campo */
  .auth-page { padding: 16px; place-items: start center; padding-top: 7vh; }
  .auth-card { padding: 24px 20px; }
  .client-page { padding: 14px 12px 56px; }
  .client-header { flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
  .client-brand h1 { font-size: 19px; }
  .client-header-actions { width: 100%; }
  .client-header-actions .btn { flex: 1; }
  .client-content { gap: 16px; }
  .client-ced .section-head { align-items: stretch; }
  .client-ced .section-head .grow { display: none; }
  .client-ced .seg { width: 100%; }
  .client-ced .seg button { flex: 1; padding: 9px 8px; }
  .client-ped .pct-legend { grid-template-columns: 1fr 1fr; }
  .post-card { padding: 14px; }
  .post-card-head { flex-direction: column; gap: 8px; align-items: flex-start; }
  /* immagini: striscia che scorre di lato */
  .gallery, .gallery.n1, .gallery.n2, .gallery.n3 { display: flex; grid-template-columns: none; overflow-x: auto; gap: 8px; scroll-snap-type: x mandatory; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .gallery-item { flex: 0 0 80%; scroll-snap-align: center; }
  .gallery.n1 .gallery-item { flex-basis: 100%; }
  /* azioni impilate, grandi come il pollice */
  .reply-actions { flex-direction: column; align-items: stretch; }
  .reply-actions .btn { width: 100%; min-height: 46px; }
  .reply-actions .muted { text-align: center; }
  /* finestre a schermo intero */
  .overlay { padding: 0; display: flex; align-items: stretch; }
  .modal, .modal-sm, .modal-md, .modal-lg { max-width: none; width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .toasts { left: 12px; right: 12px; transform: none; align-items: stretch; bottom: 14px; }
  .theme-fab { width: 40px; height: 40px; right: 12px; bottom: 12px; opacity: .94; }
  .client-page { padding-bottom: 76px; } /* spazio in fondo: il pulsante del tema non copre le azioni */
  .lb-prev { left: 6px; } .lb-next { right: 6px; }
}
