/* =====================================================================
   TeamTidier — stile. Mobile first, tema chiaro/scuro automatico.
   ===================================================================== */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --ink: #14213d;
  --text: #1c2330;
  --muted: #6a7180;
  --line: #e2ddd2;
  --brass: #9a6b1f;
  --brass-soft: #f3e8d4;
  --primary: #14213d;
  --primary-ink: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #b54708;
  --warn-soft: #fef3e2;
  --st-draft: #64748b;
  --st-pending: #c27803;
  --st-approved: #2563eb;
  --st-published: #15803d;
  --st-rejected: #b42318;
  --today: #fff7e6;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(20 33 61 / 6%), 0 4px 16px rgb(20 33 61 / 6%);
  --tabbar-h: 64px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420; --surface: #171e2d; --surface-2: #1f2738; --ink: #e8ecf4; --text: #dfe4ee;
    --muted: #94a0b4; --line: #2a3446; --brass: #d8a656; --brass-soft: #3a2f1c;
    --primary: #d8a656; --primary-ink: #141414; --danger: #f97066; --danger-soft: #3b1d1b;
    --warn: #fdb022; --warn-soft: #3a2a12; --today: #2a2516;
    --st-draft: #94a3b8; --st-pending: #fbbf24; --st-approved: #60a5fa; --st-published: #4ade80; --st-rejected: #f87171;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
h1, h2, h3 { color: var(--ink); margin: 0; }
h1 { font: 600 1.45rem/1.2 var(--serif); letter-spacing: .1px; }
h2 { font-size: 1rem; font-weight: 650; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ico { flex: none; }

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: .86rem; border-radius: 9px; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  border: 0; background: transparent; cursor: pointer; color: var(--ink);
}
.icon-btn:hover, .icon-btn.on { background: var(--surface-2); }
:focus-visible { outline: 2.5px solid var(--brass); outline-offset: 2px; }

/* ---------- Campi ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin: 0 0 14px; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: .78rem; }
.field input, .field select, .field textarea, .filters input, .filters select, .hist-dept {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft); }
.field input[type=color] { padding: 4px; height: 44px; }
.field input:disabled { opacity: .65; }
.times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pw-row { display: flex; gap: 6px; align-items: center; }
.pw-row input { flex: 1; }

/* ---------- Pill e badge ---------- */
.pill {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px;
  font-size: .74rem; font-weight: 650; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.r-director { background: var(--brass-soft); color: var(--brass); }
.pill.r-manager { background: color-mix(in srgb, var(--st-approved) 14%, transparent); color: var(--st-approved); }
.pill.st-pending { background: color-mix(in srgb, var(--st-pending) 16%, transparent); color: var(--st-pending); }
.pill.st-approved { background: color-mix(in srgb, var(--st-approved) 14%, transparent); color: var(--st-approved); }
.pill.st-published { background: color-mix(in srgb, var(--st-published) 14%, transparent); color: var(--st-published); }
.pill.st-rejected { background: var(--danger-soft); color: var(--danger); }
.badge {
  display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 5px;
  border-radius: 6px; background: var(--c); color: #fff; font-weight: 700; font-size: .78rem; letter-spacing: .3px;
}
.dept-code {
  display: inline-grid; place-items: center; min-width: 40px; height: 26px; padding: 0 6px; border-radius: 7px;
  background: var(--ink); color: var(--bg); font-weight: 700; font-size: .75rem; letter-spacing: .5px;
}

/* ---------- Struttura ---------- */
.splash { min-height: 100vh; display: grid; place-items: center; }
.logo {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--ink); color: var(--bg); font: 700 .95rem var(--serif); letter-spacing: .5px;
}
.logo.big { width: 64px; height: 64px; font-size: 1.6rem; border-radius: 16px; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text strong { font: 600 1rem var(--serif); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text small { color: var(--brass); font-size: .72rem; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; }
.me { display: flex; align-items: center; gap: 8px; min-width: 0; }
.me-name { font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; }
@media (max-width: 520px) { .me-name { display: none; } }

main#view { padding: 16px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); max-width: 1180px; margin: 0 auto; outline: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 600;
}
.tabbar a.on { color: var(--ink); }
.tabbar a.on .ico { color: var(--brass); }
.tabbar .dot {
  position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: .68rem; display: grid; place-items: center;
}

@media (min-width: 900px) {
  .tabbar {
    top: 0; bottom: 0; right: auto; width: 92px; height: auto; flex-direction: column; justify-content: flex-start;
    padding: 84px 0 0; border-top: 0; border-right: 1px solid var(--line);
  }
  .tabbar a { flex: none; height: 72px; }
  .topbar { padding-left: 108px; }
  main#view { padding: 24px 28px 40px 120px; }
}

.loading { padding: 40px 0; text-align: center; color: var(--muted); }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 10px; }
.empty.error, .error { color: var(--danger); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { margin-bottom: 12px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sec-head h2 { margin: 0; }

/* ---------- Login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 28px 22px; box-shadow: var(--shadow); text-align: center;
}
.login-card h1 { margin-top: 14px; }
.login-card > p.muted { margin: 4px 0 22px; }
.login-card .field { text-align: left; }
.form-error { color: var(--danger); min-height: 1.2em; font-size: .88rem; margin: 0 0 10px; }

/* ---------- Planning ---------- */
.toolbar { display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 700; font-size: .82rem; letter-spacing: .5px; cursor: pointer;
}
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.weeknav { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.week-label { flex: 1; border: 0; background: none; cursor: pointer; padding: 8px; font-size: .95rem; color: var(--ink); }
.dept-title { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 10px; gap: 8px; }
.view-toggle { display: flex; gap: 2px; }

.banners { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--st-draft); font-size: .9rem;
}
.banner > .ico { color: var(--muted); }
.banner > div:not(.banner-acts):not(.banner-text) { flex: 1; min-width: 200px; }
.banner-text { flex: 1 1 240px; }
.banner-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.banner.st-pending { border-left-color: var(--st-pending); }
.banner.st-approved { border-left-color: var(--st-approved); }
.banner.st-published { border-left-color: var(--st-published); }
.banner.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.banner.warn > .ico { color: var(--warn); }
.reject-note { color: var(--danger); font-weight: 600; }
.changed-note { color: var(--warn); font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }

.grid-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; }
.grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 640px; font-size: .8rem; }
.grid th, .grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.grid tr:last-child > * { border-bottom: 0; }
.grid > * > tr > :last-child { border-right: 0; }
.grid thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); padding: 6px 2px; font-weight: 600; text-align: center; }
.grid thead th .dname { display: block; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .6px; }
.grid thead th .dnum { display: block; font-size: 1rem; color: var(--ink); font-weight: 700; }
.grid thead th.today .dnum { color: var(--brass); }
.grid thead th.today { box-shadow: inset 0 -3px 0 var(--brass); }
.sdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--st-draft); }
.sdot.st-pending { background: var(--st-pending); }
.sdot.st-approved { background: var(--st-approved); }
.sdot.st-published { background: var(--st-published); }
.grid .corner, .grid .person { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; }
.grid .corner { z-index: 3; background: var(--surface-2); padding-left: 12px; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.grid .person { padding: 8px 10px; min-width: 116px; max-width: 150px; box-shadow: 2px 0 4px -2px rgb(0 0 0 / 8%); }
.pname { display: block; font-weight: 650; color: var(--ink); font-size: .84rem; line-height: 1.15; }
.prole { display: block; color: var(--muted); font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid td { padding: 0; vertical-align: middle; text-align: center; min-width: 64px; height: 56px; position: relative; }
.grid td.wkend { background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
.grid td.today { background: var(--today); }
.grid td.editable { cursor: pointer; }
.grid td.editable:hover { background: var(--brass-soft); }
.grid td.locked::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--st-pending) 10%, transparent) 6px 8px); pointer-events: none; }
.grid td.warn-rest { box-shadow: inset 0 0 0 2px var(--danger); }
.grid td.changed::before { content: ""; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.cell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px 2px; }
.cell .t { font-size: .68rem; color: var(--muted); line-height: 1.15; font-variant-numeric: tabular-nums; }
.cell-empty { color: var(--line); font-size: 1.2rem; }
.note-dot { position: absolute; bottom: 4px; right: 4px; width: 0; height: 0; border-left: 7px solid transparent; border-bottom: 7px solid var(--brass); }
.grid td.hours, .grid th.hours { min-width: 54px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.grid td.hours.over { color: var(--danger); background: var(--danger-soft); }
.grid th.person.over { background: var(--danger-soft); }
.grid th.person.over .pname { color: var(--danger); }

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 14px; font-size: .78rem; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend .badge { min-width: 22px; height: 18px; font-size: .7rem; }
.lg-changed::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }

.days { display: grid; gap: 12px; }
@media (min-width: 760px) { .days { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .days { grid-template-columns: repeat(3, 1fr); } }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.day.today { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass-soft), var(--shadow); }
.day header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.day h3 { font: 600 1.02rem var(--serif); }
.day-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.day-list li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 10px; padding: 7px 4px; border-radius: 8px; }
.day-list li.editable { cursor: pointer; }
.day-list li.editable:hover { background: var(--surface-2); }
.day-list li.me { background: var(--brass-soft); }
.day-list .who { font-weight: 600; }
.day-list .who em { color: var(--brass); font-style: normal; font-weight: 600; }
.day-list .when { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.day-list .note { grid-column: 2 / -1; font-size: .78rem; color: var(--brass); }
.day .off, .day .unset { margin: 8px 0 0; font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.day .unset { color: var(--warn); }
.day .off .editable, .day .unset .editable { cursor: pointer; text-decoration: underline dotted; }

/* ---------- Pannello dal basso ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgb(10 14 22 / 45%); display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .18s;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 30px rgb(0 0 0 / 20%);
  transform: translateY(24px); transition: transform .2s ease-out; padding-bottom: env(safe-area-inset-bottom);
}
.sheet-backdrop.open .sheet { transform: none; }
@media (min-width: 720px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 18px; }
  .sheet-grip { display: none; }
}
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 6px 18px; }
.sheet-head h2 { font: 600 1.1rem var(--serif); }
.sheet-body { padding: 6px 18px 12px; overflow-y: auto; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.sheet-actions .btn { flex: 1; }
@media (min-width: 720px) { .sheet-actions .btn { flex: none; } }

.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.tpl {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 4px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: .82rem; font-weight: 600;
}
.tpl small { color: var(--muted); font-weight: 500; font-size: .7rem; }
.tpl:hover { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, var(--surface)); }
.custom { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 0; margin-bottom: 14px; }
.custom summary { cursor: pointer; font-weight: 600; padding-bottom: 10px; color: var(--ink); }
.repeat { border: 0; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.repeat legend { font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.daychip input { position: absolute; opacity: 0; }
.daychip span { display: inline-grid; place-items: center; min-width: 46px; height: 36px; border-radius: 9px; border: 1px solid var(--line); cursor: pointer; font-weight: 600; font-size: .82rem; }
.daychip input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.daychip input:focus-visible + span { outline: 2.5px solid var(--brass); outline-offset: 2px; }
.daychip.disabled span { opacity: .35; cursor: not-allowed; }

.radio-cards { display: grid; gap: 8px; margin: 14px 0; }
.radio-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--brass); background: var(--brass-soft); }
.radio-card.disabled { opacity: .5; cursor: not-allowed; }
.radio-card .why { color: var(--warn); font-size: .76rem; }
.radio-card input { accent-color: var(--brass); width: 18px; height: 18px; }
.radio-card span { display: flex; flex-direction: column; }
.radio-card small { color: var(--muted); }

/* ---------- I miei turni ---------- */
.mine h1 { margin-bottom: 14px; }
.hero {
  display: grid; gap: 2px; padding: 18px; border-radius: 18px; margin-bottom: 18px; color: #fff;
  background: linear-gradient(135deg, var(--c, #14213d), color-mix(in srgb, var(--c, #14213d) 65%, #000));
  box-shadow: var(--shadow);
}
.hero.empty-hero { --c: #475569; }
.hero-k { font-size: .72rem; text-transform: uppercase; letter-spacing: 1.2px; opacity: .8; font-weight: 700; }
.hero-when { font: 600 1.35rem var(--serif); }
.hero-time { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero-dept { opacity: .9; font-size: .88rem; }
.mine-week { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow); }
.mine-week header { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 14px; background: var(--surface-2); }
.mine-week h2 { font-size: .9rem; }
.mine-week ul { list-style: none; margin: 0; padding: 0; }
.mine-week li { display: grid; grid-template-columns: 62px auto 1fr auto; align-items: center; gap: 10px; padding: 9px 14px; border-top: 1px solid var(--line); }
.mine-week li.today { background: var(--today); }
.mine-week li.past { opacity: .5; }
.mine-week .md { font-size: .85rem; }
.mine-week .mt { font-variant-numeric: tabular-nums; display: flex; flex-direction: column; }
.mine-week .mt small { color: var(--brass); font-size: .75rem; }
.mine-week .mdpt { font-size: .72rem; color: var(--muted); font-weight: 700; }

/* ---------- Approvazioni ---------- */
.approvals h1 { margin-bottom: 14px; }
.ap-group { margin-bottom: 22px; }
.ap-group h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--surface-2); font-size: .75rem; color: var(--muted); }
.ap-card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--st-draft); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.ap-card.st-pending { border-left-color: var(--st-pending); }
.ap-card.st-approved { border-left-color: var(--st-approved); }
.ap-card.st-published { border-left-color: var(--st-published); }
.ap-card.st-rejected { border-left-color: var(--st-rejected); }
.ap-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.ap-top > div { display: flex; flex-direction: column; line-height: 1.25; }
.ap-meta { list-style: none; margin: 8px 0; padding: 0; font-size: .82rem; color: var(--muted); display: grid; gap: 2px; }
.ap-meta .q { color: var(--text); font-style: italic; }
.ap-meta .q.rej { color: var(--danger); }
.ap-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

/* ---------- Utenti ---------- */
.filters { display: grid; gap: 8px; margin-bottom: 12px; }
@media (min-width: 720px) { .filters { grid-template-columns: 2fr 1fr 1fr; } }
.user-list { display: grid; gap: 6px; }
.user-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.user-row:hover { border-color: var(--brass); }
.user-row.inactive { opacity: .55; }
.avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); font-weight: 700; color: var(--ink); font-size: .85rem; }
.avatar.r-director { background: var(--brass-soft); color: var(--brass); }
.avatar.r-manager { background: color-mix(in srgb, var(--st-approved) 14%, transparent); color: var(--st-approved); }
.u-main, .u-side { display: flex; flex-direction: column; min-width: 0; }
.u-main small, .u-side small { color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-side { align-items: flex-end; gap: 3px; }
.deps { border: 0; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.deps legend { font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.check { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: .85rem; }
.check:has(input:checked) { border-color: var(--brass); background: var(--brass-soft); }
.check input { accent-color: var(--brass); width: 17px; height: 17px; flex: none; }
.row-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.creds dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; background: var(--surface-2); padding: 14px; border-radius: 12px; }
.creds dt { color: var(--muted); }
.creds dd { margin: 0; font-weight: 700; }
.creds code { font-size: 1.05rem; letter-spacing: .5px; }

/* ---------- Impostazioni / Storico / Altro ---------- */
.settings h1, .more h1 { margin-bottom: 14px; }
.tpl-list, .dep-list { list-style: none; margin: 0; padding: 0; }
.tpl-list li, .dep-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.grow { flex: 1; min-width: 0; }
.hist-dept { margin-bottom: 8px; }
.hist-list { list-style: none; margin: 10px 0 0; padding: 0; }
.hist-list li { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line); font-size: .86rem; }
.hist-list time { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.hist-list .dept-code { min-width: 34px; height: 20px; font-size: .66rem; }
.hist-list .h-approve span strong:first-of-type, .hist-list .h-publish span strong:first-of-type { color: var(--st-published); }
.hist-list .h-reject span strong:first-of-type { color: var(--danger); }
.profile-card { display: flex; align-items: center; gap: 14px; }
.profile-card div { display: flex; flex-direction: column; }
.profile-card small { color: var(--muted); }
.menu { display: grid; gap: 6px; }
.menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item .ico { color: var(--brass); }
.menu-item span { display: flex; flex-direction: column; }
.menu-item small { color: var(--muted); font-size: .78rem; }
.menu-item.danger, .menu-item.danger .ico { color: var(--danger); }
.steps { padding-left: 20px; line-height: 1.8; }

/* ---------- Daily Overview ---------- */
.daily-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.kicker { display: block; color: var(--brass); font-size: .72rem; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; }
.daily-title h1 { text-transform: none; }
.daily-nav { display: flex; align-items: center; gap: 4px; position: relative; }
.date-input { position: absolute; left: 44px; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dp-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 6px; margin-bottom: 8px; }
.dp-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; }
.dp-stat strong { font: 600 1.6rem/1.1 var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; }
.dp-stat span { font-size: .72rem; color: var(--muted); line-height: 1.2; }
.dp-stat.live strong { color: var(--st-published); }
.dp-stat.warn strong { color: var(--warn); }
.dp-absent-total { margin: 0 0 8px; }
.dp-jump { margin: 4px -16px 14px; }
.chip-n { opacity: .6; font-weight: 600; margin-left: 2px; }
.dp-grid { display: grid; gap: 12px; }
@media (min-width: 900px) { .dp-grid { grid-template-columns: repeat(2, 1fr); align-items: start; } }
.dp-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); scroll-margin-top: 80px; }
.dp-head { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; }
.dp-name { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.dp-name small { color: var(--muted); font-size: .78rem; }
.dp-axis { position: relative; height: 14px; margin: 12px 0 2px; font-size: .64rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.dp-axis span { position: absolute; transform: translateX(-50%); }
.dp-axis span:first-child { transform: none; }
.dp-axis span:last-child { transform: translateX(-100%); }
.dp-list { list-style: none; margin: 0; padding: 0; }
.dp-row { padding: 8px 0 9px; border-top: 1px solid var(--line); }
.dp-row:first-child { border-top: 0; }
.dp-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 10px; }
.dp-top .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.dp-top .who small { color: var(--muted); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-top .when { text-align: right; font-size: .84rem; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1.3; }
.dp-top .when small { color: var(--muted); font-size: .7rem; }
.live-tag { color: var(--st-published); font-weight: 700; }
.live-tag::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 4px; vertical-align: 1px; }
.dp-card.empty-dep { padding: 8px 14px; box-shadow: none; }
.dp-card.empty-dep .dp-name strong { color: var(--muted); }
.dp-note { margin: 4px 0 0 36px; font-size: .76rem; color: var(--brass); }
.track { position: relative; height: 6px; margin: 7px 0 0; border-radius: 3px; background: var(--surface-2);
  background-image: linear-gradient(90deg, transparent calc(25% - .5px), var(--line) calc(25% - .5px), var(--line) calc(25% + .5px), transparent calc(25% + .5px), transparent calc(50% - .5px), var(--line) calc(50% - .5px), var(--line) calc(50% + .5px), transparent calc(50% + .5px), transparent calc(75% - .5px), var(--line) calc(75% - .5px), var(--line) calc(75% + .5px), transparent calc(75% + .5px)); }
.track .seg { position: absolute; top: 0; bottom: 0; border-radius: 3px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.track .nowline { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--danger); border-radius: 1px; }
.dp-none { margin: 10px 0 2px; }
.dp-absent, .dp-unset { margin: 8px 0 0; font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 14px; }
.dp-absent b, .dp-unset b { color: var(--text); font-weight: 650; margin-right: 4px; }
.dp-unset, .dp-unset b { color: var(--warn); }
/* ---------- Presenze (ufficio paghe) ---------- */
.presenze .month-nav { display: flex; align-items: center; justify-content: space-between; padding: 6px; margin-bottom: 14px; }
.presenze .month-label { font: 600 1.1rem/1.2 var(--serif); color: var(--ink); }
.presenze .banner { margin-bottom: 14px; align-items: flex-start; }
.presenze .banner > .ico { margin-top: 2px; flex: none; }
.presenze .banner-text small { display: block; margin-top: 4px; }
.pres-checks { margin: 6px 0 0; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.pres-checks .dept-code { height: 22px; min-width: 36px; margin-right: 4px; }
.pres-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.pres-stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.pres-stats small { display: block; color: var(--muted); font-size: .76rem; }
.pres-stats strong { font: 600 1.25rem/1.25 var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; }
@media (min-width: 720px) { .pres-stats { grid-template-columns: repeat(6, 1fr); } }
.pres-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 4px 0 14px; }
.pres-actions small { flex-basis: 100%; }
@media (min-width: 720px) { .pres-actions small { flex-basis: auto; } }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 12px; }
.pres-table { border-collapse: collapse; width: 100%; font-size: .86rem; font-variant-numeric: tabular-nums; }
.pres-table th, .pres-table td { padding: 8px 8px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.pres-table th { font-size: .74rem; color: var(--muted); font-weight: 650; background: var(--surface-2); position: sticky; top: 0; }
.pres-table .l { text-align: left; position: sticky; left: 0; background: var(--surface); min-width: 150px; max-width: 200px; white-space: normal; }
.pres-table th.l { background: var(--surface-2); z-index: 1; }
.pres-table td.l small { display: block; color: var(--muted); font-size: .74rem; }
.pres-table td.b { font-weight: 700; color: var(--ink); }
.pres-table td.warn { background: var(--warn-soft); color: var(--warn); font-weight: 700; }
.pres-table tbody tr:last-child td { border-bottom: 0; }

@media print {
  .daily-nav, .dp-jump, .dp-head .icon-btn, .dp-stat.live, .track .nowline { display: none !important; }
  .dp-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dp-card { box-shadow: none; break-inside: avoid; padding: 8px 10px; }
  .dp-summary { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); z-index: 200;
  transform: translate(-50%, -20px); opacity: 0; pointer-events: none; transition: all .2s;
  max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 12px; background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: .9rem; box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); color: #fff; }

/* ---------- Stampa ---------- */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; color: #000; font-size: 11px; }
  .topbar, .tabbar, .toolbar .chips, .weeknav button.icon-btn, .view-toggle, .banners, #toast { display: none !important; }
  main#view { padding: 0 !important; max-width: none; }
  .toolbar, .weeknav { border: 0; padding: 0; }
  .week-label { font-size: 13px; padding: 0; text-align: left; }
  .grid-wrap { overflow: visible; box-shadow: none; border-color: #999; }
  .grid { min-width: 0; font-size: 10px; }
  .grid .person, .grid .corner, .grid thead th { position: static; box-shadow: none; }
  .grid th, .grid td { border-color: #999; }
  .grid td { height: 38px; }
  .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .day, .mine-week { box-shadow: none; break-inside: avoid; }
}

/* Nome dell'app nella schermata di accesso */
.login-card .app-name { color: var(--brass); font-weight: 700; letter-spacing: .3px; }
