/*!
 * LBJustice — 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 LBJustice.
 */

: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-letterhead { width: min(980px, 100%); display: block; margin: 0 auto; }
.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; }

/* ===================================================================== */
/* 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)); } }
