/* =========================================================================
   CinePost CRM — foglio di stile (tema scuro)
   ========================================================================= */

/* ---------- reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

:root {
  --bg: #0d0f13;
  --panel: #14171d;
  --panel-2: #1a1f28;
  --panel-3: #222836;
  --border: #262c38;
  --border-soft: #1e232d;
  --text: #e7eaf0;
  --muted: #98a2b3;
  --muted-2: #6b7486;
  --accent: #4f8cff;
  --accent-soft: rgba(79,140,255,0.14);
  --ok: #22c55e;
  --ok-soft: rgba(34,197,94,0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245,158,11,0.14);
  --err: #ef4444;
  --err-soft: rgba(239,68,68,0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px rgba(0,0,0,0.4);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
  background: var(--panel-3);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 6px;
}
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
h4 { font-size: 13.5px; font-weight: 650; }
small { font-size: 12px; color: var(--muted); }
::selection { background: var(--accent-soft); }

/* ---------- icone ---------- */
.icon { width: 18px; height: 18px; display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* ---------- shell ---------- */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #12151b 0%, #10131a 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 16px; }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; object-fit: contain; display: block; flex-shrink: 0; }
.brand-logo-default { display: flex; align-items: center; justify-content: center; background: var(--panel-3); font-size: 20px; border: 1px solid var(--border); }
.brand-text { min-width: 0; }
.brand-name { display: block; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-tag { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; padding: 6px 0; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 13.5px; font-weight: 500;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap; overflow: hidden;
}
.nav-item .icon { opacity: 0.85; }
.nav-item:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: #fff; }
.nav-item.active .icon { color: var(--accent); opacity: 1; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.user-chip div { min-width: 0; display: flex; flex-direction: column; }
.user-chip strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip span { font-size: 11.5px; color: var(--muted); }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; flex: 1;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(79,140,255,0.10), transparent 60%), var(--bg);
}
.login-card { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 18px; }
.login-brand { width: 100%; display: flex; justify-content: center; }
.login-brand .brand { width: 100%; padding: 0; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.login-brand .brand-logo { width: 380px; max-width: 100%; height: auto; border-radius: 14px; }
.login-brand .brand-logo-default { width: 96px; height: 96px; font-size: 40px; }
.login-brand .brand-name { font-size: 18px; white-space: normal; }
.login-card .panel { padding: 22px; margin-bottom: 0; }
.login-card h2 { margin-bottom: 14px; text-align: center; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-hints { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- bottoni ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit; font-size: 13.5px; font-weight: 550;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 8px 14px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.12s, border-color 0.12s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #5f97ff; }
.btn-success { background: var(--ok); border-color: var(--ok); color: #06210f; }
.btn-success:hover { background: #34d970; }
.btn-danger { background: transparent; border-color: rgba(239,68,68,0.5); color: #ff8a8a; }
.btn-danger:hover { background: var(--err-soft); border-color: var(--err); color: #ffb2b2; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid transparent; color: var(--muted); cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--err-soft); color: #ff9a9a; }
.icon-btn .icon { width: 16px; height: 16px; }
.row-actions { display: inline-flex; gap: 4px; }/* ---------- layout di pagina ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title p { color: var(--muted); margin-top: 4px; font-size: 13px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel h2, .panel h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.panel h2 .icon, .panel h3 .icon { color: var(--accent); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.card .label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.card .value { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.card .sub { font-size: 12px; color: var(--muted-2); }
.card.warn { border-color: rgba(245,158,11,0.45); background: linear-gradient(180deg, rgba(245,158,11,0.07), transparent 65%), var(--panel); }

.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; margin-bottom: 16px; }
.dash-cols .panel { margin-bottom: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 8px 14px; font-size: 13px; font-weight: 550; color: var(--muted); background: transparent; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-family: inherit; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.list-wrap { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--border-soft); }
.list-row:first-child { border-top: none; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.grow strong { font-size: 13.5px; font-weight: 600; }
.grow span, .list-row > span { font-size: 12.5px; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: "SFMono-Regular", Consolas, Menlo, monospace; font-size: 0.92em; }
.right { text-align: right; }
.count { font-size: 11.5px; color: var(--muted); background: var(--panel-3); border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px; margin-left: 6px; }
.arrow { color: var(--muted-2); margin: 0 6px; }
.clickable { cursor: pointer; }

.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 26px 8px; font-size: 13.5px; }

.empty, .empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 34px 16px; color: var(--muted); text-align: center; font-size: 13.5px; }
.empty-emoji, .empty-icon { font-size: 34px; }

.error-box, .alert.err { background: var(--err-soft); border: 1px solid rgba(239,68,68,0.4); color: #ffb2b2; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; }/* ---------- form ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 550; color: var(--muted); }
.field small.hint, .hint { font-size: 11.5px; color: var(--muted-2); }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-end { justify-content: flex-end; }

input, select, textarea {
  font-family: inherit; font-size: 13.5px; color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.55; cursor: not-allowed; }
select { cursor: pointer; }
textarea { resize: vertical; min-height: 64px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; padding: 0; border-radius: 0; background: transparent; box-shadow: none; }
input[type="range"] { padding: 0; border: none; background: transparent; accent-color: var(--accent); height: 24px; cursor: pointer; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

.members-block { display: flex; flex-direction: column; gap: 10px; }
.members-block > span { font-size: 12.5px; font-weight: 550; color: var(--muted); }
.members { display: flex; flex-direction: column; gap: 8px; }
.member-row { display: grid; grid-template-columns: 1.2fr 1fr 34px; gap: 8px; align-items: center; }

.settings-logo-row { display: flex; align-items: center; gap: 12px; }
.settings-logo-preview { width: 54px; height: 54px; border-radius: var(--radius-sm); background: var(--panel-3); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.settings-logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.settings-logo-preview .icon { width: 26px; height: 26px; color: var(--muted); }
.settings-dirty { color: var(--warn); font-size: 12.5px; font-weight: 550; }
.word-count { font-size: 11.5px; color: var(--muted-2); margin-left: auto; white-space: nowrap; }/* ---------- tabelle ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; padding: 10px 12px; background: var(--panel-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-strong { display: flex; flex-direction: column; gap: 2px; }

.totals, .totals-box { max-width: 420px; margin-left: auto; display: flex; flex-direction: column; gap: 2px; }
.trow { display: flex; justify-content: space-between; gap: 12px; padding: 6px 2px; font-size: 13.5px; color: var(--muted); }
.trow .val { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.trow.disc .val { color: var(--warn); }
.trow.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 15px; font-weight: 700; color: var(--text); }
.trow.total .val { font-weight: 700; color: var(--accent); font-size: 16px; }

.quote-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.quote-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.quote-meta strong { color: var(--text); font-weight: 550; }

.decision-note { margin-top: 14px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--err-soft); border: 1px solid rgba(239,68,68,0.35); color: #ffb2b2; font-size: 13px; }
.decision-note.approved { background: var(--ok-soft); border-color: rgba(34,197,94,0.35); color: #86efac; }

.billing-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }
.billing-row:first-of-type { border-top: none; }
.billing-row strong { display: block; font-size: 13.5px; }
.billing-date { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.history-item { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 9px 0; border-top: 1px solid var(--border-soft); font-size: 13px; }
.history-item:first-child { border-top: none; }
.h-when { font-size: 12px; color: var(--muted-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.h-what { color: var(--text); }
.h-vals { color: var(--muted); font-size: 12.5px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.legend-consuntivo { font-size: 12px; color: var(--muted); margin-top: 10px; }
.notes { font-size: 13px; color: var(--muted); white-space: pre-wrap; }

/* ---------- editor voci (preventivi / fatture) ---------- */
.items-editor { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.item-help { display: grid; grid-template-columns: 2fr 1.2fr 70px 90px 110px 80px 34px; gap: 8px; font-size: 11px; color: var(--muted-2); align-items: center; }
.item-head, .item-row { display: grid; grid-template-columns: 2fr 1.2fr 70px 90px 110px 80px 34px; gap: 8px; align-items: center; }
.item-head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.item-row { padding: 4px 0; border-top: 1px solid var(--border-soft); }/* ---------- badge e stati ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; line-height: 1.5; }

.st-personnel { background: var(--accent-soft); color: #9ec3ff; border-color: rgba(79,140,255,0.35); }
.st-room { background: rgba(139,92,246,0.14); color: #c4b0ff; border-color: rgba(139,92,246,0.4); }
.st-freelance { background: rgba(20,184,166,0.14); color: #7fe0d1; border-color: rgba(20,184,166,0.4); }

.st-planning { background: var(--accent-soft); color: #9ec3ff; border-color: rgba(79,140,255,0.35); }
.st-production { background: var(--warn-soft); color: #fbc96b; border-color: rgba(245,158,11,0.4); }
.st-post { background: rgba(139,92,246,0.14); color: #c4b0ff; border-color: rgba(139,92,246,0.4); }
.st-review { background: rgba(236,72,153,0.14); color: #f9a8d4; border-color: rgba(236,72,153,0.4); }
.st-done { background: var(--ok-soft); color: #86efac; border-color: rgba(34,197,94,0.4); }
.st-archived { background: var(--panel-3); color: var(--muted); border-color: var(--border); }

.st-draft { background: var(--panel-3); color: var(--muted); border-color: var(--border); }
.st-submitted { background: var(--warn-soft); color: #fbc96b; border-color: rgba(245,158,11,0.4); }
.st-sentc { background: var(--accent-soft); color: #9ec3ff; border-color: rgba(79,140,255,0.35); }
.st-approved { background: var(--ok-soft); color: #86efac; border-color: rgba(34,197,94,0.4); }
.st-rejected { background: var(--err-soft); color: #ff9a9a; border-color: rgba(239,68,68,0.4); }
.st-billed { background: rgba(6,182,212,0.14); color: #7dd3fc; border-color: rgba(6,182,212,0.4); }
.st-paid { background: var(--ok-soft); color: #86efac; border-color: rgba(34,197,94,0.4); }

.st-notstarted { background: var(--panel-3); color: var(--muted); border-color: var(--border); }
.st-inprogress { background: var(--warn-soft); color: #fbc96b; border-color: rgba(245,158,11,0.4); }
.st-paused { background: rgba(148,163,184,0.14); color: #cbd5e1; border-color: rgba(148,163,184,0.4); }
.st-completed { background: var(--ok-soft); color: #86efac; border-color: rgba(34,197,94,0.4); }
.st-blocked { background: var(--err-soft); color: #ff9a9a; border-color: rgba(239,68,68,0.4); }

.pos { color: var(--ok); }
.neg { color: var(--err); }
.danger { color: #ff8a8a; }/* ---------- modali ---------- */
#modal-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4,6,10,0.66); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 18px; overflow-y: auto; pointer-events: auto; }
.modal { width: 100%; max-width: 520px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; margin: auto 0; }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { display: flex; align-items: center; gap: 8px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.confirm-msg { font-size: 13.5px; line-height: 1.55; }

/* ---------- toast ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 36px)); }
.toast { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 11px 15px; font-size: 13px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: opacity 0.22s, transform 0.22s; }
.toast.in { opacity: 1; transform: none; }
.toast.out { opacity: 0; transform: translateY(6px); }
.toast.err { background: var(--err-soft); border-color: rgba(239,68,68,0.45); color: #ffb2b2; }

/* ---------- dettaglio prenotazione ---------- */
.alloc-detail { display: flex; flex-direction: column; gap: 14px; }
.alloc-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.alloc-kv { display: flex; flex-direction: column; gap: 2px; }
.alloc-kv-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-2); font-weight: 600; }
.alloc-kv-value { font-size: 13.5px; }
.booking-members { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.booking-members .list-row { border-top: 1px solid var(--border-soft); }
.booking-members .list-row:first-child { border-top: none; }

.progress-block { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.progress-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.progress-head h4 { display: flex; align-items: center; gap: 8px; }
.pct-val { font-size: 20px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.progress-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.progress-range { display: flex; align-items: center; gap: 10px; }
.prog-meta { font-size: 12px; color: var(--muted-2); }

.notes-title { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.note-list { display: flex; flex-direction: column; }
.note-item { padding: 10px 0; border-top: 1px solid var(--border-soft); }
.note-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.note-meta strong { color: var(--text); }
.note-text { font-size: 13px; white-space: pre-wrap; }
.note-empty { color: var(--muted-2); font-size: 13px; padding: 10px 0; }
.note-composer { display: flex; flex-direction: column; gap: 8px; }/* ---------- agenda / schedule ---------- */
.sched-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; max-width: 680px; }
.sched { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); overflow-x: auto; }
.sched-inner { min-width: 880px; }
.sched-head { display: grid; grid-template-columns: 190px 1fr; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.sched-label { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--border); min-width: 0; }
.sched-label strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-label small { color: var(--muted-2); }
.sched-days { display: grid; grid-template-columns: repeat(14, 1fr); }
.sched-day { padding: 8px 3px; text-align: center; font-size: 12px; color: var(--muted); border-left: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 1px; }
.sched-day .dow { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-2); }
.sched-day.weekend { background: rgba(255,255,255,0.02); }
.sched-day.today { color: var(--accent); }
.sched-day.today .dow { color: var(--accent); }

.sched-row { display: grid; grid-template-columns: 190px 1fr; border-bottom: 1px solid var(--border-soft); }
.sched-row:last-child { border-bottom: none; }
.sched-track { position: relative; display: grid; grid-template-columns: repeat(14, 1fr); min-height: 46px; }
.sched-cell { border-left: 1px solid var(--border-soft); min-height: 46px; height: 100%; }
.sched-cell.weekend { background: rgba(255,255,255,0.02); }
.sched-cell.today { background: var(--accent-soft); }
.sched-cell.clickable:hover { background: rgba(79,140,255,0.25); }

.sched-bar { position: absolute; top: 50%; transform: translateY(-50%); height: 22px; border-radius: 6px; color: #0b0d12; font-size: 11.5px; font-weight: 650; display: flex; align-items: center; padding: 0 8px; overflow: hidden; white-space: nowrap; z-index: 2; box-shadow: 0 2px 8px rgba(0,0,0,0.35); }
.sched-bar.clickable { cursor: pointer; }
.sched-bar.clickable:hover { filter: brightness(1.1); }
.sched-bar.group { outline: 2px dashed rgba(255,255,255,0.7); outline-offset: -3px; }
.sched-bar-prog { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,0.35); pointer-events: none; }
.sched-bar.ws-completed { opacity: 0.72; }
.sched-bar.ws-paused { opacity: 0.8; }
.sched-bar.ws-blocked { outline: 2px solid var(--err); }
.sched-bar[draggable="true"] { cursor: grab; }
.sched-bar.dragging { opacity: 0.4; }
.sched-cell.drop-target { background: rgba(79,140,255,0.35); box-shadow: inset 0 0 0 2px #4f8cff; }
/* doppio-booking: lista conflitti (409) */
.conflict-box p { margin: 0 0 12px; color: var(--muted); }
.conflict-list { display: flex; flex-direction: column; gap: 8px; }
.conflict-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-3); }
.conflict-item small { margin-left: auto; color: var(--muted); }/* ---------- statistiche ---------- */
.stat-panel { min-height: 120px; }
.stat-rank { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border-soft); }
.stat-rank:first-of-type { border-top: none; }
.stat-rank.no-rev { opacity: 0.65; }
.rank { width: 26px; height: 26px; border-radius: 50%; background: var(--panel-3); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.stat-nums { display: flex; flex-direction: column; gap: 2px; }
.stat-nums > div { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; font-size: 12px; color: var(--muted); }
.stat-nums .num { color: var(--text); }

/* ---------- spese ufficio ---------- */
.exp-cols { grid-template-columns: 1.25fr 1fr; }
.exp-total { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.month-bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 5px; align-items: end; height: 160px; padding-top: 8px; }
.mbar { display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; min-width: 0; }
.mbar-val { font-size: 9.5px; color: var(--muted); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.mbar-track { flex: 1; width: 100%; max-width: 26px; background: var(--panel-3); border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden; }
.mbar-fill { width: 100%; background: linear-gradient(180deg, var(--accent), #3567c4); border-radius: 6px 6px 0 0; min-height: 2px; }
.mbar:not(.on) .mbar-fill { display: none; }
.mbar-label { font-size: 10px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.03em; }

.catbars { display: flex; flex-direction: column; gap: 12px; }
.catbar-row { display: flex; flex-direction: column; gap: 5px; }
.catbar-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.catbar-head .num { color: var(--muted); font-size: 12px; }
.catbar-track { height: 8px; border-radius: 4px; background: var(--panel-3); overflow: hidden; }
.catbar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #3567c4, var(--accent)); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .dash-cols, .exp-cols { grid-template-columns: 1fr; }
  .dash-cols .panel { margin-bottom: 0; }
}
@media (max-width: 860px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 12px; }
  .nav { flex-direction: row; overflow-x: auto; flex-wrap: nowrap; }
  .nav-item { white-space: nowrap; }
  .sidebar-foot { flex-direction: row; align-items: center; border-top: none; padding-top: 0; }
  .main { padding: 18px 16px 50px; }
  .form-grid { grid-template-columns: 1fr; }
  .sched-controls { grid-template-columns: 1fr; }
  .alloc-detail-grid { grid-template-columns: 1fr; }
  .member-row { grid-template-columns: 1fr 34px; }
  .item-head { display: none; }
  .item-help { display: none; }
  .item-row { grid-template-columns: 1fr 1fr 34px; grid-auto-rows: auto; }
  .month-bars { grid-template-columns: repeat(6, 1fr); row-gap: 14px; }
}
.note-del { margin-left: auto; }
/* =========================================================================
   Ricerca globale (sidebar)
   ========================================================================= */
.sidebar-search { position: relative; padding: 0 8px; margin-bottom: 14px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box .icon { color: var(--muted); flex-shrink: 0; }
.search-box input {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--text); font-size: 13.5px; font-family: var(--font);
}
.search-box input::placeholder { color: var(--muted-2); }

.search-drop {
  position: absolute; left: 8px; right: 8px; top: calc(100% + 6px);
  z-index: 60;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 380px; overflow-y: auto;
  padding: 6px;
  animation: searchDropIn 0.12s ease;
}
@keyframes searchDropIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.search-empty { padding: 14px 12px; color: var(--muted); font-size: 13px; text-align: center; }
.search-group { margin-bottom: 2px; }
.search-group-title {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted-2); padding: 8px 10px 4px;
}
.search-item { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.search-item:hover { background: var(--panel-2); }
.si-title { font-size: 13.5px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* flash sulla riga trovata dopo la navigazione */
table tbody tr.search-hit { animation: searchHit 2.6s ease; }
@keyframes searchHit {
  0%   { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
  70%  { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
  100% { background: transparent; box-shadow: inset 0 0 0 0 transparent; }
}

@media (max-width: 860px) {
  .search-drop { position: static; margin-top: 6px; box-shadow: none; }
}

/* ---------- notifiche (campanella sidebar) ---------- */
.notif-wrap { margin-bottom: 10px; }
.notif-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.notif-btn:hover { background: var(--panel-2); color: var(--text); }
.notif-btn .icon { width: 17px; height: 17px; }
.notif-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--err);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.notif-panel {
  position: fixed;
  z-index: 90;
  width: 340px;
  max-width: calc(100vw - 16px);
  max-height: min(480px, calc(100vh - 24px));
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: searchDropIn 0.14s ease;
}
.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  background: var(--panel);
}
.notif-markall {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}
.notif-markall:hover { background: var(--accent-soft); }
.notif-empty { padding: 18px 12px; color: var(--muted); font-size: 13px; }
.notif-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--panel-2); }
.notif-item.unread { background: var(--accent-soft); }
.notif-item.unread:hover { background: var(--accent-soft); }
.notif-title { font-size: 13px; font-weight: 600; }
.notif-msg { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.notif-time { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }/* ---------- PWA / mobile (bottom bar, offline, agenda sticky) ----------
.mnav { display: none; }
.mnav-ic { display: inline-flex; }
.offline-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; font-size: 12.5px;
  background: #3a2c10; color: #ffd98a;
  border-bottom: 1px solid #6b5316;
}
.more-menu { display: flex; flex-direction: column; gap: 4px; }
.more-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 8px; color: inherit; text-decoration: none;
}
.more-item:hover { background: var(--panel-3); }

@media (max-width: 860px) {
  .sidebar .nav { display: none; }
  .main { padding-bottom: 84px; }
  .offline-bar { top: 0; }
  .mnav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: rgba(13, 15, 19, 0.96);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mnav-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: none; color: var(--muted);
    font-size: 10.5px; padding: 6px 2px; border-radius: 8px; cursor: pointer;
    text-decoration: none; font-family: inherit;
  }
  .mnav-item .mnav-ic svg { width: 24px; height: 24px; }
  .mnav-item.active { color: var(--accent); }
  .mnav-item:active { background: var(--panel-3); }

  /* Agenda mobile: colonna risorse fissa (sticky) + scroll orizzontale dei giorni */
  .sched-inner { min-width: 0; }
  .sched-head, .sched-row { grid-template-columns: 118px 1fr; }
  .sched-label { position: sticky; left: 0; z-index: 3; background: var(--panel-2); min-width: 118px; }
  .sched-row .sched-label { background: var(--panel); }
  .sched-days, .sched-track { min-width: 560px; }
  .sched-bar { height: 26px; font-size: 11px; }
}
