:root {
  --bg:#f4f7fb; --card:#ffffff; --line:#dfe7f1; --text:#1f2937; --muted:#6b7280;
  --primary:#0ea5e9; --primary-dark:#0284c7; --ok:#16a34a; --danger:#dc2626;
  --soft:#eef6ff; --warn:#f59e0b; --shadow:0 8px 24px rgba(15,23,42,.08); --radius:14px;
}
*{box-sizing:border-box}
body{margin:0;font-family:system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;background:var(--bg);color:var(--text)}
.wrap{max-width:1120px;margin:0 auto;padding:16px}
.topbar,.panel{background:var(--card);border-radius:var(--radius);box-shadow:var(--shadow);padding:14px}
.topbar{margin-bottom:14px}
.topbar h1{margin:4px 0 6px;font-size:1.5rem}
.home-link{display:inline-flex;align-items:center;margin-bottom:4px;color:var(--primary-dark);text-decoration:none;font-weight:700;font-size:.9rem}
.home-link:hover{text-decoration:underline}
.topbar-sub{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.muted{color:var(--muted)}
.grid{display:grid;gap:14px;grid-template-columns:1.15fr 0.85fr}
.section-title{margin:0 0 12px;font-size:1rem;display:flex;align-items:center;justify-content:space-between;gap:8px}
.meta-grid{display:grid;grid-template-columns:1fr 1fr 1fr auto;gap:10px;margin-bottom:12px}
.admin-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.search-row,.admin-grid{margin-bottom:12px}
label{display:block;font-size:.85rem;color:var(--muted);margin-bottom:6px}
input[type=text],input[type=date],input[type=number],textarea,select{
  width:100%;border:1px solid var(--line);border-radius:10px;padding:10px 12px;font-size:16px;
  background:#fff;color:var(--text);-webkit-appearance:none;appearance:none}
textarea{min-height:42px;resize:vertical}
.toolbar{display:flex;flex-wrap:wrap;gap:8px;margin:12px 0 0}
button{border:0;border-radius:10px;padding:10px 14px;font-size:.95rem;cursor:pointer;transition:.15s ease}
button:hover{transform:translateY(-1px)}
button:disabled{opacity:.55;cursor:not-allowed;transform:none}
.btn-primary{background:var(--primary);color:#fff}
.btn-primary:hover:not(:disabled){background:var(--primary-dark)}
.btn-soft{background:var(--soft);color:var(--primary-dark)}
.btn-ok{background:var(--ok);color:#fff}
.btn-danger{background:var(--danger);color:#fff}
.btn-warn{background:var(--warn);color:#fff}
details.company,details.admin-box{border:1px solid var(--line);border-radius:12px;margin-bottom:10px;overflow:hidden;background:#fff}
details.company[open] summary,details.admin-box[open] summary{background:var(--soft)}
summary{list-style:none;padding:12px;cursor:pointer;display:flex;align-items:center;justify-content:space-between;gap:10px;font-weight:700;position:relative}
summary::-webkit-details-marker{display:none}
summary::before{content:'▸';color:var(--primary-dark);font-size:1rem;margin-right:2px}
details[open] > summary::before{content:'▾'}
.sum-left,.sum-right{display:flex;align-items:center;gap:8px}
.badge{background:var(--primary);color:#fff;border-radius:999px;padding:3px 9px;font-size:.75rem;font-weight:700}
.mini-btn{padding:6px 10px;font-size:.8rem;border-radius:999px;background:var(--soft);color:var(--primary-dark);text-decoration:none;border:0;display:inline-flex;align-items:center}
.worker{padding:12px;border-top:1px solid var(--line)}
.worker.hidden{display:none}
.worker-head{display:flex;align-items:center;gap:10px}
.worker-head input[type=checkbox]{width:20px;height:20px;accent-color:var(--primary);flex:0 0 auto}
.worker-name{flex:1;font-weight:600}
.preview-card{border:1px solid var(--line);border-radius:16px;background:linear-gradient(180deg,#fff 0,#fbfdff 100%);padding:18px;min-height:320px;box-shadow:0 10px 26px rgba(15,23,42,.06)}
.report-header{text-align:left;border:1px solid var(--line);background:var(--soft);border-radius:14px;padding:14px;margin-bottom:14px}
.report-header h2{margin:0 0 6px;font-size:1.28rem;color:var(--text)}
.total-highlight{margin-top:10px;display:flex;align-items:center;padding:7px 11px;border-radius:12px;background:#eef6ff;border:1px solid #bfe7fb;color:var(--primary-dark);font-size:.88rem;font-weight:600}
.total-highlight strong{font-size:.92rem;font-weight:700;color:#0284c7;margin-left:auto}
.company-block{margin-bottom:14px;border:1px solid var(--line);border-radius:14px;background:#fff;overflow:hidden}
.company-block h3{margin:0;padding:10px 12px;background:var(--soft);border-bottom:1px solid var(--line);font-size:.96rem;display:flex;align-items:center;justify-content:space-between;gap:10px}
.section-title-row{display:flex;align-items:center;gap:10px;min-width:0}
.report-count{display:inline-flex;align-items:center;justify-content:center;min-width:28px;height:28px;padding:0 10px;border-radius:999px;background:var(--primary);color:#fff;font-size:.8rem;font-weight:700;flex:0 0 auto}
.simple-row{border-bottom:1px solid var(--line);padding:10px 12px;display:flex;align-items:center;gap:10px;font-size:1rem;color:var(--text);background:transparent}
.simple-row:last-child{border-bottom:0}
.simple-check{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;font-size:.95rem;font-weight:500;flex:0 0 auto}
.empty{color:var(--muted);text-align:center;padding:30px 10px}
.tiny{font-size:.82rem;color:var(--muted)}
.footer-note{margin-top:8px;font-size:.8rem;color:var(--muted);text-align:center}
.admin-body{padding:12px;border-top:1px solid var(--line)}
.admin-list{display:grid;gap:10px}
.admin-company-card{border:1px solid var(--line);border-radius:12px;padding:10px;background:#fff}
.admin-company-head{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-bottom:8px}
.admin-workers{display:flex;flex-wrap:wrap;gap:8px}
.chip{display:inline-flex;align-items:center;gap:8px;border-radius:999px;padding:7px 10px;background:var(--soft);color:var(--text);font-size:.88rem}
.chip button{padding:0;width:22px;height:22px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;background:#fff;border:1px solid var(--line);color:var(--danger);cursor:pointer}
.status-line{margin-top:8px;font-size:.85rem;color:var(--muted);min-height:1.4em}
.sync-badge{display:inline-flex;align-items:center;gap:5px;border-radius:999px;padding:3px 10px;font-size:.75rem;font-weight:700;margin-left:4px}
.sync-badge.ok{background:#dcfce7;color:#166534;border:1px solid #bbf7d0}
.sync-badge.warn{background:#fef3c7;color:#92400e;border:1px solid #fde68a}
.sync-badge.err{background:#fee2e2;color:#991b1b;border:1px solid #fca5a5}
.sync-dot{width:7px;height:7px;border-radius:50%;background:currentColor;display:inline-block}
.helper-box{border:1px dashed #c7d8ea;border-radius:12px;padding:10px 12px;background:#fbfdff;margin-bottom:12px}
.helper-box strong{display:block;margin-bottom:6px}
.settings-toggle{}
.settings-panel.hidden{display:none}
.hidden{display:none!important}
.settings-panel{margin-bottom:14px;border:1px solid #bfdbfe}
details.admin-box > summary,
details.company > summary{background:#dbeafe;border-bottom:1px solid #bfdbfe}
details.admin-box[open] > summary,
details.company[open] > summary{background:#eef6ff}
details.admin-box{border-color:#bfdbfe}
details.company{border-color:#d7e7f7}
.settings-panel details.admin-box{margin-bottom:12px}

.linklike{background:none;border:0;color:var(--primary-dark);padding:0;cursor:pointer;font:inherit}
@media(max-width:860px){.grid{grid-template-columns:1fr}.meta-grid,.admin-grid{grid-template-columns:1fr 1fr}}
@media(max-width:560px){
  .wrap{padding:10px}.panel,.topbar{padding:12px;border-radius:12px}
  .meta-grid,.admin-grid{grid-template-columns:1fr}
  .company-block h3{align-items:center}
  button{width:100%}
  .toolbar{flex-direction:column}
  .sum-right{flex-wrap:wrap;justify-content:flex-end}
  .admin-company-head{align-items:flex-start;flex-direction:column}
}
@media print{
  body{background:#fff}
  .topbar,.editor-panel,.toolbar,.footer-note,.right-actions,.admin-box,.status-line,.helper-box{display:none!important}
  .grid{display:block}
  .panel{box-shadow:none;border:0;padding:0}
  .preview-card{border:0}
}



.roster-meta{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
  margin:8px 0 12px;
}
.roster-pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.06);
}
.roster-pill.mode-assigned_personale{background:rgba(16,185,129,.16);border-color:rgba(16,185,129,.35)}
.roster-pill.mode-assigned_aziende{background:rgba(59,130,246,.16);border-color:rgba(59,130,246,.35)}
.roster-pill.mode-legacy_all_active{background:rgba(245,158,11,.16);border-color:rgba(245,158,11,.35)}
.roster-pill.mode-config,
.roster-pill.mode-config_fallback{background:rgba(168,85,247,.16);border-color:rgba(168,85,247,.35)}



/* ui_cleanup_light_20260418 */
#syncDetail,
.footer-note,
.section-title .right-actions,
details.admin-box summary .tiny,
details.company summary .tiny {
  display:none !important;
}

#saveDayBtn {
  min-width:220px;
  font-weight:800;
  box-shadow:0 10px 22px rgba(2,132,199,.18);
}

#saveDayBtn:hover:not(:disabled) {
  transform:translateY(-1px) scale(1.01);
}

#openDayBtn {
  font-weight:700;
}

.roster-meta {
  margin:10px 0 14px;
}

#dayStatus {
  font-size:.9rem;
}


/* presenze_ui_safe_v1_20260419 */
.day-actions {
  display:grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap:10px;
  align-items:stretch;
}

.day-actions > button {
  width:100%;
  min-height:54px;
  font-weight:800;
  border:0;
  color:#fff;
  box-shadow:0 10px 22px rgba(15,23,42,.10);
}

#saveDayBtn {
  background:linear-gradient(135deg,#16a34a 0%,#22c55e 100%) !important;
}

#resetBtn {
  background:linear-gradient(135deg,#dc2626 0%,#ef4444 100%) !important;
}

#downloadSimpleBtn {
  background:linear-gradient(135deg,#2563eb 0%,#0ea5e9 100%) !important;
}

#shareSimpleBtn {
  display:none !important;
}

#dayStatus {
  color:#475569;
  font-size:.95rem;
  line-height:1.45;
}

@media(max-width:860px) {
  .day-actions {
    grid-template-columns:1fr;
  }
}


/* PRESENZE_TOPBAR_RM_STYLE_V1 */
:root {
  --presenze-topbar-accent: var(--primary);
  --presenze-topbar-accent-dark: var(--primary-dark);
  --presenze-topbar-soft: var(--soft);
}

.topbar.presenze-topbar {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px 16px;
  padding: 16px 18px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.96) 0%, rgba(255,255,255,.90) 100%);
  box-shadow: 0 12px 28px rgba(15,23,42,.08);
  overflow: hidden;
}

.topbar.presenze-topbar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--presenze-topbar-accent-dark) 0%, var(--presenze-topbar-accent) 100%);
  opacity: .95;
}

.topbar.presenze-topbar h1 {
  margin: 0;
  font-size: 1.34rem;
  line-height: 1.08;
  letter-spacing: -.02em;
}

.topbar-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.topbar-heading {
  min-width: 0;
}

.topbar-subtitle {
  margin-top: 4px;
  font-size: .92rem;
  color: var(--muted);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-home {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: auto;
  margin: 0;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--presenze-topbar-accent-dark);
  background: linear-gradient(135deg, var(--presenze-topbar-soft) 0%, #ffffff 100%);
  color: var(--presenze-topbar-accent-dark);
  box-shadow: 0 8px 20px rgba(15,23,42,.08);
  text-decoration: none;
  font-weight: 700;
  font-size: .92rem;
}

.topbar-home .home-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  color: inherit;
  font-size: .92rem;
  line-height: 1;
}

.topbar-home:hover {
  background: linear-gradient(135deg, var(--presenze-topbar-accent-dark) 0%, var(--presenze-topbar-accent) 100%);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(2,132,199,.20);
  transform: translateY(-1px);
  text-decoration: none;
}

.topbar-home:hover .home-link-icon {
  background: rgba(255,255,255,.18);
  color: #ffffff;
}

.theme-toggle-btn {
  min-width: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

html[data-theme="dark"] {
  --bg: #0b1220;
  --card: #111827;
  --line: #223046;
  --text: #e5edf8;
  --muted: #9fb0c7;
  --soft: #0f1f35;
  --shadow: 0 12px 28px rgba(0,0,0,.34);
}

html[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}

html[data-theme="dark"] .topbar,
html[data-theme="dark"] .panel,
html[data-theme="dark"] details.company,
html[data-theme="dark"] details.admin-box,
html[data-theme="dark"] .preview-card,
html[data-theme="dark"] .company-block,
html[data-theme="dark"] .admin-company-card {
  background: var(--card);
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] .topbar.presenze-topbar {
  background: linear-gradient(180deg, rgba(17,24,39,.98) 0%, rgba(17,24,39,.94) 100%);
  box-shadow: 0 14px 32px rgba(0,0,0,.34);
}

html[data-theme="dark"] .report-header,
html[data-theme="dark"] .company-block h3,
html[data-theme="dark"] details.admin-box > summary,
html[data-theme="dark"] details.company > summary,
html[data-theme="dark"] .helper-box,
html[data-theme="dark"] .btn-soft,
html[data-theme="dark"] .chip {
  background: var(--soft);
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] .home-link,
html[data-theme="dark"] .topbar-subtitle,
html[data-theme="dark"] .muted,
html[data-theme="dark"] .tiny,
html[data-theme="dark"] .footer-note,
html[data-theme="dark"] label,
html[data-theme="dark"] .empty,
html[data-theme="dark"] .status-line {
  color: var(--muted);
}

html[data-theme="dark"] input[type=text],
html[data-theme="dark"] input[type=date],
html[data-theme="dark"] input[type=number],
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background: #0d1728;
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] .topbar-home {
  background: linear-gradient(135deg, rgba(14,165,233,.14) 0%, rgba(17,24,39,.92) 100%);
  color: #dbeafe;
  border-color: var(--presenze-topbar-accent);
}

html[data-theme="dark"] .topbar-home .home-link-icon {
  background: rgba(255,255,255,.10);
}

html[data-theme="dark"] .topbar-home:hover {
  color: #ffffff;
}

html[data-theme="dark"] .sync-badge.ok {
  background: rgba(22,163,74,.18);
  color: #bbf7d0;
  border-color: rgba(34,197,94,.30);
}

html[data-theme="dark"] .sync-badge.warn {
  background: rgba(245,158,11,.16);
  color: #fde68a;
  border-color: rgba(245,158,11,.30);
}

html[data-theme="dark"] .sync-badge.err {
  background: rgba(220,38,38,.16);
  color: #fecaca;
  border-color: rgba(239,68,68,.30);
}

@media (max-width: 860px) {
  .topbar.presenze-topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar-home {
    justify-self: start;
  }

  .topbar-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 560px) {
  .topbar.presenze-topbar {
    padding: 14px;
    gap: 12px;
  }

  .topbar.presenze-topbar h1 {
    font-size: 1.18rem;
  }

  .topbar-subtitle {
    font-size: .84rem;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .theme-toggle-btn,
  .topbar-actions .settings-toggle {
    width: auto;
  }
}


/* PRESENZE_TOPBAR_RM_STYLE_V1_REFINED */
.topbar.presenze-topbar {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px 18px;
  padding: 16px 18px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(255,255,255,.92) 100%);
  box-shadow: 0 12px 28px rgba(15,23,42,.08);
  overflow: hidden;
}

.topbar.presenze-topbar::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  opacity: .95;
}

.topbar-left,
.topbar-center,
.topbar-right {
  min-width: 0;
}

.topbar-center {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topbar-title-wrap h1 {
  margin: 0;
  font-size: 1.34rem;
  line-height: 1.06;
  letter-spacing: -.02em;
}

.topbar-subtitle {
  margin-top: 4px;
  font-size: .92rem;
  color: var(--muted);
}

.topbar-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-home-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: auto;
  margin: 0;
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid rgba(2,132,199,.28);
  background: linear-gradient(135deg, rgba(239,246,255,.96) 0%, rgba(255,255,255,.98) 100%);
  color: var(--primary-dark);
  box-shadow: 0 8px 20px rgba(15,23,42,.08);
  text-decoration: none;
  transition: .18s ease;
}

.topbar-home-mark {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.78);
  box-shadow: inset 0 0 0 1px rgba(2,132,199,.10);
  font-size: 1rem;
  line-height: 1;
  flex: 0 0 auto;
}

.topbar-home-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.05;
}

.topbar-home-overline {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .75;
}

.topbar-home-label {
  font-size: .95rem;
  font-weight: 800;
}

.topbar-home-badge:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(2,132,199,.22);
  text-decoration: none;
}

.topbar-home-badge:hover .topbar-home-mark {
  background: rgba(255,255,255,.16);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}

.theme-toggle-btn {
  min-width: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.topbar-right .settings-toggle,
.theme-toggle-btn {
  box-shadow: 0 8px 18px rgba(15,23,42,.08);
}

html[data-theme="dark"] .topbar.presenze-topbar {
  background: linear-gradient(180deg, rgba(17,24,39,.98) 0%, rgba(17,24,39,.94) 100%);
  box-shadow: 0 14px 32px rgba(0,0,0,.34);
}

html[data-theme="dark"] .topbar-home-badge {
  background: linear-gradient(135deg, rgba(14,165,233,.14) 0%, rgba(17,24,39,.92) 100%);
  color: #dbeafe;
  border-color: rgba(14,165,233,.34);
}

html[data-theme="dark"] .topbar-home-mark {
  background: rgba(255,255,255,.10);
}

html[data-theme="dark"] .topbar-home-badge:hover {
  color: #fff;
}

@media (max-width: 860px) {
  .topbar.presenze-topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 12px;
  }

  .topbar-right {
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  .topbar.presenze-topbar {
    padding: 14px;
  }

  .topbar-title-wrap h1 {
    font-size: 1.18rem;
  }

  .topbar-subtitle {
    font-size: .84rem;
  }

  .topbar-home-badge {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-right .settings-toggle,
  .theme-toggle-btn {
    width: auto;
  }
}


/* PRESENZE_TOPBAR_RM_STYLE_V1_FINAL */
.topbar.presenze-topbar,
.header.rm-topbar.presenze-topbar {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  height: auto !important;
  z-index: auto !important;
  padding: 0 !important;
  margin-bottom: 14px !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 7%, transparent), transparent 62%),
    color-mix(in srgb, var(--card) 96%, white) !important;
  box-shadow: 0 12px 28px rgba(15,23,42,.08) !important;
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.header.rm-topbar.presenze-topbar::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  opacity: .95;
}

.header.rm-topbar.presenze-topbar .rm-topbar-inner {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
  padding: 0.95rem 1rem;
}

.header.rm-topbar.presenze-topbar .rm-topbar-logo.presenze-topbar-logo {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--soft) 88%, white), color-mix(in srgb, var(--card) 92%, white));
  border: 1.5px solid color-mix(in srgb, var(--primary) 28%, var(--line));
  box-shadow: 0 8px 20px rgba(15,23,42,.08);
  text-decoration: none;
  transition:
    transform .18s ease,
    box-shadow .18s ease,
    background .18s ease,
    color .18s ease,
    border-color .18s ease;
}

.header.rm-topbar.presenze-topbar .rm-topbar-logo.presenze-topbar-logo:hover {
  transform: translateY(-1px);
  color: #fff;
  background:
    linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 78%, #0f172a));
  border-color: color-mix(in srgb, var(--primary) 80%, white);
  box-shadow: 0 13px 28px color-mix(in srgb, var(--primary) 28%, rgba(15,23,42,.18));
  text-decoration: none;
}

.header.rm-topbar.presenze-topbar .rm-topbar-title.presenze-topbar-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.header.rm-topbar.presenze-topbar .rm-topbar-title.presenze-topbar-title b {
  font-size: 1.02rem;
  font-weight: 780;
  letter-spacing: -0.025em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header.rm-topbar.presenze-topbar .rm-topbar-title.presenze-topbar-title small {
  margin-top: 0.18rem;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header.rm-topbar.presenze-topbar .rm-topbar-actions.presenze-topbar-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  min-width: 0;
}

.header.rm-topbar.presenze-topbar .sync-badge {
  height: 34px;
  white-space: nowrap;
  margin-left: 0;
}

.header.rm-topbar.presenze-topbar .rm-theme-toggle,
.header.rm-topbar.presenze-topbar .theme-toggle-btn {
  min-width: 42px;
  width: 42px;
  height: 38px;
  border-radius: 14px;
  padding: 0;
  border-color: color-mix(in srgb, var(--primary) 24%, var(--line));
  background: color-mix(in srgb, var(--soft) 52%, var(--card));
  color: var(--primary-dark);
  box-shadow: 0 6px 16px rgba(15,23,42,.06);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.header.rm-topbar.presenze-topbar .rm-theme-toggle:hover,
.header.rm-topbar.presenze-topbar .theme-toggle-btn:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 18%, transparent);
}

.header.rm-topbar.presenze-topbar #syncDetail {
  display: none !important;
}

html[data-theme="dark"] .header.rm-topbar.presenze-topbar {
  background:
    radial-gradient(circle at 24px 20px, color-mix(in srgb, var(--primary) 16%, transparent), transparent 34px),
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 9%, transparent), transparent 62%),
    color-mix(in srgb, var(--card) 94%, #020617) !important;
  border-color: color-mix(in srgb, var(--primary) 26%, var(--line)) !important;
  box-shadow: 0 12px 34px rgba(0,0,0,.34) !important;
}

html[data-theme="dark"] .header.rm-topbar.presenze-topbar .rm-topbar-logo.presenze-topbar-logo {
  color: #dbeafe;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 14%, transparent), color-mix(in srgb, var(--card) 96%, #020617));
  border-color: color-mix(in srgb, var(--primary) 34%, var(--line));
}

html[data-theme="dark"] .header.rm-topbar.presenze-topbar .rm-topbar-logo.presenze-topbar-logo:hover {
  color: #fff;
}

@media (max-width: 640px) {
  .header.rm-topbar.presenze-topbar .rm-topbar-inner {
    gap: 0.65rem;
    padding: 0.8rem 0.75rem;
  }

  .header.rm-topbar.presenze-topbar .rm-topbar-logo.presenze-topbar-logo {
    width: 42px;
    height: 42px;
    border-radius: 15px;
  }

  .header.rm-topbar.presenze-topbar .rm-topbar-title.presenze-topbar-title b {
    font-size: 0.94rem;
  }

  .header.rm-topbar.presenze-topbar .rm-topbar-title.presenze-topbar-title small {
    font-size: 0.7rem;
  }

  .header.rm-topbar.presenze-topbar .sync-badge {
    display: none;
  }
}

@media print {
  .header.rm-topbar.presenze-topbar {
    box-shadow: none !important;
    border: 0 !important;
  }
}


/* PRESENZE_EDITOR_STORICO_SWITCH_V1 */
.presenze-view-switch{
  display:flex;
  align-items:center;
  gap:10px;
  margin:0 0 14px;
  padding:4px;
  border:1px solid var(--line);
  background:color-mix(in srgb, var(--card) 96%, white);
  border-radius:999px;
  box-shadow:0 8px 20px rgba(15,23,42,.06);
  width:max-content;
  max-width:100%;
}

.presenze-view-chip{
  border:0;
  border-radius:999px;
  padding:9px 14px;
  background:transparent;
  color:var(--muted);
  font-size:.9rem;
  font-weight:700;
  line-height:1;
  box-shadow:none;
}

.presenze-view-chip:hover{
  transform:none;
  color:var(--text);
}

.presenze-view-chip.active{
  background:linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color:#fff;
  box-shadow:0 8px 18px rgba(2,132,199,.20);
}

#editorView{
  display:block;
}

#historyPanel{
  margin-top:0 !important;
}

#closeHistoryBtn{
  display:none !important;
}

@media (max-width:560px){
  .presenze-view-switch{
    width:100%;
    justify-content:space-between;
  }
}


/* PRESENZE_ACTIONS_LIGHTER_V1 */
#resetBtn,
#saveDayBtn,
#downloadSimpleBtn {
  min-height: 46px !important;
  padding: 9px 12px !important;
  font-size: .89rem !important;
  font-weight: 700 !important;
  border-radius: 12px !important;
  box-shadow: 0 5px 14px rgba(15,23,42,.07) !important;
  letter-spacing: 0 !important;
}

#resetBtn {
  background: linear-gradient(135deg, #ef4444 0%, #f87171 100%) !important;
}

#saveDayBtn {
  background: linear-gradient(135deg, #22c55e 0%, #4ade80 100%) !important;
}

#downloadSimpleBtn {
  background: linear-gradient(135deg, #38bdf8 0%, #60a5fa 100%) !important;
}

#resetBtn:hover:not(:disabled),
#saveDayBtn:hover:not(:disabled),
#downloadSimpleBtn:hover:not(:disabled) {
  transform: translateY(-1px) !important;
  box-shadow: 0 8px 18px rgba(15,23,42,.10) !important;
}

#resetBtn:disabled,
#saveDayBtn:disabled,
#downloadSimpleBtn:disabled {
  box-shadow: 0 3px 10px rgba(15,23,42,.05) !important;
}

@media (max-width: 560px) {
  #resetBtn,
  #saveDayBtn,
  #downloadSimpleBtn {
    min-height: 44px !important;
    font-size: .87rem !important;
  }
}
