:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #667085;
  --border: #d9dde5;
  --accent: #c62828;
  --accent-text: #ffffff;
  --weekend: #eef1f6;

  --g-bg: #fff4c2; --g-fg: #6b5200;
  --n-bg: #d6e4ff; --n-fg: #1a3d8f;
  --f-bg: #d8f3dc; --f-fg: #1b5e20;
  --m-bg: #ede0f7; --m-fg: #5b2a86;
  --p-bg: #ffe0cc; --p-fg: #8a3b00;
  --r-bg: #e4e7ec; --r-fg: #475467;
  --c-bg: #d3f1f1; --c-fg: #0b5c5c;

  --bad: #c62828; --bad-bg: #fde7e7;
  --warn: #9a6200; --warn-bg: #fff1d6;
  --good: #2e7d32; --good-bg: #e3f4e4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --surface: #1d2129;
    --text: #e6e8ec;
    --muted: #98a1b2;
    --border: #343a46;
    --accent: #e05252;
    --weekend: #232833;
    --g-bg: #4a3f12; --g-fg: #ffe28a;
    --n-bg: #1f3260; --n-fg: #b9cdff;
    --f-bg: #1f4226; --f-fg: #b5e8bd;
    --m-bg: #3c2853; --m-fg: #dcc3f4;
    --p-bg: #4d2c14; --p-fg: #ffc59e;
    --r-bg: #343a46; --r-fg: #c3c9d4;
    --c-bg: #123f40; --c-fg: #a6e6e6;
    --bad: #ff8a80; --bad-bg: #4a1f1f;
    --warn: #ffcc80; --warn-bg: #45351a;
    --good: #a5d6a7; --good-bg: #1f3a22;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button, input, select { font: inherit; color: inherit; }

button, .button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
button:hover:not(:disabled), .button:hover { border-color: var(--muted); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--bad); }
button.ghost { border-color: transparent; background: transparent; }

input, select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

kbd {
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  font-size: 12px;
}

/* ---------- Barra in alto ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 18px; color: var(--accent); }
.tabs { display: flex; gap: 4px; }
.tab { border-color: transparent; background: transparent; }
.tab.active { background: var(--bg); border-color: var(--border); font-weight: 600; }

main { padding: 16px 20px 40px; }
.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card h3 small, th small { font-weight: normal; color: var(--muted); }

/* ---------- Toolbar del tabellone ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  margin-bottom: 12px;
}
.month-nav { display: flex; align-items: center; gap: 8px; }
.amb-view { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.month-nav h2 { margin: 0; min-width: 170px; text-align: center; font-size: 20px; }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.tools-label { color: var(--muted); margin-right: 4px; }
.tool { font-weight: 700; }
.tool small { font-weight: normal; }
.tool.active { outline: 2px solid var(--text); outline-offset: 1px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }

.hint { color: var(--muted); font-size: 13px; }
.note { color: var(--muted); font-size: 13px; max-width: 760px; }

/* ---------- Tabellone ---------- */

.grid-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.grid { border-collapse: collapse; width: 100%; }
.grid th, .grid td {
  border: 1px solid var(--border);
  padding: 0;
  text-align: center;
  white-space: nowrap;
}
.grid thead th { padding: 4px 2px; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
.grid th.day span { display: block; color: var(--muted); font-weight: normal; font-size: 11px; }
.grid th.day.today { color: var(--accent); }
.grid th.name {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  padding: 4px 10px;
  min-width: 170px;
  font-weight: 600;
}
.grid th.name small { display: block; font-size: 11px; }
.grid .monday { border-left: 2px solid var(--muted); }
.grid .weekend { background: var(--weekend); }

.grid td.cell {
  width: 30px;
  min-width: 30px;
  height: 32px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.grid td.cell:focus { outline: 2px solid var(--text); outline-offset: -2px; }
.cell-G { background: var(--g-bg) !important; color: var(--g-fg); }
.cell-N { background: var(--n-bg) !important; color: var(--n-fg); }
.cell-F { background: var(--f-bg) !important; color: var(--f-fg); }
.cell-M { background: var(--m-bg) !important; color: var(--m-fg); }
.cell-P { background: var(--p-bg) !important; color: var(--p-fg); }
.cell-R { background: var(--r-bg) !important; color: var(--r-fg); }
.cell-C { background: var(--c-bg) !important; color: var(--c-fg); }
.grid td.cell-P { font-size: 10px; }
.grid td.cell small { display: block; font-size: 9px; font-weight: 600; line-height: 1; }
.tool-group { display: inline-flex; align-items: center; gap: 4px; }
.tool-group input { width: 64px; padding: 5px 6px; }
.tag104 { display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 8px; font-size: 10px; font-weight: 600; background: var(--p-bg); color: var(--p-fg); vertical-align: 1px; }
.tag104.full { background: var(--bad-bg); color: var(--bad); }
.drv {
  display: inline-block; width: 16px; height: 16px; margin-right: 6px; border-radius: 4px;
  background: var(--accent); color: var(--accent-text); font-size: 10px; line-height: 16px;
  text-align: center; vertical-align: 1px;
}
.check { display: inline-flex; align-items: center; gap: 6px; }
.grid td.cell.error { box-shadow: inset 0 0 0 2px var(--bad); color: var(--bad); }
.grid td.cell.soft { box-shadow: inset 0 0 0 2px var(--warn); }
.grid td.cell.auto { font-style: italic; font-weight: 500; opacity: .8; }
.grid td.cell.locked::after {
  content: "🔒"; position: absolute; top: 0; right: 1px; font-size: 8px; line-height: 1; opacity: .85;
}
.grid td.cell.locked:not([class*="cell-"]) { background-image: repeating-linear-gradient(45deg, transparent 0 4px, var(--border) 4px 5px); }
.row-lock {
  float: right; margin-left: 6px; padding: 0 4px; border-color: transparent; background: transparent;
  font-size: 12px; opacity: .35;
}
.grid tr:hover .row-lock, .row-lock.on { opacity: 1; }
.tool-lock.active { outline-color: var(--accent); }

.grid td.sum { padding: 0 8px; font-variant-numeric: tabular-nums; min-width: 60px; }
.grid thead th.sum { font-size: 11px; color: var(--muted); }
.grid tbody tr:hover th.name, .grid tbody tr:hover td.sum { background: var(--bg); }

.grid tfoot th, .grid tfoot td { font-size: 12px; height: 26px; }
.grid tfoot tr:first-child > * { border-top: 2px solid var(--muted); }

.under { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.over { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.ok { color: var(--good); }
.grid td.sum.ok { background: var(--good-bg); }

.grid.small td { padding: 4px 8px; font-variant-numeric: tabular-nums; }
.grid.small thead th { padding: 4px 8px; }

.empty { padding: 24px !important; color: var(--muted); }

/* ---------- Sotto il tabellone ---------- */

.below {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 16px;
  align-items: start;
}
.below .card { margin: 0; }
.below .grid-wrap { border: none; }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.soft { background: var(--warn-bg); color: var(--warn); }

.issues { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.issues > li { padding: 6px 8px; border-radius: 6px; margin-bottom: 4px; font-size: 13px; }
.issues li.err { background: var(--bad-bg); cursor: pointer; }
.issues li.warn { background: var(--warn-bg); }
.issues li.err.soft { background: var(--warn-bg); }
.issues li.info { background: var(--bg); }
.issues li.okmsg { background: var(--good-bg); color: var(--good); }
.issues summary { cursor: pointer; font-weight: 600; }
.issues ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Dipendenti e impostazioni ---------- */

.row-form { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.row-form .field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.row-form .field[hidden] { display: none; }
.row-form .field input, .row-form .field select { font-size: 14px; font-weight: normal; color: var(--text); }
.row-form #emp-name { min-width: 240px; }
.role-choice { margin: 0; padding: 0; border: 0; flex-direction: row !important; flex-wrap: wrap; gap: 4px 6px !important; }
.role-choice legend { padding: 0; margin-bottom: 4px; }
.role-choice label {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  color: var(--text); font-weight: normal; font-size: 14px; cursor: pointer;
}
.role-choice label:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.role-choice small { color: var(--muted); }
.field-check { padding-bottom: 7px; }
.version { padding: 0 20px 20px; color: var(--muted); font-size: 12px; }
.row-form #emp-hours, .list .hours { width: 90px; }

.list { border-collapse: collapse; width: 100%; }
.list th, .list td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.list th { font-size: 12px; color: var(--muted); font-weight: 600; }
.list td.order { white-space: nowrap; width: 1%; }
.list td.order button { padding: 2px 6px; font-size: 11px; }
.list input[data-field="name"] { width: 100%; min-width: 200px; }
.list input.short { width: 130px; text-transform: uppercase; }
.settings label.wide { grid-column: span 2; }

.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; align-items: end; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.settings button { justify-self: start; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  max-width: min(560px, calc(100% - 32px));
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.period { margin-bottom: 12px; padding: 10px 16px; }
.period summary { cursor: pointer; font-weight: 600; }
.period[open] summary { margin-bottom: 10px; }
.period .note { margin: 10px 0 0; }

.print-only { display: none; }

@media (max-width: 900px) {
  .below { grid-template-columns: 1fr; }
  .below > * { min-width: 0; }
  main { padding: 12px 16px 32px; }
  .topbar { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
}

/* ---------- Stampa: solo il tabellone e le ore settimanali ---------- */

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  :root {
    --bg: #fff; --surface: #fff; --text: #000; --border: #999; --weekend: #eee;
  }
  body { font-size: 10px; }
  .no-print, .hint { display: none !important; }
  .print-only { display: block; margin: 0 0 6px; font-size: 16px; }
  main { padding: 0; }
  .grid-wrap { overflow: visible; border: none; }
  .grid th.name { min-width: 0; position: static; }
  .grid thead th { position: static; }
  .grid td.cell { width: auto; min-width: 0; height: 20px; }
  .grid td.cell.error, .grid td.cell.soft { box-shadow: none; }
  .grid td.cell.locked::after, .row-lock { display: none; }
  .below { display: block; margin-top: 10px; page-break-inside: avoid; }
  .card { border: none; padding: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Ambulanze e turni ---------- */

.amb { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.amb-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; font-weight: 600; }
.amb-head .amb-code { width: 90px; margin-left: 6px; font-weight: 700; letter-spacing: 1px; }
.amb-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.amb-warn { color: var(--warn); font-size: 12px; font-weight: 600; }
.shifts input[data-f="name"] { width: 140px; }
.shifts input.sigla { width: 56px; text-transform: uppercase; font-weight: 700; }
.shifts td.dur { color: var(--muted); white-space: nowrap; }
.shifts td.days { white-space: nowrap; }
.shifts td.days label { display: inline-flex; flex-direction: column; align-items: center; font-size: 11px; margin-right: 4px; }
.grid td.cell-multi { font-size: 9px; line-height: 1.05; }
.grid td.cov.off { color: var(--muted); }
.grid tfoot tr.first-cov > * { border-top: 2px solid var(--muted); }

/* ---------- Accesso, barra utente, avviso cookie ---------- */

body.auth-mode .topbar, body.auth-mode main, body.auth-mode footer.version { display: none; }
.auth-screen {
  min-height: 100vh; display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 16px; background: linear-gradient(180deg, var(--bg), var(--surface));
}
.auth-screen[hidden] { display: none; }
.auth-card {
  width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px 24px 16px; box-shadow: 0 8px 28px rgba(0, 0, 0, .08);
}
.auth-brand { display: flex; align-items: center; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.auth-brand img { width: 64px; height: 64px; }
.auth-org { font-weight: 700; color: var(--accent); font-size: 17px; }
.auth-committee { font-weight: 600; font-size: 15px; }
.auth-title { margin: 16px 0 12px; font-size: 22px; }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.auth-tabs[hidden] { display: none; }
.auth-tab { flex: 1; justify-content: center; }
.auth-tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form[hidden] { display: none; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.auth-form label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: normal; color: var(--text); }
.auth-form input, .auth-form select { font-size: 15px; padding: 8px 10px; color: var(--text); font-weight: normal; }
.auth-form small { font-weight: normal; }
.auth-form button.primary { justify-content: center; padding: 10px; font-size: 15px; }
.auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-link { font-size: 13px; color: var(--accent); align-self: flex-start; }
.auth-message { padding: 10px 12px; border-radius: 8px; background: var(--good-bg); color: var(--good); font-size: 14px; }
.auth-message.error { background: var(--bad-bg); color: var(--bad); }
.auth-message[hidden] { display: none; }
.auth-foot { margin: 16px 0 0; text-align: center; font-size: 12px; }
.auth-foot a { color: var(--muted); }
@media (max-width: 480px) { .auth-row { grid-template-columns: 1fr; } }

.userbar { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
.userbar[hidden] { display: none; }
.userbar .who { color: var(--muted); }
.userbar select { padding: 4px 6px; font-weight: 600; }
.save-status { font-size: 12px; color: var(--good); }
.save-status.pending { color: var(--warn); }
.save-status.error { color: var(--bad); font-weight: 600; }

.cookie-notice {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 50; max-width: 760px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .15); font-size: 13px;
}
.cookie-notice[hidden] { display: none; }
.cookie-notice span { flex: 1 1 320px; }
.cookie-notice a, footer.version a { color: var(--accent); }
.auth-row > label { min-width: 0; }
.auth-form input, .auth-form select { width: 100%; }
.auth-form label.check input { width: auto; }

/* Vista per ambulanza: i turni delle altre ambulanze, sbiaditi nelle stesse caselle */
.grid td.cell .ghost { opacity: .4; font-weight: 600; position: relative; }
.grid td.cell small.ghost { font-size: 9px; }
.grid td.cell-ghost::before { content: ""; position: absolute; inset: 0; opacity: .35; pointer-events: none; }
.grid td.ghost-G::before { background: var(--g-bg); }
.grid td.ghost-N::before { background: var(--n-bg); }
.grid td.ghost-G .ghost { color: var(--g-fg); }
.grid td.ghost-N .ghost { color: var(--n-fg); }
.grid-view-field { margin-top: 14px; max-width: 460px; }

/* ---------- Telefono ---------- */

.menu-btn, .more-btn, .mobile-only { display: none; }
.more-actions { display: contents; }
.nm-short { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.add-mode { font-weight: 700; }
.add-mode[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }

@media (max-width: 700px) {
  .topbar { position: sticky; top: 0; z-index: 30; flex-wrap: nowrap; gap: 8px; padding: 8px 12px; }
  .topbar h1 { flex: 1; font-size: 17px; }
  .menu-btn { display: inline-flex; font-size: 20px; line-height: 1; padding: 6px 12px; }
  .tabs, .userbar { display: none; }
  .topbar.open { flex-wrap: wrap; box-shadow: 0 6px 20px rgba(0, 0, 0, .15); }
  .topbar.open .tabs { display: flex; flex-direction: column; order: 3; width: 100%; }
  .topbar.open .tab:not([hidden]) { justify-content: flex-start; padding: 12px; font-size: 16px; }
  .topbar.open .userbar:not([hidden]) { display: flex; order: 4; width: 100%; margin: 0; padding: 10px 4px 4px; border-top: 1px solid var(--border); }

  main { padding: 10px 12px calc(96px + env(safe-area-inset-bottom)); }
  .toolbar { gap: 10px; }
  .month-nav { width: 100%; flex-wrap: wrap; }
  .month-nav h2 { flex: 1; min-width: 0; font-size: 18px; }
  .month-nav .pub-status { order: 10; flex-basis: 100%; text-align: center; white-space: normal; }
  .amb-view { width: 100%; }
  .amb-view select { flex: 1; }

  /* Strumenti per inserire: barra fissa in basso, a portata di pollice */
  .tools {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    flex-wrap: nowrap; overflow-x: auto; gap: 6px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .1);
  }
  .tools-label { display: none; }
  .tools .tool-group { flex: none; }
  .tools .tool, .tools .add-mode { flex: none; min-height: 44px; padding: 6px 12px; font-size: 16px; }
  .tools .tool small { display: none; }
  .tools .add-mode small { font-size: 12px; }
  .tools #training-hours { width: 56px; min-height: 44px; }

  /* Azioni: la principale in vista, le altre nel menu "Altro" */
  .actions { position: relative; width: 100%; flex-wrap: nowrap; }
  .actions > .primary { flex: 1; justify-content: center; min-height: 44px; }
  .more-btn, .mobile-only { display: inline-flex; min-height: 44px; }
  .more-actions { display: none; }
  .more-actions.open {
    display: flex; flex-direction: column; position: absolute; right: 0; top: calc(100% + 4px); z-index: 25;
    min-width: 230px; padding: 6px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  }
  .more-actions.open button { justify-content: flex-start; padding: 12px; border-color: transparent; font-size: 15px; }

  /* Tabellone: nomi corti per vedere più giorni */
  .grid th.name { min-width: 0; max-width: 96px; padding: 4px 6px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .grid th.name small, .grid th.name .tag104, .grid th.name .nm-full, .row-lock { display: none; }
  .grid th.name .nm-short { display: inline; }
  .grid th.name .drv { margin-right: 3px; }
  .grid td.cell { width: 34px; min-width: 34px; height: 38px; }
  .hint { display: none; }

  /* Tabelle delle impostazioni e degli elenchi: scorrono dentro il riquadro */
  table.list { display: block; overflow-x: auto; }
  .card { padding: 12px; }
  .settings { grid-template-columns: 1fr; }
  .settings label.wide { grid-column: auto; }

  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .cookie-notice { bottom: calc(76px + env(safe-area-inset-bottom)); left: 8px; right: 8px; }
}

/* ---------- Richieste dei dipendenti e pubblicazione ---------- */

.pub-status { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 12px; white-space: nowrap; }
.pub-status.off { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.pub-status.on { background: var(--good-bg); color: var(--good); }
.pub-status.stale { background: var(--warn-bg); color: var(--warn); }
button.publish { font-weight: 600; }
.grid td.cell.req { text-decoration: underline wavy var(--accent); text-underline-offset: 3px; }
.link-btn { padding: 0 6px; margin-left: 6px; font-size: 12px; color: var(--accent); background: transparent; }
.tab-badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px;
  background: var(--accent); color: var(--accent-text); font-size: 11px; line-height: 18px; text-align: center;
}
.cell-A { background: var(--bg) !important; color: var(--muted); }

/* Schermata del dipendente */
body.staff-mode .tabs, body.staff-mode main > .panel { display: none !important; }
.staff-view { max-width: 100%; }
.staff-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 10px; }
.staff-head .month-nav h2 { min-width: 170px; }
.staff-view > .pub-status { display: inline-block; margin: 0 0 12px; white-space: normal; }
.staff-alert { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); }
.staff-grid tr.mine th.name, .staff-grid tr.mine td.cell:not([class*="cell-"]) { background: var(--g-bg); }
.staff-grid td.cell { cursor: default; }
.staff-grid td.cell.editable { cursor: pointer; }
.staff-grid td.cell.editable:hover, .staff-grid td.cell.editable:focus { outline: 2px solid var(--text); outline-offset: -2px; }
.req-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.req-tools .tool { min-height: 40px; }
.my-shifts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.my-shifts li { display: flex; align-items: center; gap: 8px; }
.my-shifts .when { width: 52px; color: var(--muted); font-size: 13px; }
.my-shifts .cell { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 30px; padding: 0 4px;
  border-radius: 6px; font-weight: 700; }
.my-shifts .cell small { font-size: 9px; margin-left: 1px; }
.my-shifts .what { font-size: 13px; }

/* ---------- Volontari generici ---------- */

.grid td.cov { cursor: pointer; }
.grid td.cov:hover { outline: 2px solid var(--text); outline-offset: -2px; }
.grid td.cov .vol-mark { display: block; font-size: 9px; line-height: 1; font-weight: 700; color: var(--accent); }
.vol-pop {
  position: absolute; z-index: 60; width: 270px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.vol-head { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 8px; }
.vol-head button { margin-left: auto; padding: 2px 8px; }
.vol-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.vol-row span { flex: 1; font-size: 14px; }
.vol-row button { width: 36px; height: 36px; justify-content: center; font-size: 18px; padding: 0; }
.vol-row b { min-width: 18px; text-align: center; }
.vol-pop .note { margin: 6px 0 0; font-size: 12px; }

/* Dipendenti sospesi */
#emp-table tr.suspended td, #emp-table tr.suspended input, #emp-table tr.suspended select { color: var(--muted); }
#emp-table tr.suspended { background: var(--bg); }

/* ---------- Finestra di rifiuto delle richieste ---------- */

.dialog { width: min(480px, calc(100% - 24px)); padding: 16px 18px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); box-shadow: 0 12px 36px rgba(0, 0, 0, .25); }
.dialog::backdrop { background: rgba(0, 0, 0, .35); }
.dialog h3 { margin: 0 0 8px; }
.dialog ul { margin: 6px 0; padding-left: 20px; }
.dialog .check { margin: 12px 0 6px; font-weight: 600; }
.dialog .field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.dialog textarea { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit;
  background: var(--surface); color: var(--text); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
#users-table input[data-f="first_name"], #users-table input[data-f="last_name"] { width: 100%; min-width: 120px; }

.ics-row { margin: 12px 0 4px; }

/* Riposo chiesto per un solo turno (G = a casa di giorno, N = a casa la notte) */
.grid td.cell { position: relative; }
.grid td.cell .off-mark {
  position: absolute; right: 1px; top: 1px; padding: 0 2px; border-radius: 3px; font-style: normal;
  font-size: 9px; line-height: 12px; font-weight: 700; background: var(--bg); color: var(--muted);
  border: 1px dashed var(--muted);
}
.grid td.cell sub, .req-tools sub { font-size: 9px; vertical-align: baseline; margin-left: 1px; }
.staff-view .staff-alert + .staff-alert, .staff-view .note + .staff-alert { margin-top: 6px; }
.staff-view .staff-alert { margin-bottom: 8px; }
