/* =====================================================================
   TEMA SCURO BLU NOTTE: riposa gli occhi.
   Sfondo blu scuro, schede blu un po' più chiare, testo chiaro (non bianco puro),
   accenti Tiffany per pulsanti, link e voce attiva del menu.
   Si carica dopo style.css e theme.css e ne sostituisce i colori.
   ===================================================================== */
:root {
  color-scheme: dark;
  /* Blu notte */
  --bg: #0E1A2B;               /* sfondo pagina */
  --surface: #15253B;          /* schede */
  --surface-2: #1B2E48;        /* righe evidenziate, riquadri interni */
  --field: #0F1E33;            /* campi da compilare */
  --edge: #2A3F5E;             /* bordi */
  --edge-strong: #3A5478;
  --ink: #E2E9F2;              /* testo principale: chiaro ma non bianco puro */
  --muted: #9AACC4;            /* testo secondario */
  --navy: #E2E9F2;
  /* Tiffany (accenti) */
  --tiffany: #7FD3CA;
  --tiffany-soft: #4E9E97;
  --tiffany-light: rgba(127, 211, 202, .13);
  --tiffany-dark: #5FC4BA;     /* pulsanti principali (testo scuro sopra) */
  --tiffany-deep: #9BE3DB;     /* testo in evidenza */
  --primary: #5FC4BA;
  --primary-dark: #9BE3DB;
  --primary-light: rgba(127, 211, 202, .13);
  /* Stati: tinte scure con testo chiaro */
  --ok: #86DDA8;      --ok-light: rgba(60, 170, 100, .16);
  --warn: #F3C47E;    --warn-light: rgba(230, 150, 40, .15);
  --danger: #FF9F95;  --danger-light: rgba(225, 80, 70, .17);
  --accent: #E8C547;
  --radius: 14px;
  /* Menu laterale: blu ancora più scuro */
  --side-bg: #0A1422;
  --side-ink: #D3DDEA;
  --side-muted: #7E95B3;
  --side-line: rgba(211, 221, 234, .12);
  --side-hover: rgba(127, 211, 202, .1);
  --hover: #22395A;
  --link: #8ADDD4;
  --link-hover: #B6EEE8;
}
html { background: var(--bg); }
body { background: var(--bg); color: var(--ink); accent-color: var(--tiffany-dark);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif; }
::selection { background: rgba(127, 211, 202, .35); }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
h1, h2, h3, h4 { color: var(--ink); letter-spacing: -.01em; }
.muted, small.muted, .small.muted { color: var(--muted); }
code { background: var(--surface-2); color: var(--ink); }
hr { border-color: var(--edge); }

/* ---------- Menu laterale ---------- */
.sidebar { background: var(--side-bg); border-right: 1px solid var(--side-line); color: var(--side-ink); }
.side-group { color: var(--side-muted); font-weight: 700; letter-spacing: .1em; }
.side-group.has-active { color: var(--tiffany); }
.side-link { color: var(--side-ink); font-weight: 500; border-radius: 10px; }
.side-link:hover { background: var(--side-hover); color: var(--side-ink); }
.side-link.active { background: var(--tiffany); color: #08201F; font-weight: 700; box-shadow: none; }
.side-link.is-soon:hover { background: none; color: var(--side-ink); }
.side-site { color: var(--side-muted); }
.side-count { box-shadow: 0 0 0 2px var(--side-bg); }
.side-me, .side-me strong { color: var(--side-ink); }
.side-me small { color: var(--side-muted); opacity: 1; }
.side-user { border-top-color: var(--side-line); }
.side-user .btn, .push-btn { background: var(--side-hover); color: var(--side-ink); border-color: var(--side-line); font-weight: 500; }
.side-user .btn:hover, .push-btn:hover { background: var(--tiffany); color: #08201F; border-color: var(--tiffany); }

/* Logo e nome: Console / Studio Legale / Avv. Barbara Tangari */
.side-brand.brand-studio { display: flex; align-items: center; gap: .75rem; padding: .35rem .4rem 1.1rem; border-bottom: 1px solid var(--side-line); margin-bottom: .6rem; }
.brand-studio img, .guest-brand img, .portal-head img {
  flex: none; width: 72px; height: 72px; padding: 0; border-radius: 50%; background: #F2F6F9; object-fit: contain;
  box-shadow: 0 0 0 2px var(--tiffany), 0 4px 14px rgba(0, 0, 0, .35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 1.15rem; font-weight: 700; color: var(--tiffany); letter-spacing: .01em; }
.brand-text span { font-size: .8rem; letter-spacing: .04em; color: var(--side-muted); margin-top: .15rem; }
.brand-text em { font-style: normal; font-size: .88rem; font-weight: 600; color: var(--side-ink); margin-top: .1rem; white-space: nowrap; }

/* Barra in alto su cellulare */
.mobilebar { background: var(--side-bg); border-bottom: 1px solid var(--side-line); box-shadow: 0 2px 10px rgba(0, 0, 0, .3); min-height: 66px; }
.mobilebar .brand-studio { gap: .6rem; }
.mobilebar .brand-studio img { width: 52px; height: 52px; }
.mobilebar .brand-text strong { font-size: .95rem; }
.mobilebar .brand-text span { font-size: .7rem; margin-top: 0; }
.mobilebar .brand-text em { font-size: .76rem; margin-top: 0; }
.burger { background: var(--side-hover); border-color: var(--side-line); color: var(--side-ink); border-radius: 10px; }

/* ---------- Schede e riquadri ---------- */
.card, .stat, .week-day, .tile, .progress-box, .nw-tile, .nw-gal-item, .send-box, .portal-msg, table.stackable tr, .guest-box,
.list-builder, .ct-message, .vc-copy, .case-text, .month-cell, .rich-toolbar, .item-card {
  background: var(--surface); border-color: var(--edge); color: var(--ink);
}
.card { border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .18); }
.howto, .slot, .sw, .nw-image, .nw-image-status, .rich blockquote, .month-cell.is-closed, .checklist-item.is-missing, .ct-row.is-new, tr.row-new td,
.progress-box.is-complete, .item-card.is-over, .alert-warning, .mat.is-off {
  background: var(--surface-2); border-color: var(--edge); color: var(--ink);
}
.dropzone { background: var(--field); border-color: var(--edge-strong); }
.dropzone:hover, .dropzone.is-over { background: var(--tiffany-light); border-color: var(--tiffany); }
.dropzone strong { color: var(--ink); }
.tile { border-radius: 18px; }
.tile:hover { border-color: var(--tiffany-soft); box-shadow: 0 8px 22px rgba(0, 0, 0, .3); }
.tile-icon { background: var(--tiffany-light); }
.tile-num { color: var(--tiffany-deep); }
.tile-label, .dash-group h2 { color: var(--muted); }
.tile-go { color: var(--tiffany-soft); }
.tile.is-hot { background: rgba(230, 150, 40, .12); border-color: rgba(243, 196, 126, .5); }
.tile.is-hot .tile-icon { background: rgba(230, 150, 40, .2); }
.tile.is-hot .tile-num { color: var(--warn); }
.stat strong { color: var(--tiffany-deep); }

/* Tabelle */
table th { color: var(--muted); }
table td, table th { border-color: var(--edge); }
table.clickable tbody tr:hover { background: var(--hover); }

/* Campi */
input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea, .rich, .sw-track {
  background: var(--field); border-color: var(--edge-strong); color: var(--ink); border-radius: 10px;
}
input[type=file]::file-selector-button { background: var(--surface-2); color: var(--ink); border: 1px solid var(--edge-strong); border-radius: 8px; padding: .3rem .7rem; }
input[type=checkbox], input[type=radio] { background: none; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus, .rich:focus { outline: 3px solid rgba(127, 211, 202, .35); outline-offset: 0; border-color: var(--tiffany); }
select option, select optgroup { background: var(--field); color: var(--ink); }
fieldset { border-color: var(--edge); }
label, legend { color: var(--ink); }

/* Pulsanti */
.btn { background: var(--surface-2); border-color: var(--edge-strong); color: var(--ink); border-radius: 10px; }
.btn:hover { background: var(--hover); border-color: var(--tiffany-soft); color: var(--ink); }
.btn-primary { background: var(--tiffany-dark); border-color: var(--tiffany-dark); color: #06201E; font-weight: 600; box-shadow: 0 2px 10px rgba(95, 196, 186, .2); }
.btn-primary:hover { background: var(--tiffany); border-color: var(--tiffany); color: #06201E; }
.btn-danger { background: rgba(225, 80, 70, .15); border-color: rgba(255, 159, 149, .45); color: var(--danger); }
.btn-danger:hover { background: rgba(225, 80, 70, .3); color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
/* Bottone per tornare alla schermata precedente: ben visibile su ogni pagina */
.btn-back { background: var(--hover); border: 1.5px solid var(--tiffany-dark); color: var(--ink); font-weight: 600; margin-bottom: .6rem; }
.btn-back:hover { background: var(--tiffany-dark); border-color: var(--tiffany-dark); color: #06201E; }
.btn-preview { background: var(--hover); border-color: var(--tiffany-soft); color: var(--ink); font-weight: 700; letter-spacing: .03em; }
.btn-preview:hover { background: var(--tiffany); color: #06201E; border-color: var(--tiffany); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--edge); }
.pager a, label.pill, .nw-chip, .rich-toolbar button, .sw:hover, .dc-mode-opt, .cl-role-opt { background: var(--surface-2); border-color: var(--edge-strong); color: var(--ink); }
label.pill:has(input:checked), .dc-mode-opt:has(input:checked), .cl-role-opt:has(input:checked), .nw-mode.on { background: var(--tiffany-light); border-color: var(--tiffany); color: var(--ink); }
.nw-chip.on, .pager a.active { background: var(--tiffany-dark); border-color: var(--tiffany-dark); color: #06201E; }
.tabs a { color: var(--muted); }
.tabs a.active { color: var(--tiffany-deep); border-bottom-color: var(--tiffany); }

/* Etichette di stato e avvisi: tinte scure leggibili */
.badge { background: var(--surface-2); border-color: var(--edge-strong); color: var(--muted); }
.badge-admin { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.badge-avvocato { background: var(--tiffany-light); color: var(--tiffany-deep); border-color: var(--tiffany-soft); }
.badge-segreteria { background: rgba(232, 197, 71, .14); color: #F0D77E; border-color: rgba(232, 197, 71, .45); }
.badge-ok { border-color: rgba(134, 221, 168, .45); }
.badge-warn { border-color: rgba(243, 196, 126, .45); }
.badge-off { border-color: rgba(255, 159, 149, .45); }
.alert-success { border-color: rgba(134, 221, 168, .45); }
.alert-error { border-color: rgba(255, 159, 149, .45); }
.alert-info { background: var(--tiffany-light); border-color: var(--tiffany-soft); color: var(--tiffany-deep); }
.alert-warning { border-color: rgba(243, 196, 126, .45); color: var(--warn); }

/* ---------- Accesso e pagina cliente ---------- */
body.guest { background: radial-gradient(1000px 560px at 50% -10%, var(--surface-2) 0%, var(--bg) 60%); }
.guest-box { border: 1px solid var(--edge); border-radius: 18px; padding: 1.5rem; box-shadow: 0 14px 40px rgba(0, 0, 0, .35); }
.guest-brand img { width: 96px; height: 96px; }
.guest-brand .brand-text { align-items: center; margin-top: .75rem; }
.guest-brand .brand-text strong { font-size: 1.5rem; }
.guest-brand .brand-text span { font-size: .85rem; }
.guest-brand .brand-text em { font-size: 1rem; }
body.portal { background: var(--bg); }
.portal-head { background: var(--side-bg); border-bottom: 1px solid var(--side-line); }
.portal-head strong { color: var(--side-ink); }
.portal-head span { color: var(--side-muted); }
.portal-head img { width: 44px; height: 44px; }

/* ---------- Composizione documenti: allineamento e ANTEPRIMA dal vivo ---------- */
.dc-align { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: -.35rem 0 1rem; }
.dc-align > span { margin-right: .25rem; }
.dc-align-opt { display: inline-flex; align-items: center; gap: .3rem; margin: 0; padding: .28rem .6rem; border: 1px solid var(--edge-strong); border-radius: 999px;
  background: var(--surface-2); color: var(--ink); font-size: .82rem; font-weight: 500; cursor: pointer; }
.dc-align-opt input { position: absolute; opacity: 0; pointer-events: none; }
.dc-align-opt:has(input:checked) { background: var(--tiffany-dark); border-color: var(--tiffany-dark); color: #06201E; font-weight: 700; }
.dc-align-opt:has(input:focus-visible) { outline: 3px solid rgba(127, 211, 202, .6); }
textarea.al-left { text-align: left; }
textarea.al-center { text-align: center; }
textarea.al-right { text-align: right; }
textarea.al-justify { text-align: justify; }
.dc-logo-prev { background: #F2F6F9; border-color: var(--edge); }
.dc-sum .dc-total { color: var(--ink); border-top-color: var(--edge); }
.dc-sum { border-top-color: var(--edge); }

/* Scheda utente: permessi a blocchi come nel menu */
.perm-sections { display: grid; gap: .4rem 1.5rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.perm-sec { padding: .2rem 0 .5rem; }
.perm-sec-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--tiffany); margin: .6rem 0 .2rem; }

/* Contatti trovati con la ricerca in «Preventivi e parcelle» */
.dc-found { display: grid; gap: .5rem; }
.dc-found-row { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; padding: .6rem .8rem;
  border: 1px solid var(--edge); border-radius: 12px; background: var(--surface-2); }
.dc-found-name { display: flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: center; min-width: 0; }
.dc-found-name small { flex-basis: 100%; }
select[data-dc-client][size] { padding: .3rem; }

/* Riquadro anteprima: a destra dello schermo, il modulo resta usabile a sinistra */
.dc-live { position: fixed; z-index: 40; top: 4.1rem; right: 0;   /* sotto i pulsanti in alto (Aggiorna, utente) */ bottom: 0; width: min(48vw, 760px); display: flex; flex-direction: column;
  background: #1A2A42; border-left: 1px solid var(--edge); box-shadow: -8px 0 28px rgba(0, 0, 0, .4); }
.dc-live[hidden] { display: none; }
.dc-live-bar { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; background: var(--side-bg); color: var(--side-ink); border-bottom: 1px solid var(--side-line); }
.dc-live-bar strong { font-size: 1rem; }
.dc-live-hint { flex: 1; font-size: .8rem; color: var(--muted); }
.dc-live iframe { flex: 1; width: 100%; border: 0; background: #1A2A42; }
body.dc-live-on .content { margin-right: min(48vw, 760px); }
/* Con l'anteprima aperta il modulo va su una colonna sola (niente sovrapposizioni) */
body.dc-live-on .ct-grid { grid-template-columns: minmax(0, 1fr); }
body.dc-live-on .dc-totals { position: static; }
body.dc-live-on .page-head { flex-wrap: wrap; }
@media (max-width: 900px) {
  /* Su telefono e tablet l'anteprima occupa tutto lo schermo: sopra a tutto, con barra compatta e pulsanti ben visibili */
  .dc-live { width: 100%; z-index: 80; top: 0; }
  body.dc-live-on .content { margin-right: 0; }
  body.dc-live-on .topbar-r, body.dc-live-on .mobilebar { display: none; }
  .dc-live-bar { flex-wrap: nowrap; gap: .45rem; padding: calc(.55rem + env(safe-area-inset-top, 0px)) .7rem .55rem; }
  .dc-live-hint { display: none; }
  .dc-live-bar strong { flex: 1; white-space: nowrap; }
  .dc-live-bar .btn { padding: .5rem .8rem; white-space: nowrap; font-size: .95rem; }
}
@media (max-width: 600px) {
  /* Telefono: solo icone (tranne «Invia»), così i pulsanti non vengono tagliati */
  .dc-live-bar .lbl { display: none; }
  .dc-live-bar { gap: .4rem; }
  .dc-live-bar .btn { padding: .5rem .7rem; }
}

/* Mandati: campo di ricerca largo e anteprima obbligatoria prima dell'invio */
.md-search { flex-grow: 1; min-width: min(24rem, 100%); max-width: 40rem; }
.md-send-frame { display: block; width: 100%; height: 78vh; margin: .75rem 0; border: 1px solid var(--edge-strong); border-radius: .6rem; background: #1A2A42; }

/* Posta E-mail e PEC: letti e non letti ben diversi a colpo d'occhio (richiesta 18/11/2026)
   Non letti (o PEC nuove): fondo verde acqua acceso, bordo spesso a sinistra, testo in grassetto, pallino «●».
   Letti: fondo neutro e testo attenuato. */
.mail-list .mail-row.is-new { background: rgba(129, 216, 208, .26) !important; border: 1px solid rgba(129, 216, 208, .75) !important;
  border-left: 7px solid var(--primary, #81d8d0) !important; }
.mail-list .mail-row.is-new strong { font-weight: 800; }
.mail-list .mail-row.is-read { background: var(--surface) !important; border-left: 7px solid transparent !important; }
.mail-list .mail-row.is-read .ct-who, .mail-list .mail-row.is-read .ct-msg, .mail-list .mail-row.is-read .ct-side { opacity: .62; }
.mail-list .mail-row.is-read strong { font-weight: 500; }
.mail-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; margin: .2rem 0 .6rem; }
.mail-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.mail-legend i { display: inline-block; width: 1.4rem; height: .9rem; border-radius: 4px; }
.mail-legend .lg-new { background: rgba(129, 216, 208, .45); border-left: 4px solid var(--primary, #81d8d0); }
.mail-legend .lg-read { background: var(--surface); border: 1px solid var(--edge); opacity: .7; }
