/*!
 * LB Medical — foglio di stile principale
 * Identità: blu navy istituzionale, oro, bianco e grigi chiari.
 * Struttura del pannello ispirata all'organizzazione del pannello staff LaZoneRP
 * (hero con contatori, toolbar di ricerca e filtri, card di sezione, schede a tab, toast),
 * ridisegnata da zero per LB Medical.
 */

:root {
  --navy-950: #061327;
  --navy-900: #0b1f3a;
  --navy-800: #112b4f;
  --navy-700: #183a66;
  --navy-600: #24508a;
  --navy-100: #e6ecf5;
  --navy-50:  #f2f5fa;
  --gold-700: #8f6d22;
  --gold-600: #a8832f;
  --gold-500: #c29a3f;
  --gold-400: #d4b060;
  --gold-200: #ecdcae;
  --gold-100: #f7efd8;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #dde3ec;
  --border-strong: #c5cedb;
  --text: #17202e;
  --text-2: #3b4658;
  --muted: #5f6b7e;
  --green: #1d7a4e;  --green-bg: #e3f4ea;
  --red: #b42f2f;    --red-bg: #fbe7e7;
  --amber: #9a6200;  --amber-bg: #fdf1dc;
  --orange: #b3560f; --orange-bg: #fde9da;
  --indigo: #3b3fa8; --indigo-bg: #e8e9fb;
  --blue: #1f5aa6;   --blue-bg: #e2edfb;
  --slate: #4a5566;  --slate-bg: #eceff4;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(11, 31, 58, .06);
  --shadow: 0 2px 10px rgba(11, 31, 58, .07), 0 1px 2px rgba(11, 31, 58, .05);
  --shadow-lg: 0 18px 50px rgba(6, 19, 39, .22);
  --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", "Liberation Serif", serif;
  --sidebar-w: 264px;
  --focus: 0 0 0 3px rgba(194, 154, 63, .45);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-sans); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); }
img { max-width: 100%; height: auto; }
a { color: var(--navy-600); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--navy-800); }
h1, h2, h3, h4 { font-family: var(--font-serif); color: var(--navy-900); line-height: 1.2; margin: 0 0 .5rem; font-weight: 700; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.08rem; }
p { margin: 0 0 .75rem; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
[hidden] { display: none !important; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--gold-500); color: var(--navy-950); padding: .5rem 1rem; z-index: 1000; }
.skip-link:focus { left: 1rem; top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Icone */
.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.icon-xs { width: 14px; height: 14px; vertical-align: -2px; }
.icon-lg { width: 26px; height: 26px; }

/* ===================================================================== */
/* SHELL: sidebar + contenuto                                            */
/* ===================================================================== */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
  color: #d6deea; display: flex; flex-direction: column; border-right: 3px solid var(--gold-500);
}
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand img { border-radius: 50%; box-shadow: 0 0 0 2px rgba(212,176,96,.35); }
.sidebar-brand strong { display: block; font-family: var(--font-serif); font-size: 1.12rem; color: #fff; letter-spacing: .02em; }
.sidebar-brand span { display: block; font-size: .72rem; color: var(--gold-400); text-transform: uppercase; letter-spacing: .12em; }
.sidebar-identity { display: flex; align-items: center; gap: .7rem; margin: .9rem .9rem .2rem; padding: .7rem; background: rgba(255,255,255,.05); border: 1px solid rgba(212,176,96,.25); border-radius: var(--radius); }
.sidebar-identity strong { display: block; color: #fff; font-size: .9rem; line-height: 1.25; }
.sidebar-identity span { display: block; color: var(--gold-400); font-size: .76rem; }
.avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: var(--navy-950); background: linear-gradient(135deg, var(--gold-400), var(--gold-600)); }
.sidebar-nav { padding: .7rem .6rem; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a, .sidebar-logout button {
  display: flex; align-items: center; gap: .7rem; padding: .62rem .8rem; border-radius: 8px; color: #cfd8e6;
  text-decoration: none; font-size: .92rem; border: 0; background: none; width: 100%; font: inherit; cursor: pointer; text-align: left;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover, .sidebar-logout button:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav a.active { background: rgba(194,154,63,.16); color: #fff; border-left-color: var(--gold-400); }
.sidebar-nav a.active .icon { color: var(--gold-400); }
.sidebar-label { margin: 1rem .8rem .35rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .14em; color: rgba(212,176,96,.8); }
.sidebar-logout { margin: 0; }
.sidebar-foot { padding: .8rem 1.1rem 1rem; font-size: .7rem; color: rgba(214,222,234,.55); border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(6,19,39,.5); z-index: 40; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem; padding: .65rem 1.6rem;
  background: rgba(255,255,255,.96); border-bottom: 1px solid var(--border); backdrop-filter: blur(6px);
}
.topbar-menu { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: .4rem; color: var(--navy-900); cursor: pointer; }
.topbar-area { flex: 1; }
.topbar-user { display: flex; align-items: center; gap: .6rem; }
.topbar-name { font-weight: 600; color: var(--navy-900); font-size: .92rem; }
.area-pill { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .7rem; border-radius: 999px; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.area-pill-admin { background: var(--navy-900); color: var(--gold-400); border: 1px solid var(--gold-600); }
.area-pill-inst { background: var(--gold-100); color: var(--gold-700); border: 1px solid var(--gold-200); }
.content { padding: 1.4rem 1.6rem 2.5rem; width: 100%; max-width: 1360px; margin: 0 auto; flex: 1; }
.app-footer { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.6rem; font-size: .75rem; color: var(--muted); border-top: 1px solid var(--border); background: var(--surface); }

/* ===================================================================== */
/* INTESTAZIONI DI PAGINA (hero con contatori, come nel pannello LaZoneRP) */
/* ===================================================================== */
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; font-size: .82rem; color: var(--muted); margin-bottom: .9rem; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--navy-700); text-decoration: underline; }
.breadcrumbs span[aria-current] { color: var(--navy-900); font-weight: 600; }

.page-hero {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 1.2rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.3rem 1.5rem;
  margin-bottom: 1.2rem; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.page-hero::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: linear-gradient(180deg, var(--gold-400), var(--gold-600)); }
.page-hero h1 { margin-bottom: .2rem; }
.page-hero .eyebrow { margin-bottom: .25rem; }
.page-hero p.lead { color: var(--muted); margin: 0; max-width: 70ch; }
.page-hero-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; color: var(--gold-600); font-weight: 700; }
.hero-stats { display: flex; gap: .6rem; flex-wrap: wrap; }
.stat-badge { min-width: 92px; padding: .5rem .8rem; text-align: center; border-radius: var(--radius); background: var(--navy-50); border: 1px solid var(--navy-100); }
.stat-badge .num { font-family: var(--font-serif); font-size: 1.35rem; font-weight: 700; color: var(--navy-900); line-height: 1.1; }
.stat-badge .lbl { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* Welcome (dashboard) */
.welcome { background: linear-gradient(120deg, var(--navy-900), var(--navy-700)); color: #fff; border-radius: var(--radius-lg); padding: 1.5rem 1.6rem; margin-bottom: 1.2rem; display: flex; align-items: center; gap: 1.2rem; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.welcome::after { content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px; border-radius: 50%; border: 2px solid rgba(212,176,96,.25); }
.welcome img { width: 72px; height: 72px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(212,176,96,.45); flex: none; }
.welcome h1 { color: #fff; margin: .15rem 0 .25rem; font-size: 1.55rem; }
.welcome p { margin: 0; color: #cfd8e6; }
.welcome .welcome-tag { display: inline-block; font-size: .7rem; letter-spacing: .2em; text-transform: uppercase; color: var(--gold-400); border: 1px solid rgba(212,176,96,.45); padding: .15rem .6rem; border-radius: 999px; }

/* Statistiche */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.1rem; display: flex; gap: .9rem; align-items: center; box-shadow: var(--shadow-sm); text-decoration: none; color: inherit; }
a.stat-card:hover { border-color: var(--gold-400); box-shadow: var(--shadow); }
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--navy-50); color: var(--navy-700); flex: none; }
.stat-card .stat-icon.gold { background: var(--gold-100); color: var(--gold-700); }
.stat-card .stat-value { font-family: var(--font-serif); font-size: 1.6rem; font-weight: 700; color: var(--navy-900); line-height: 1; }
.stat-card .stat-label { font-size: .8rem; color: var(--muted); }

/* Card di sezione (griglia della dashboard, eredità LaZoneRP) */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.section-card { display: flex; flex-direction: column; gap: .4rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.1rem 1.15rem; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; position: relative; }
.section-card:hover { border-color: var(--gold-400); box-shadow: var(--shadow); transform: translateY(-2px); color: inherit; }
.section-card .sc-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--navy-900); color: var(--gold-400); margin-bottom: .2rem; }
.section-card strong { font-family: var(--font-serif); color: var(--navy-900); font-size: 1.02rem; }
.section-card span.sc-desc { font-size: .84rem; color: var(--muted); }
.section-card.primary { border-color: var(--gold-200); background: linear-gradient(180deg, #fff, var(--gold-100)); }

/* ===================================================================== */
/* PANNELLI                                                              */
/* ===================================================================== */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 1.2rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .9rem 1.15rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.panel-head h2 .icon, .panel-head h3 .icon { color: var(--gold-600); }
.panel-body { padding: 1.1rem 1.15rem; }
.panel-body.flush { padding: 0; }
.panel-foot { padding: .8rem 1.15rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.2rem; }
.grid-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }

/* Definizioni (schede informative) */
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .9rem 1.2rem; margin: 0; }
.dl-grid div { min-width: 0; }
.dl-grid dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: .15rem; }
.dl-grid dd { margin: 0; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.prose { white-space: normal; overflow-wrap: anywhere; color: var(--text-2); }

/* ===================================================================== */
/* TOOLBAR, FILTRI, TABELLE                                              */
/* ===================================================================== */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.toolbar form { display: contents; }
.search-wrap { position: relative; flex: 1 1 260px; min-width: 200px; }
.search-wrap .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-wrap input, .search-wrap input[type=search] { padding-left: 2.3rem; }
.filter-pills { display: flex; gap: .35rem; flex-wrap: wrap; }
.filter-pill { display: inline-flex; align-items: center; gap: .3rem; padding: .42rem .85rem; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: .84rem; text-decoration: none; white-space: nowrap; }
.filter-pill:hover { border-color: var(--navy-600); color: var(--navy-800); }
.filter-pill.active { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.filter-pill .count { font-size: .72rem; background: rgba(0,0,0,.08); padding: 0 .4rem; border-radius: 999px; }
.filter-pill.active .count { background: rgba(255,255,255,.2); }
.toolbar-spacer { flex: 1; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .7rem; align-items: end; padding: 1rem 1.15rem; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.filters .field { margin: 0; }
.filters-actions { display: flex; gap: .4rem; }

.table-wrap { width: 100%; overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; padding: .7rem .9rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #fafbfd; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .t-main { font-weight: 600; color: var(--navy-900); text-decoration: none; }
.table a.t-main:hover { text-decoration: underline; }
.table .t-sub { display: block; font-size: .8rem; color: var(--muted); }
.table .t-actions { text-align: right; white-space: nowrap; }
.table .t-mono, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .84rem; }
.sort-link { color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--navy-800); }
.sort-ind { color: var(--gold-600); }

/* Badge */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .16rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.badge-green { background: var(--green-bg); color: var(--green); border-color: #bfe3cf; }
.badge-red { background: var(--red-bg); color: var(--red); border-color: #f1c4c4; }
.badge-amber { background: var(--amber-bg); color: var(--amber); border-color: #f1d9a8; }
.badge-orange { background: var(--orange-bg); color: var(--orange); border-color: #f5ccad; }
.badge-indigo { background: var(--indigo-bg); color: var(--indigo); border-color: #cacdf3; }
.badge-blue { background: var(--blue-bg); color: var(--blue); border-color: #c3d8f3; }
.badge-slate, .badge-gray { background: var(--slate-bg); color: var(--slate); border-color: #d7dce4; }
.badge-gold { background: var(--gold-100); color: var(--gold-700); border-color: var(--gold-200); }
.badge-navy { background: var(--navy-900); color: #fff; }
.badge-outline { background: transparent; border-color: var(--border-strong); color: var(--text-2); }

/* ===================================================================== */
/* BOTTONI                                                               */
/* ===================================================================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .56rem 1rem; border-radius: 8px; border: 1px solid transparent; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--navy-900); color: #fff; }
.btn-primary:hover { background: var(--navy-700); color: #fff; }
.btn-gold { background: linear-gradient(180deg, var(--gold-400), var(--gold-600)); color: var(--navy-950); border-color: var(--gold-600); }
.btn-gold:hover { background: linear-gradient(180deg, var(--gold-500), var(--gold-700)); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--navy-900); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--navy-600); color: var(--navy-700); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #962424; color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #155f3c; color: #fff; }
.btn-warning { background: var(--amber); color: #fff; }
.btn-sm { padding: .36rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-ghost.is-loading::after { border-color: rgba(11,31,58,.25); border-top-color: var(--navy-900); }
.btn-group { display: flex; gap: .4rem; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--navy-600); font: inherit; cursor: pointer; text-decoration: underline; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================================================================== */
/* MODULI                                                                */
/* ===================================================================== */
.form { display: flex; flex-direction: column; gap: .95rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .95rem 1.1rem; }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label, .field .label { font-size: .82rem; font-weight: 700; color: var(--text-2); }
.field .req { color: var(--red); }
.help { font-size: .78rem; color: var(--muted); }
input[type=text], input[type=password], input[type=email], input[type=search], input[type=date], input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: .58rem .75rem; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; color: var(--text);
  font: inherit; font-size: .93rem; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
textarea.tall { min-height: 260px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold-500); box-shadow: var(--focus); }
input[readonly] { background: var(--surface-2); }
.input-code { font-size: 1.5rem; letter-spacing: .4em; text-align: center; font-family: ui-monospace, Consolas, monospace; }
.check { display: flex; gap: .55rem; align-items: flex-start; font-size: .9rem; }
.check input { margin-top: .2rem; width: 16px; height: 16px; accent-color: var(--navy-800); flex: none; }
.check small { display: block; color: var(--muted); }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; padding-top: .3rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem 1rem; margin: 0; }
legend { font-weight: 700; font-size: .85rem; color: var(--navy-800); padding: 0 .4rem; }
.photo-preview { display: flex; align-items: center; gap: .9rem; }
.photo-preview img { width: 110px; height: 130px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.photo-frame { width: 110px; height: 130px; border-radius: 8px; border: 1px dashed var(--border-strong); display: grid; place-items: center; color: var(--muted); background: var(--surface-2); }

/* Avvisi */
.alert { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius); border: 1px solid; margin-bottom: 1rem; font-size: .9rem; }
.alert ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.alert .icon { margin-top: 2px; }
.alert-error { background: var(--red-bg); border-color: #f1c4c4; color: #7e1f1f; }
.alert-success { background: var(--green-bg); border-color: #bfe3cf; color: #13553a; }
.alert-warning { background: var(--amber-bg); border-color: #f1d9a8; color: #6d4700; }
.alert-info { background: var(--navy-50); border-color: var(--navy-100); color: var(--navy-800); }
.alert-gold { background: var(--gold-100); border-color: var(--gold-200); color: var(--gold-700); }

/* Banner dello stato legale del documento */
.doc-banner { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; border-radius: var(--radius); font-weight: 700; letter-spacing: .02em; margin-bottom: 1rem; border: 2px dashed; }
.doc-banner-draft { background: repeating-linear-gradient(135deg, #fff7e6, #fff7e6 12px, #fdf0d4 12px, #fdf0d4 24px); border-color: var(--amber); color: #6d4700; }
.doc-banner-pending { background: var(--indigo-bg); border-color: var(--indigo); color: var(--indigo); border-style: solid; }
.doc-banner-rejected { background: var(--red-bg); border-color: var(--red); color: var(--red); border-style: solid; }
.doc-banner-final { background: var(--green-bg); border-color: var(--green); color: var(--green); border-style: solid; }

/* ===================================================================== */
/* TAB (schede del procedimento, come la scheda cittadino LaZoneRP)      */
/* ===================================================================== */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; overflow-x: auto; scrollbar-width: thin; }
.tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: .7rem .95rem; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem; border-bottom: 3px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover { color: var(--navy-800); }
.tabs a.active { color: var(--navy-900); border-bottom-color: var(--gold-500); }
.tabs a .count { font-size: .72rem; background: var(--navy-50); color: var(--navy-700); padding: 0 .45rem; border-radius: 999px; }

/* Cronologia */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 1rem 1.6rem; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: -6px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--gold-500); }
.timeline .tl-meta { font-size: .78rem; color: var(--muted); }
.timeline .tl-text { font-size: .9rem; }

/* Elenchi compatti */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: .8rem; align-items: center; justify-content: space-between; padding: .7rem 1.15rem; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .li-main { min-width: 0; }
.list .li-main strong { display: block; color: var(--navy-900); overflow-wrap: anywhere; }
.list .li-main span { font-size: .8rem; color: var(--muted); }

/* Parti del procedimento */
.party-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .9rem; }
.party-card { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; display: flex; gap: .8rem; background: var(--surface); }
.party-card img, .party-card .party-ph { width: 64px; height: 76px; object-fit: cover; border-radius: 6px; flex: none; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--muted); }
.party-card strong { color: var(--navy-900); }
.party-card .meta { font-size: .8rem; color: var(--muted); }

/* Matrice permessi */
.matrix th.rot { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-size: .72rem; padding: .7rem .35rem; height: 190px; vertical-align: bottom; text-align: left; }
.matrix td.cell { text-align: center; padding: .45rem; }
.matrix td.cell input { width: 17px; height: 17px; accent-color: var(--navy-800); }
.matrix .group-row td { background: var(--navy-50); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--navy-700); }
.matrix .perm-label strong { display: block; font-size: .86rem; }
.matrix .perm-label small { color: var(--muted); }
.matrix thead th { position: sticky; top: 0; z-index: 1; }

/* Stato vuoto */
.empty-state { text-align: center; padding: 2.4rem 1.2rem; color: var(--muted); }
.empty-state .empty-icon { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--navy-50); color: var(--navy-600); margin-bottom: .7rem; }
.empty-state .empty-icon .icon { width: 26px; height: 26px; }
.empty-state h3 { margin-bottom: .3rem; }
.empty-state p { max-width: 52ch; margin: 0 auto 1rem; }

/* Paginazione */
.pagination { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .8rem 1.15rem; border-top: 1px solid var(--border); font-size: .84rem; color: var(--muted); }
.pagination-links { display: flex; gap: .4rem; }

/* Toast */
.toasts { position: fixed; right: 1.2rem; bottom: 1.2rem; display: flex; flex-direction: column; gap: .5rem; z-index: 200; max-width: min(420px, calc(100vw - 2rem)); }
.toast { display: flex; align-items: flex-start; gap: .6rem; padding: .8rem .9rem; border-radius: var(--radius); background: var(--navy-900); color: #fff; box-shadow: var(--shadow-lg); font-size: .9rem; border-left: 4px solid var(--gold-400); animation: toast-in .25s ease-out; }
.toast-success { border-left-color: #4fc58b; }
.toast-error { border-left-color: #ff7b7b; }
.toast-warning { border-left-color: #f5b74a; }
.toast span { flex: 1; }
.toast-close { background: none; border: 0; color: rgba(255,255,255,.7); cursor: pointer; padding: 0; }
.toast.is-hiding { opacity: 0; transform: translateY(8px); transition: all .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Modale di conferma */
.modal-overlay { position: fixed; inset: 0; background: rgba(6,19,39,.55); display: grid; place-items: center; z-index: 300; padding: 1rem; }
.modal { background: var(--surface); border-radius: var(--radius-lg); max-width: 460px; width: 100%; padding: 1.3rem 1.4rem; box-shadow: var(--shadow-lg); border-top: 4px solid var(--red); }
.modal-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-icon { color: var(--red); }
.modal-text { color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* Spinner / caricamento */
.loader { display: flex; align-items: center; gap: .6rem; color: var(--muted); padding: 1.5rem; justify-content: center; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--navy-100); border-top-color: var(--navy-700); border-radius: 50%; animation: spin .8s linear infinite; }

/* Codice/segreti */
.secret-box { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; background: var(--navy-900); color: var(--gold-200); border-radius: var(--radius); font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; letter-spacing: .05em; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: 220px 1fr; gap: .45rem 1rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .35rem; }
.status-dot.ok { background: var(--green); } .status-dot.ko { background: var(--red); } .status-dot.warn { background: var(--amber); }

/* Anteprima documento */
.doc-sheet { background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); padding: 1.4rem 1.6rem; max-width: 820px; }
.doc-sheet .doc-letterhead { width: 100%; display: block; margin-bottom: .8rem; }
.doc-sheet h2 { text-align: center; text-transform: uppercase; letter-spacing: .06em; font-size: 1.12rem; }
.doc-sheet .doc-meta { width: 100%; border-collapse: collapse; font-size: .86rem; margin: .8rem 0 1rem; }
.doc-sheet .doc-meta td { border: 1px solid var(--border); padding: .35rem .55rem; }
.doc-sheet .doc-meta td:first-child { width: 32%; background: var(--surface-2); font-weight: 700; color: var(--text-2); }
.doc-sheet .doc-body { font-family: var(--font-serif); font-size: .98rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.doc-sheet .doc-field { margin: .7rem 0; }
.doc-sheet .doc-field h4 { font-family: var(--font-sans); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .2rem; }
.doc-sheet .doc-field div { white-space: pre-wrap; font-family: var(--font-serif); overflow-wrap: anywhere; }
.doc-photo { float: right; width: 120px; margin: 0 0 .6rem 1rem; border: 1px solid var(--border); border-radius: 4px; }
.sig-box { border: 1px solid var(--border); border-left: 4px solid var(--green); border-radius: 6px; padding: .7rem .9rem; background: #f9fcfa; margin-top: .6rem; font-size: .88rem; }
.sig-box.decision-rejected { border-left-color: var(--red); background: #fdf8f8; }
.sig-box.decision-needs_info { border-left-color: var(--amber); background: #fffbf3; }
.sig-box .sig-hash { font-family: ui-monospace, Consolas, monospace; font-size: .74rem; color: var(--muted); overflow-wrap: anywhere; }
.sig-pending { border: 1px dashed var(--border-strong); border-radius: 6px; padding: .7rem .9rem; color: var(--muted); font-size: .88rem; margin-top: .6rem; }

/* ===================================================================== */
/* PAGINE SENZA SIDEBAR: home, login, errori                             */
/* ===================================================================== */
body.bare { min-height: 100vh; }
.home { min-height: 100vh; display: flex; flex-direction: column; background: linear-gradient(180deg, #fff 0%, var(--bg) 55%); }
.home-hero { text-align: center; padding: 1.2rem 1rem 0; }
.home-logo { width: 200px; height: auto; display: block; margin: 0 auto .4rem; filter: drop-shadow(0 6px 16px rgba(6,19,39,.25)); }
.home-title { max-width: 760px; margin: 0 auto; padding: .4rem 1rem 0; }
.home-title h1 { font-size: 2rem; letter-spacing: .03em; margin: .2rem 0 .6rem; }
.home-intro { color: var(--muted); }
.home-access { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; max-width: 820px; width: 100%; margin: 1.4rem auto 2rem; padding: 0 1rem; }
.access-card { display: flex; align-items: center; gap: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.2rem; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.access-card:hover { transform: translateY(-2px); border-color: var(--gold-400); color: inherit; }
.access-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--gold-100); color: var(--gold-700); flex: none; }
.access-icon .icon { width: 26px; height: 26px; }
.access-card-admin .access-icon { background: var(--navy-900); color: var(--gold-400); }
.access-body { flex: 1; }
.access-body strong { display: block; font-family: var(--font-serif); font-size: 1.12rem; color: var(--navy-900); }
.access-body span { font-size: .86rem; color: var(--muted); }
.access-arrow { color: var(--gold-600); }
.home-foot { margin-top: auto; display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; padding: 1rem 1.5rem; font-size: .76rem; color: var(--muted); border-top: 1px solid var(--border); background: var(--surface); }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth-inst { background: linear-gradient(180deg, #fff 0%, var(--navy-50) 100%); }
.auth-admin { background: radial-gradient(ellipse at top, var(--navy-700) 0%, var(--navy-950) 70%); }
.auth-card { width: 100%; max-width: 480px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--border); }
.auth-card-admin { border: 1px solid var(--gold-600); border-top: 4px solid var(--gold-500); }
.auth-letterhead { display: block; width: 100%; border-bottom: 1px solid var(--border); }
.auth-admin-head { display: flex; align-items: center; gap: 1rem; padding: 1.3rem 1.5rem; background: var(--navy-900); color: #fff; }
.auth-admin-head img { width: 72px; height: 72px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(212,176,96,.4); }
.auth-admin-head h1 { color: #fff; font-size: 1.25rem; margin: .45rem 0 0; }
.auth-body { padding: 1.4rem 1.5rem 1.5rem; }
.auth-body h1 { margin-top: .6rem; }
.auth-sub { color: var(--muted); font-size: .9rem; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; font-size: .84rem; }
.auth-links a { color: var(--muted); }
.error-body { text-align: center; }
.error-code { font-family: var(--font-serif); font-size: 3rem; font-weight: 700; color: var(--gold-600); margin: .3rem 0 0; line-height: 1; }
.error-actions { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; }

/* Utilità */
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mt-1 { margin-top: .6rem; } .mt-2 { margin-top: 1.2rem; } .mb-1 { margin-bottom: .6rem; }
.flex { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: .6rem; }
.nowrap { white-space: nowrap; }
.w-auto { width: auto; }
.divider { height: 1px; background: var(--border); margin: 1rem 0; border: 0; }

/* ===================================================================== */
/* APP PER TELEFONO (pagina di installazione)                            */
/* ===================================================================== */
.app-hero-icon { width: 96px; height: 96px; border-radius: 22px; box-shadow: var(--shadow-lg); }
.app-steps { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .5rem; }

/* ===================================================================== */
/* MESSAGGI DEL PROCEDIMENTO E NUOVE PROVE IN GIUDIZIO                   */
/* ===================================================================== */
.nav-count { margin-left: auto; min-width: 1.4rem; padding: .05rem .4rem; border-radius: 999px; background: var(--gold-500); color: var(--navy-950); font-size: .72rem; font-weight: 700; text-align: center; }
.msg-layout { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.msg-peers .list li { padding: 0; }
.msg-peers .list li a { display: flex; gap: .6rem; align-items: center; justify-content: space-between; width: 100%; padding: .7rem 1.15rem; color: inherit; text-decoration: none; }
.msg-peers .list li a:hover { background: var(--surface-2); }
.msg-peers .list li.active a { background: var(--gold-100); box-shadow: inset 3px 0 0 var(--gold-500); }
.msg-list { display: flex; flex-direction: column; gap: .7rem; max-height: 60vh; overflow-y: auto; background: var(--surface-2); }
.msg { max-width: 80%; align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); border-top-left-radius: 4px; padding: .6rem .8rem; box-shadow: var(--shadow-sm); }
.msg header { font-size: .8rem; margin-bottom: .25rem; }
.msg-mine { align-self: flex-end; background: var(--navy-50); border-color: var(--navy-100); border-top-left-radius: var(--radius-lg); border-top-right-radius: 4px; }
.msg-full { max-width: 100%; align-self: stretch; }
.msg-court { max-width: 100%; align-self: stretch; background: var(--gold-100); border-color: var(--gold-200); }
.msg-body { overflow-wrap: anywhere; font-size: .92rem; }
.msg .btn { margin-top: .4rem; }
.msg-photo img { display: block; max-width: 260px; max-height: 220px; width: auto; height: auto; margin-top: .4rem; border-radius: var(--radius); border: 1px solid var(--border); }
.msg-compose { display: flex; flex-direction: column; gap: .6rem; }
.msg-compose textarea { width: 100%; resize: vertical; }
.ev-list li { align-items: flex-start; }
.ev-note { margin-top: .5rem; padding: .5rem .7rem; border-radius: var(--radius); background: var(--navy-50); border: 1px solid var(--navy-100); font-size: .85rem; }
.ev-note-amber { background: var(--amber-bg); border-color: #f1d9a8; }
.ev-note-red { background: var(--red-bg); border-color: #f1c4c4; }
.ev-action { margin-top: .5rem; }
.ev-action summary { list-style: none; cursor: pointer; display: inline-flex; }
.ev-action summary::-webkit-details-marker { display: none; }
.ev-action form { max-width: 560px; }
@media (max-width: 900px) {
  .msg-layout { grid-template-columns: 1fr; }
  .msg { max-width: 92%; }
  .msg-list { max-height: none; }
}

/* ===================================================================== */
/* RESPONSIVE                                                            */
/* ===================================================================== */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  .topbar-menu { display: inline-flex; }
  .topbar { padding: .6rem 1rem; }
  .content { padding: 1rem 1rem 2rem; }
  .grid-2-even { grid-template-columns: 1fr; }
  .topbar-name { display: none; }
}
@media (max-width: 700px) {
  h1 { font-size: 1.4rem; }
  .page-hero { padding: 1rem 1.1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .kv { grid-template-columns: 1fr; }
  .welcome { flex-direction: column; align-items: flex-start; }
  .welcome img { width: 56px; height: 56px; }
  .area-pill { font-size: .66rem; }
  /* Tabelle → schede impilate su smartphone */
  table.table.responsive thead { display: none; }
  table.table.responsive, table.table.responsive tbody, table.table.responsive tr, table.table.responsive td { display: block; width: 100%; }
  table.table.responsive tr { padding: .6rem .9rem; border-bottom: 1px solid var(--border); }
  table.table.responsive td { border: 0; padding: .22rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  table.table.responsive td::before { content: attr(data-label); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: left; flex: none; padding-top: 2px; }
  table.table.responsive td.t-actions { justify-content: flex-end; }
  table.table.responsive td.t-actions::before { content: none; }
  .toolbar .btn { flex: 1 1 auto; }
  .doc-sheet { padding: 1rem; }
  .doc-photo { float: none; display: block; margin: 0 0 .6rem; }
  .toasts { left: 1rem; right: 1rem; bottom: 1rem; max-width: none; }
}
@media print {
  .sidebar, .topbar, .app-footer, .toasts, .btn, .tabs { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.qr-box { width: 230px; max-width: 100%; aspect-ratio: 1; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); display: grid; place-items: center; padding: 6px; }
.qr-box svg { width: 100%; height: 100%; }
@media (min-width: 901px) { .shell { background: linear-gradient(90deg, var(--navy-950) 0, var(--navy-950) var(--sidebar-w), transparent var(--sidebar-w)); } }
.panel-danger { border-color: #f1c4c4; }
.panel-danger .panel-head h2 .icon, .panel-danger .panel-head h3 .icon { color: var(--red); }
.snapshot { max-height: 480px; overflow: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .8rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ===================================================================== */
/* PULIZIA DELLA FEDINA PENALE                                           */
/* ===================================================================== */
.steps { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.steps li { display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .75rem .35rem .4rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: .82rem; color: var(--muted); }
.steps .step-n { display: inline-grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: 50%; background: var(--slate-bg); color: var(--slate); font-weight: 700; font-size: .75rem; }
.steps li.done { color: var(--green); border-color: #bfe3cf; background: var(--green-bg); }
.steps li.done .step-n { background: var(--green); color: #fff; }
.steps li.current { color: var(--navy-900); border-color: var(--gold-400); background: var(--gold-100); font-weight: 600; }
.steps li.current .step-n { background: var(--navy-900); color: #fff; }
.steps li.stopped { color: var(--red); border-color: #f1c4c4; background: var(--red-bg); font-weight: 600; }
.steps li.stopped .step-n { background: var(--red); color: #fff; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem 1rem; margin: 0; }
.fieldset legend { padding: 0 .4rem; font-weight: 700; color: var(--navy-900); font-family: var(--font-serif); }
.tariff-table td { padding: .55rem .9rem; }
.tariff-table tr.muted td { color: var(--muted); }
.tariff-table tr.total-row td { border-top: 2px solid var(--gold-500); background: var(--gold-100); font-size: 1rem; }
.table tr.group-row td { background: var(--surface-2); font-size: .82rem; color: var(--navy-900); padding: .45rem .9rem; }
[data-article-info].is-found { color: var(--navy-900); }
[data-article-info].is-s { color: var(--red); }
[data-article-info].is-missing { color: var(--amber); }
input[type=color] { width: 4rem; height: 2.4rem; padding: .15rem; }
.panel-foot.flex input { width: auto; flex: 0 1 auto; }
.panel-foot.flex input[type=text] { min-width: 12rem; }
/* Avviso IC al login: sparisce dopo 10 secondi */
.ic-notice { position: relative; overflow: hidden; padding-right: 2.4rem; transition: opacity .4s ease, transform .4s ease; }
.ic-notice.is-hiding { opacity: 0; transform: translateY(-6px); }
.ic-notice .ic-close { position: absolute; top: .45rem; right: .45rem; border: 0; background: transparent; color: inherit; cursor: pointer; padding: .2rem; border-radius: 6px; }
.ic-notice .ic-close:hover { background: rgba(0,0,0,.06); }
.ic-notice .ic-timer { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--gold-500); transform-origin: left; animation: ic-countdown 10s linear forwards; }
@keyframes ic-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ===================================================================== */
/* PORTALI DI ACCESSO SEPARATI + PIÈ DI PAGINA (copyright e 029 Project)  */
/* ===================================================================== */
.portal-hospital  { --portal: #0b2a5b; --portal-2: #1d5bb5; }
.portal-medici-privati { --portal: #14406b; --portal-2: #2a6aa3; }
.portal-fire-department { --portal: #6b1d14; --portal-2: #a3321f; }
.portal-governo { --portal: #2b3445; --portal-2: #46526a; }

/* Le pagine "bare" (home, login, errori) hanno il piè di pagina in fondo */
body.bare { display: flex; flex-direction: column; }
body.bare > .auth, body.bare > .home { min-height: 0; flex: 1 0 auto; }
.bare-credits { padding: .85rem 1.5rem; border-top: 1px solid var(--border); background: var(--surface); }
body.bare:has(.auth-admin) .bare-credits { background: var(--navy-950); border-top-color: rgba(212,176,96,.25); }
body.bare:has(.auth-admin) .credits, body.bare:has(.auth-admin) .credits-madeby { color: #b9c4d6; }
body.bare:has(.auth-admin) .credits-madeby strong { color: var(--gold-400); }

.credits { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .4rem 1rem; font-size: .76rem; color: var(--muted); max-width: 1200px; margin: 0 auto; width: 100%; }
.credits-madeby { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); text-decoration: none; }
.credits-madeby img { width: 40px; height: 40px; display: block; transition: transform .2s ease; }
.credits-madeby strong { color: var(--navy-900); font-weight: 700; letter-spacing: .02em; }
.credits-madeby:hover { color: var(--text); }
.credits-madeby:hover img { transform: rotate(-8deg) scale(1.08); }
.credits-inline { flex-basis: 100%; max-width: none; padding-top: .6rem; margin-top: .2rem; border-top: 1px dashed var(--border); }
.home-foot { margin-top: auto; }

/* Login: intestazione colorata con il logo LB Medical, un colore per ogni portale */
.auth-inst[class*="portal-"] {
  background: radial-gradient(ellipse at top, color-mix(in srgb, var(--portal) 14%, #fff) 0%, var(--navy-50) 70%);
}
.auth-card-portal { border-top: 4px solid var(--portal, var(--navy-900)); }
.portal-head { display: flex; align-items: center; gap: 1rem; padding: 1.4rem 1.5rem; color: #fff; background: linear-gradient(135deg, var(--portal) 0%, var(--portal-2) 100%); }
.portal-head-icon { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; flex: none; background: rgba(255,255,255,.12); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.portal-head-icon .icon { width: 32px; height: 32px; }
.portal-head-logo { width: 64px; height: 64px; flex: none; filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); }
.portal-head-eyebrow { margin: 0; font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; opacity: .8; }
.portal-head-title { margin: .15rem 0 .1rem; color: #fff; font-size: 1.35rem; line-height: 1.2; }
.portal-head-tag { margin: 0; font-size: .86rem; opacity: .9; }
.btn-portal { background: var(--portal, var(--navy-900)); }
.btn-portal:hover { background: var(--portal-2, var(--navy-700)); }
.portal-switch { display: flex; flex-wrap: wrap; gap: .3rem .8rem; margin-top: 1.1rem; padding-top: .9rem; border-top: 1px solid var(--border); font-size: .8rem; color: var(--muted); }
.portal-switch a { color: var(--text-2); }

/* Home: accessi raggruppati */
.home-access { display: block; max-width: 980px; }
.home-ic { max-width: 640px; margin: 0 auto 1rem; }
.home-ic:empty { display: none; }
.access-group { margin-bottom: 1.4rem; }
/* Home: un accesso per riga, tutti della stessa larghezza */
.access-list { display: flex; flex-direction: column; gap: .9rem; max-width: 640px; margin: 0 auto; }
.access-group-title { text-align: center; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-family: inherit; font-weight: 700; margin: 0 0 .6rem; padding-left: .2rem; }
.access-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
/* Gruppo con un solo accesso (Giustizia, Amministrazione): stessa larghezza degli altri pulsanti, centrato */
.access-grid > .access-card:only-child { grid-column: 1 / -1; justify-self: center; width: calc(50% - .5rem); }
.access-card[class*="portal-"] .access-icon { background: var(--portal); color: #fff; }
.access-card[class*="portal-"]:hover { border-color: var(--portal-2); }
.access-card.portal-hospital .access-icon { background: var(--gold-100); color: var(--gold-700); }

@media (max-width: 700px) {
  .access-grid { grid-template-columns: 1fr; }
  .access-grid > .access-card:only-child { width: 100%; }
  .credits { justify-content: center; text-align: center; }
  .portal-head { padding: 1.1rem 1.1rem; }
  .portal-head-icon, .portal-head-logo { width: 52px; height: 52px; }
}

/* ===================================================================== */
/* RICERCA ARTICOLI DEL CODICE PENALE                                     */
/* ===================================================================== */
.article-picker { margin-bottom: .7rem; padding: .8rem .9rem; border: 1px solid var(--gold-200); border-radius: var(--radius); background: var(--gold-100); }
.article-picker-label { display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; font-size: .85rem; color: var(--gold-700); margin-bottom: .4rem; }
.article-picker-box, .article-suggest { position: relative; display: block; }
.article-picker-icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; width: 18px; height: 18px; }
.article-picker-input { width: 100%; padding-left: 2.3rem !important; background: #fff; }
.article-picker-hint { margin: .45rem 0 0; transition: color .2s; }
.article-picker-hint.is-flash { color: var(--green); font-weight: 600; }
.article-picker-import { margin-top: .5rem; }
.article-picker-list { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: .3rem; list-style: none; background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; min-width: 280px; }
.article-picker-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: 8px; cursor: pointer; font-size: .88rem; color: var(--text); }
.article-picker-item.is-active, .article-picker-item:hover { background: var(--navy-50); }
.article-picker-code { font-family: var(--font-mono, ui-monospace, monospace); font-weight: 700; color: var(--navy-900); min-width: 3.4rem; }
.article-picker-title { line-height: 1.3; }
.article-picker-class { font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; background: var(--slate-bg); color: var(--slate); white-space: nowrap; }
.article-picker-class.cls-S { background: var(--red-bg); color: var(--red); }
.article-picker-class.cls-A { background: var(--orange-bg); color: var(--orange); }
.article-picker-class.cls-B { background: var(--amber-bg); color: var(--amber); }
.article-picker-class.cls-E { background: var(--green-bg); color: var(--green); }
.article-picker-empty { padding: .6rem; color: var(--muted); font-size: .86rem; }
textarea.charges-text { min-height: 7rem; }
@media (max-width: 700px) {
  .article-picker-item { grid-template-columns: auto 1fr; }
  .article-picker-class { grid-column: 2; justify-self: start; }
}

/* Piè di pagina: tutto centrato, una voce sopra l'altra */
.credits, .credits-inline { flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: .35rem; }
.home-foot, .app-footer { flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: .3rem; }
.app-footer { flex-wrap: nowrap; }
.credits-inline { flex-basis: auto; width: 100%; }
.home-notice { display: inline-flex; align-items: center; gap: .35rem; margin: .1rem 0 0; font-size: .82rem; color: var(--muted); }

/* ===================================================================== */
/* FASCIA DELLA COMMUNITY (Last Beach RP) — prima del piè di pagina       */
/* ===================================================================== */
.community { display: flex; align-items: center; justify-content: center; gap: .5rem; max-width: 1200px; width: 100%; margin: 0 auto .5rem; padding: .2rem 1rem; font-size: .8rem; color: var(--muted); text-align: center; }
.community-logo { display: inline-flex; flex: none; border-radius: 50%; transition: transform .15s ease, opacity .15s ease; }
a.community-logo:hover, a.community-logo:focus-visible { transform: scale(1.12); }
.community-logo img { width: 26px; height: 26px; display: block; }
.community-text { min-width: 0; }
.bare-community, .app-community { padding: 0 1.5rem; }
.bare-community:empty, .app-community:empty { display: none; }

/* Prove su cloud (campi di tipo "links") */
.doc-links { margin: .2rem 0 0; padding-left: 1.2rem; }
.doc-links li { margin: .15rem 0; overflow-wrap: anywhere; }
textarea.links-text { min-height: 6rem; font-family: var(--font-mono, ui-monospace, monospace); font-size: .85rem; }

/* ===================================================================== */
/* FIRMA PERSONALE                                                        */
/* ===================================================================== */
.auth-card-wide { max-width: 680px; }
.sig-tabs { display: flex; gap: .4rem; border-bottom: 1px solid var(--border); }
.sig-tab { appearance: none; border: 0; background: none; padding: .55rem .9rem; font: inherit; font-size: .88rem; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; }
.sig-tab.is-active { color: var(--navy-900); border-bottom-color: var(--gold-500); }
.sig-tab:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; border-radius: 6px; }
.sig-pad-wrap { position: relative; border: 1px dashed var(--border-strong); border-radius: 12px; background: #fff; overflow: hidden; }
.sig-pad { display: block; width: 100%; height: auto; aspect-ratio: 3 / 1; touch-action: none; cursor: crosshair; position: relative; z-index: 1; }
.sig-pad-line { position: absolute; left: 6%; right: 6%; bottom: 24%; border-bottom: 1px solid var(--gold-200); pointer-events: none; }
.sig-pad-actions { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-top: .4rem; flex-wrap: wrap; }
.sig-upload-prev { display: block; max-width: 100%; max-height: 140px; margin: .5rem 0; border: 1px solid var(--border); border-radius: 8px; }
.sig-current, .sig-thumb { border: 1px solid var(--border); border-radius: 12px; padding: .8rem; text-align: center;
  background-color: #fff; background-image: linear-gradient(45deg, #eef1f6 25%, transparent 25%), linear-gradient(-45deg, #eef1f6 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #eef1f6 75%), linear-gradient(-45deg, transparent 75%, #eef1f6 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.sig-current img { max-width: 100%; max-height: 160px; }
.sig-thumb { display: inline-block; padding: .4rem; }
.sidebar-nav details.nav-group > summary { display: flex; align-items: center; gap: .7rem; padding: .62rem .8rem; border-radius: 8px; color: #cfd8e6; font-size: .92rem; cursor: pointer; list-style: none; border-left: 3px solid transparent; }
.sidebar-nav details.nav-group > summary::-webkit-details-marker { display: none; }
.sidebar-nav details.nav-group > summary:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav details.nav-group > summary.active { background: rgba(194,154,63,.16); color: #fff; border-left-color: var(--gold-400); }
.sidebar-nav details.nav-group > summary.active .icon { color: var(--gold-400); }
.sidebar-nav details.nav-group > summary:focus-visible { outline: none; box-shadow: var(--focus); }
.nav-caret { margin-left: auto; width: .45rem; height: .45rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .15s; }
details.nav-group[open] > summary .nav-caret { transform: rotate(-135deg); }
.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 4px .9rem; padding-left: .5rem; border-left: 1px solid rgba(255,255,255,.12); }
.sidebar-nav .nav-sub a { padding: .42rem .7rem; font-size: .86rem; }
.nav-mine { margin-left: auto; font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gold-400); }
.guide-idx a.current { background: var(--navy-900); color: #fff; border-color: var(--navy-900); }
.section-card.has-alert { border-color: var(--gold-500); background: linear-gradient(135deg, var(--gold-200) 0%, var(--gold-100) 45%, #fff 100%); box-shadow: 0 0 0 1px var(--gold-400) inset, var(--shadow-sm); }
.section-card.has-alert .sc-icon { background: var(--orange); color: #fff; }
.section-card .alert-count { position: absolute; top: .7rem; right: .8rem; min-width: 1.6rem; padding: .08rem .5rem; border-radius: 999px; background: var(--orange); color: #fff; font-size: .78rem; font-weight: 700; text-align: center; }
a.stat-card.has-alert { border-color: var(--gold-500); background: linear-gradient(135deg, var(--gold-200), var(--gold-100) 50%, #fff); }
a.stat-card.has-alert .stat-icon { background: var(--orange); color: #fff; }
.list li.has-alert { background: linear-gradient(90deg, var(--gold-100), transparent 75%); box-shadow: inset 3px 0 0 var(--gold-500); }
.sidebar-nav a.has-alert { background: linear-gradient(90deg, rgba(194,154,63,.30), rgba(194,154,63,.06)); color: #fff; border-left-color: var(--gold-400); }
.sidebar-nav a.has-alert .icon { color: var(--gold-400); }
.integ { border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1rem; display: grid; gap: .5rem; background: var(--surface); }
.integ.has-alert { border-color: var(--gold-500); background: linear-gradient(135deg, var(--gold-100), #fff 70%); }
.integ header { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; align-items: center; }
.integ-note { background: var(--navy-50); border-radius: 8px; padding: .6rem .8rem; }
.integ-answer { border-top: 1px dashed var(--border-strong); padding-top: .6rem; display: grid; gap: .4rem; }
.integ-form input[type=file] { display: block; margin-block: .25rem; }
.guide-idx { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.guide-idx a { text-decoration: none; color: var(--navy-900); border: 1px solid var(--border); background: var(--surface); padding: .3rem .8rem; border-radius: 999px; font-size: .88rem; font-weight: 600; }
.guide-idx a:hover { border-color: var(--gold-500); }
.guide .guide-sec { scroll-margin-top: 1rem; }
.guide .guide-tag { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-700); }
.guide h3 { font-family: var(--font-serif); font-size: 1.08rem; color: var(--navy-900); margin: 1.4rem 0 .4rem; }
.guide .panel-body p, .guide .panel-body li { max-width: 72ch; }
.guide .who { color: var(--muted); }
.guide .grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; margin-block: .6rem; }
.guide .box { background: var(--navy-50); border-radius: 10px; padding: .8rem 1rem; min-width: 0; }
.guide .box h4 { margin: 0 0 .3rem; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.guide .box ul { margin: 0; padding-left: 1.1rem; }
.guide ol.steps { counter-reset: s; list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .5rem; }
.guide ol.steps li { counter-increment: s; display: grid; grid-template-columns: 1.7rem 1fr; gap: .6rem; align-items: start; min-width: 0; }
.guide ol.steps li::before { content: counter(s); font-weight: 700; color: var(--gold-700); border: 1.5px solid var(--gold-600); border-radius: 50%; width: 1.5rem; height: 1.5rem; display: grid; place-items: center; font-size: .8rem; margin-top: .1rem; }
.guide .note { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--gold-200); border-radius: 10px; padding: .7rem 1rem; margin-block: .8rem; }
.guide .new { color: var(--green); font-weight: 700; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.guide .scroll { overflow-x: auto; }
.guide table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.guide th, .guide td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.guide th { color: var(--muted); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.guide .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88em; background: var(--navy-50); padding: .05rem .35rem; border-radius: 5px; }
.evidence-list { display: grid; gap: .8rem; }
.evidence-row { display: grid; gap: .5rem; padding: .8rem; border: 1px solid var(--border); border-radius: 12px; }
.evidence-top { display: grid; grid-template-columns: 4.2rem 1fr auto; gap: .5rem; align-items: center; }
.evidence-top .ev-letter { text-align: center; font-weight: 700; }
.avatar { overflow: hidden; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 96px; height: 96px; font-size: 1.8rem; }
.profile-photo { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.sig-thumb img { display: block; max-width: 220px; max-height: 90px; }
.sig-msg { margin: 0; }

/* ===================================================================== */
/* POLIZIA → PROCURA → TRIBUNALE: numeri collegati, percorso, esercitazioni */
/* ===================================================================== */
.badge-test { background: #fff3c4; color: #7a5600; border: 1px dashed #c99a00; font-weight: 700; letter-spacing: .04em; display: inline-flex; align-items: center; gap: .25rem; }
.case-numbers { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 .2rem; }
.case-numbers .cn { display: inline-flex; flex-direction: column; padding: .3rem .65rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); line-height: 1.2; }
.case-numbers .cn small { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.case-numbers .cn b { font-size: .88rem; color: var(--navy-900); }
.case-numbers .cn-police { border-color: #c9d6ee; background: #eef3fc; }
.case-path { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; counter-reset: cp; }
.case-path li { display: flex; gap: .55rem; align-items: flex-start; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.case-path .cp-dot { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-strong); color: #fff; background: var(--surface); }
.case-path .cp-body { display: flex; flex-direction: column; min-width: 0; }
.case-path .cp-body strong { font-size: .84rem; color: var(--navy-900); }
.case-path .cp-body small { font-size: .74rem; color: var(--muted); overflow-wrap: anywhere; }
.case-path .cp-done { border-color: #b9e2c9; background: #f3fbf6; }
.case-path .cp-done .cp-dot { background: #1d7a4e; border-color: #1d7a4e; }
.case-path .cp-pending { border-color: #f1d9a8; background: #fffaf0; }
.case-path .cp-pending .cp-dot { background: #c78a00; border-color: #c78a00; }
.case-path .cp-rejected .cp-dot { background: #b42f2f; border-color: #b42f2f; }
.case-path .cp-skip, .case-path .cp-future { opacity: .6; }
.case-path .cp-skip .cp-dot, .case-path .cp-future .cp-dot { border-style: dashed; }
.choice-card { display: flex; gap: .7rem; align-items: flex-start; padding: .75rem .9rem; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface); }
.choice-card:hover { border-color: var(--gold-400); }
.choice-card:has(input:checked) { border-color: var(--gold-500); background: var(--gold-100); box-shadow: inset 0 0 0 1px var(--gold-400); }
.choice-card input { margin-top: .2rem; }
.choice-card span { display: flex; flex-direction: column; gap: .15rem; }
.choice-card small { color: var(--muted); font-size: .8rem; }
.check-test { padding: .65rem .8rem; border: 1px dashed #c99a00; border-radius: 10px; background: #fffbea; }
.intake-card { border: 1px solid var(--border); border-radius: 14px; padding: .9rem 1rem; margin-bottom: .8rem; background: var(--surface); }
.intake-card.is-test { border-style: dashed; border-color: #c99a00; background: #fffdf3; }
.intake-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.intake-head h3 { margin: .1rem 0 .2rem; font-size: 1.05rem; }
.intake-actions { display: grid; gap: .55rem; margin-top: .7rem; padding-top: .7rem; border-top: 1px dashed var(--border); }
.intake-actions .inline-form { display: flex; gap: .5rem; align-items: center; }
.intake-actions .inline-form input[type=text], .intake-actions .inline-form select { flex: 1 1 auto; width: auto; min-width: 0; }
.intake-actions .inline-form .btn { flex: none; min-width: 170px; justify-content: center; }
.police-forward { display: flex; flex-direction: column; gap: .5rem; padding: .7rem; border: 1px solid #c9d6ee; border-radius: 12px; background: #eef3fc; }
@media (max-width: 560px) {
  .intake-actions .inline-form { flex-wrap: wrap; }
  .intake-actions .inline-form .btn { width: 100%; }
}

/* Messaggio di benvenuto da copiare */
.welcome-msg { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: .86rem; line-height: 1.5; white-space: pre-wrap; background: var(--surface-2, #f6f7fb); }
.secret-box .btn { margin-left: auto; color: inherit; }

/* Gradi di giudizio: riga del procedimento corrente; invito alla difesa */
.table tr.row-current td { background: var(--gold-100); }
.invite-panel { border-color: var(--gold-200); }
.mini-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--gold-100); color: var(--gold-700); font-size: 0.72rem; font-weight: 700; margin-right: 0.6rem; vertical-align: middle; }
.msg header .mini-avatar { width: 28px; height: 28px; margin-right: 0.35rem; }
