/* ── Reset & Variables ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Blocca il bounce/overscroll che mostra il bianco dietro l'app */
html, body {
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
  height: 100%;
  overflow-x: hidden;
  max-width: 100vw;
}

/* iOS: previene auto-zoom al focus degli input (triggered quando font-size < 16px) */
@media (max-width: 768px) {
  input, select, textarea { font-size: 16px !important; }
}

:root {
  --wk:        #1AAFE6;
  --wk-d:      #0D8FBF;
  --wk-l:      #EBF8FF;
  --wk-ll:     #F0FAFF;
  --bg:        #F8FAFC;
  --surf:      #FFFFFF;
  --surf2:     #F1F5F9;
  --surf3:     #E2E8F0;
  --bdr:       #E2E8F0;
  --bdr2:      #CBD5E1;
  --txt:       #0F172A;
  --txt2:      #64748B;
  --txt3:      #94A3B8;
  --green:     #059669;
  --green-bg:  #F0FDF4;
  --amber:     #D97706;
  --amber-bg:  #FFFBEB;
  --red:       #DC2626;
  --red-bg:    #FEF2F2;
  --blue:      #2563EB;
  --blue-bg:   #EFF6FF;
  --purple:    #7C3AED;
  --purple-bg: #F5F3FF;
  --rad:       8px;
  --rad-sm:    5px;
  --sidebar-w: 220px;
  --sidebar-bg: #0F172A;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

body { background: var(--bg); color: var(--txt); min-height: 100vh; }

/* ── Layout ──────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; overflow-x: clip; }
.shell.has-sidebar .main-area { margin-left: var(--sidebar-w); }
.main-area { flex: 1; display: flex; flex-direction: column; min-height: 100vh; overflow-x: clip; }

/* ── Sidebar (dark) ──────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: none;
  position: fixed; top: 0; left: 0; height: 100vh;
  display: flex; flex-direction: column; z-index: 100; overflow: hidden;
  box-shadow: 1px 0 0 rgba(255,255,255,.05);
}

.sb-logo {
  padding: 9px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 9px;
  height: 52px; box-sizing: border-box;
}
.sb-logo-text { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -.3px; }

.sb-season {
  padding: 7px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.04);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sb-season-btn {
  flex-shrink: 0; background: transparent; border: none; cursor: pointer;
  color: rgba(255,255,255,.35); padding: 4px; border-radius: 6px; transition: all .15s;
  display: flex; align-items: center;
}
.sb-season-btn:hover { color: rgba(255,255,255,.8); background: rgba(255,255,255,.08); }
.sb-season-btn svg { width: 14px; height: 14px; }
.sb-season-label { font-size: 9px; font-weight: 600; color: rgba(255,255,255,.35); text-transform: uppercase; letter-spacing: .8px; }
.sb-season-val   { font-size: 14px; font-weight: 700; color: #fff; margin-top: 1px; }
.sb-project      { font-size: 11px; color: rgba(255,255,255,.45); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sb-nav { flex: 1; padding: 8px 8px; overflow-y: auto; }

.sb-sep {
  font-size: 9px; font-weight: 700; letter-spacing: .9px;
  text-transform: uppercase; color: rgba(255,255,255,.25);
  padding: 12px 8px 4px; margin-top: 2px;
}

.sb-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: var(--rad-sm); border: none;
  background: none; font-size: 13px; font-family: inherit;
  color: rgba(255,255,255,.55); cursor: pointer;
  text-align: left; transition: all .1s; margin-bottom: 1px;
}
.sb-item:hover  { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
.sb-item.active { background: rgba(26,175,230,.15); color: #1AAFE6; font-weight: 600; }

.sb-ico {
  width: 18px; height: 18px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; opacity: .85;
}
.sb-ico svg { width: 15px; height: 15px; }
.sb-item.active .sb-ico { opacity: 1; }

.sb-footer {
  padding: 12px 12px 14px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sb-user {
  display: flex; align-items: center; gap: 9px; margin-bottom: 10px;
  width: 100%; background: transparent; border: none; border-radius: var(--rad-sm);
  padding: 6px 6px; cursor: pointer; text-align: left; transition: background .15s;
}
.sb-user:hover { background: rgba(255,255,255,.07); }
.sb-user-name { font-size: 13px; font-weight: 600; color: #fff; }
.sb-user-role { font-size: 11px; color: rgba(255,255,255,.4); }
.sb-logout {
  display: flex; align-items: center; gap: 7px; width: 100%;
  padding: 7px 10px; border-radius: var(--rad-sm); border: none;
  background: rgba(255,255,255,.06); font-size: 12px; font-family: inherit;
  color: rgba(255,255,255,.5); cursor: pointer; transition: all .1s;
}
.sb-logout:hover { background: rgba(255,255,255,.1); color: rgba(255,255,255,.8); }
.sb-logout svg { width: 14px; height: 14px; }
.sb-config-btn {
  display: flex; align-items: center; gap: 7px; width: 100%;
  margin-top: 4px; padding: 6px 10px; border-radius: var(--rad-sm); border: none;
  background: transparent; font-size: 11px; font-family: inherit;
  color: rgba(255,255,255,.3); cursor: pointer; transition: all .1s;
}
.sb-config-btn:hover { color: rgba(255,255,255,.7); }
.sb-config-btn svg { width: 12px; height: 12px; }

/* ── Avatar (works on both light and dark) ───────────────── */
.av    { width: 30px; height: 30px; border-radius: 50%; background: rgba(26,175,230,.25); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #1AAFE6; flex-shrink: 0; }
.av-sm { width: 26px; height: 26px; font-size: 10px; border-radius: 50%; background: var(--wk-l); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--wk-d); }
.av-lg { width: 48px; height: 48px; font-size: 17px; border-radius: 50%; background: var(--wk-l); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--wk-d); }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  background: var(--surf); border-bottom: 1px solid var(--bdr);
  padding: 0 24px; height: 52px; display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 50;
}
.mob-menu-btn {
  background: none; border: none; cursor: pointer; padding: 6px;
  color: var(--txt2); border-radius: var(--rad-sm);
  display: flex; align-items: center; justify-content: center;
}
.mob-menu-btn:hover { background: var(--surf2); }
.mob-menu-btn svg { width: 18px; height: 18px; }
.topbar-titles { flex: 1; }
.topbar-title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.topbar-sub   { font-size: 11.5px; color: var(--txt2); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── Non-gestori: sempre layout mobile, qualunque schermo ──── */
.shell:not(.has-sidebar) .topbar        { display: none; }
.shell:not(.has-sidebar) .mob-topbar    { display: flex; }
.shell:not(.has-sidebar) .mob-actions-bar { display: flex; }
.shell:not(.has-sidebar) .content {
  padding: 14px 16px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 72px);
  max-width: 640px;
}
.shell:not(.has-sidebar) ~ .bottom-nav {
  display: flex;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  background: var(--surf); border-top: 1px solid var(--bdr);
  z-index: 520;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* ── Mobile topbar ───────────────────────────────────────── */
.mob-topbar {
  display: none;
  background: var(--sidebar-bg);
  height: calc(54px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  position: sticky; top: 0; z-index: 150;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.mob-topbar-btn {
  background: none; border: none; cursor: pointer;
  width: 48px; height: 54px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.75); flex-shrink: 0;
}
.mob-topbar-btn:active { background: rgba(255,255,255,.08); }
.mob-topbar-btn svg { width: 22px; height: 22px; }
.mob-topbar-spacer { width: 48px; flex-shrink: 0; }
.mob-topbar-center {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-width: 0; padding: 0 4px;
}
.mob-topbar-logo { display: flex; align-items: center; gap: 7px; }
.mob-topbar-logo-text { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -.3px; }
.mob-topbar-section {
  font-size: 11px !important; font-family: inherit; color: rgba(255,255,255,.45);
  margin-top: 1px;
  display: flex; align-items: center; gap: 3px;
  max-width: 100%; overflow: hidden;
}
.mob-topbar-section span {
  font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0; flex: 1;
}
.mob-topbar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(26,175,230,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #1AAFE6;
  cursor: pointer; flex-shrink: 0; margin: 0 8px;
  border: 2px solid rgba(26,175,230,.3); transition: border-color .15s;
  user-select: none;
}
.mob-topbar-avatar:active { border-color: #1AAFE6; }

/* ── Avatar dropdown ─────────────────────────────────────── */
.avatar-dropdown {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 60px); right: 8px;
  background: var(--surf); border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18), 0 0 0 1px var(--bdr);
  width: 200px; z-index: 600; overflow: hidden;
  transform-origin: top right;
  transform: scale(.92); opacity: 0; pointer-events: none;
  transition: transform .15s cubic-bezier(.4,0,.2,1), opacity .15s;
}
.avatar-dropdown.open { transform: scale(1); opacity: 1; pointer-events: all; }
.avatar-dd-hdr { padding: 12px 14px; border-bottom: 1px solid var(--bdr); }
.avatar-dd-name { font-size: 13px; font-weight: 600; }
.avatar-dd-role { font-size: 11px; color: var(--txt2); margin-top: 1px; }
.avatar-dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; font-size: 13px; cursor: pointer;
  transition: background .1s; width: 100%; border: none; background: none;
  font-family: inherit; color: var(--txt); text-align: left;
}
.avatar-dd-item:hover { background: var(--surf2); }
.avatar-dd-item.danger { color: var(--red); }
.avatar-dd-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--txt2); }
.avatar-dd-item.danger svg { color: var(--red); }
.avatar-dd-sep { height: 1px; background: var(--bdr); }

/* ── Content ─────────────────────────────────────────────── */
.content { padding: 20px 24px; flex: 1; max-width: 1200px; margin: 0 auto; width: 100%; box-sizing: border-box; }
@media (max-width: 768px) {
  /* Topbar fissa: main-area è container fisso, solo .content scrolla */
  html, body { height: 100%; overflow: hidden; }
  .shell { min-height: 100%; height: 100%; }
  .main-area {
    height: 100vh; /* dvh sotto sovrascrive su browser moderni */
    height: 100dvh;
    min-height: unset;
    overflow: hidden;
    overflow-x: unset;
  }
  .content {
    padding: 14px 16px;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 72px);
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .topbar  { display: none; }
  .mob-topbar { display: flex; }
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--rad-sm); font-size: 13px;
  font-weight: 500; cursor: pointer; border: 1px solid var(--bdr2);
  background: var(--surf); color: var(--txt); font-family: inherit;
  transition: all .1s; white-space: nowrap; line-height: 1;
}
.btn:hover   { background: var(--surf2); }
.btn:active  { transform: scale(.98); }
.btn svg     { width: 14px; height: 14px; flex-shrink: 0; }
.btn.primary { background: var(--wk); color: #fff; border-color: var(--wk); }
.btn.primary:hover { background: var(--wk-d); border-color: var(--wk-d); }
.btn.danger  { background: var(--red-bg);   color: var(--red);   border-color: rgba(220,38,38,.2); }
.btn.success { background: var(--green-bg); color: var(--green); border-color: rgba(5,150,105,.2); }
.btn.ghost   { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surf2); }
.btn.sm  { padding: 5px 10px; font-size: 12px; }
.btn.xs  { padding: 3px 8px;  font-size: 11px; }
.btn.full{ width: 100%; justify-content: center; }
.btn.big { padding: 12px 20px; font-size: 15px; min-height: 48px; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; display: inline-flex;
  align-items: center; justify-content: center;
  border-radius: var(--rad-sm); border: 1px solid var(--bdr);
  background: var(--surf); cursor: pointer; transition: all .1s; color: var(--txt2);
}
.btn-icon:hover { background: var(--surf2); color: var(--txt); }
.btn-icon svg { width: 15px; height: 15px; }

/* ── Cards ───────────────────────────────────────────────── */
.card { background: var(--surf); border: 1px solid var(--bdr); border-radius: var(--rad); overflow: hidden; }
.card-hdr { padding: 13px 16px; border-bottom: 1px solid var(--bdr); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 13.5px; font-weight: 700; }
.card-body  { padding: 16px; }

/* ── Shortcut cards (dashboard) ──────────────────────────── */
.shortcut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 10px; }
.shortcut-card {
  background: var(--surf); border: 1px solid var(--bdr); border-radius: var(--rad);
  padding: 16px; cursor: pointer; transition: all .15s; display: flex; flex-direction: column; gap: 10px;
}
.shortcut-card:hover { border-color: var(--wk); box-shadow: 0 2px 12px rgba(26,175,230,.12); transform: translateY(-1px); }
.shortcut-icon {
  width: 36px; height: 36px; border-radius: var(--rad-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--surf2);
}
.shortcut-icon svg { width: 18px; height: 18px; stroke: var(--txt2); }
.shortcut-card:hover .shortcut-icon { background: var(--wk-l); }
.shortcut-card:hover .shortcut-icon svg { stroke: var(--wk); }
.shortcut-label { font-size: 13px; font-weight: 600; }
.shortcut-sub   { font-size: 11px; color: var(--txt2); margin-top: 2px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 11px; font-weight: 600; color: var(--txt2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px; }
.form-input {
  width: 100%; padding: 9px 12px; border-radius: var(--rad-sm);
  border: 1.5px solid var(--bdr); font-size: 14px; font-family: inherit;
  background: var(--surf); color: var(--txt); transition: border-color .1s; outline: none;
}
.form-input:focus { border-color: var(--wk); box-shadow: 0 0 0 3px rgba(26,175,230,.1); }
select.form-input { cursor: pointer; }
.form-hint { font-size: 11px; color: var(--txt2); margin-top: 3px; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
  /* cred box wrap su schermi stretti */
  .cred-val { font-size: 17px; letter-spacing: 2px; }
}

/* ── Pills ───────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
button.pill { -webkit-appearance: none; appearance: none; border: 1px solid var(--bdr2); font-family: inherit; cursor: pointer; }
/* Ruoli — 7 colori distinti */
.p-admin      { background: #EEF2FF; color: #4338CA; }   /* indigo  */
.p-capo       { background: #F3E8FF; color: #7C3AED; }   /* violet  */
.p-coord      { background: #DBEAFE; color: #1D4ED8; }   /* blue    */
.p-senior     { background: #DCFCE7; color: #15803D; }   /* green   */
.p-junior     { background: #FEF9C3; color: #A16207; }   /* yellow  */
.p-formatore  { background: #FFEDD5; color: #C2410C; }   /* orange  */
.p-partec     { background: #F1F5F9; color: #475569; border: 1px solid #CBD5E1; } /* slate */
.p-volont     { background: #FFE4E6; color: #BE123C; }   /* rose    */
/* Tipologie progetto — 3 colori distinti */
.p-midnight   { background: #2B3FD4; color: #FFFFFF; }   /* royal blue  */
.p-opensunday { background: #E8130C; color: #FFFFFF; }   /* red         */
.p-minimove   { background: #F5C800; color: #1A1200; }   /* yellow      */
.p-active     { background: var(--green-bg);  color: var(--green);  }
.p-inactive   { background: var(--surf2);     color: var(--txt2); border: 1px solid var(--bdr); }
.p-warn       { background: var(--amber-bg);  color: var(--amber);  }
.p-danger     { background: var(--red-bg);    color: var(--red);    }
.p-orange     { background: #FFF0E0;          color: #C05000;       }  /* vacanza */
.p-blue       { background: #E0F2FE;          color: #0369A1;       }  /* serata  */
.r-x  { background: #F0FDF4; color: #059669; }
.r-c  { background: #EFF6FF; color: #2563EB; }
.r-d  { background: #F5F3FF; color: #7C3AED; }
.r-e  { background: #FFFBEB; color: #D97706; }
.r-p  { background: #F8FAFC; color: #64748B; }
.r-no { background: #FEF2F2; color: #DC2626; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  padding: 9px 14px; text-align: left; font-size: 10px; font-weight: 700;
  color: var(--txt3); background: var(--surf2); border-bottom: 1px solid var(--bdr);
  text-transform: uppercase; letter-spacing: .5px; white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--bdr); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .08s; }
tbody tr:hover { background: var(--surf2); }
.td-user { display: flex; align-items: center; gap: 9px; }

/* ── Stats ───────────────────────────────────────────────── */
.stats { display: grid; gap: 10px; margin-bottom: 20px; }
.s2 { grid-template-columns: repeat(2,1fr); }
.s3 { grid-template-columns: repeat(3,1fr); }
.s4 { grid-template-columns: repeat(4,1fr); }
.s5 { grid-template-columns: repeat(5,1fr); }
@media (max-width: 640px) { .s3,.s4,.s5 { grid-template-columns: repeat(2,1fr); } }

.stat {
  background: var(--surf); border: 1px solid var(--bdr);
  border-radius: var(--rad); padding: 16px 18px;
}
.stat-l { font-size: 10.5px; font-weight: 600; color: var(--txt3); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .4px; }
.stat-v { font-size: 26px; font-weight: 700; letter-spacing: -.5px; line-height: 1; }
.stat-s { font-size: 11.5px; color: var(--txt2); margin-top: 4px; }
.stat-icon { float: right; width: 32px; height: 32px; border-radius: var(--rad-sm); background: var(--surf2); display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 16px; height: 16px; stroke: var(--txt3); }
.c-green { color: var(--green); } .c-red { color: var(--red); } .c-amber { color: var(--amber); }
.c-blue  { color: var(--wk); }

/* ── Login ───────────────────────────────────────────────── */
.login-wrap {
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 28px;
  min-height: 100vh; background: var(--sidebar-bg);
  padding: max(20px, env(safe-area-inset-top, 20px)) 20px max(20px, env(safe-area-inset-bottom, 20px));
}
.login-brand {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
}
.login-brand-icon {
  width: 64px; height: 64px; background: var(--wk); border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(26,175,230,.4);
}
.login-brand-name { font-size: 26px; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.login-brand-sub  { font-size: 12px; color: rgba(255,255,255,.45); letter-spacing: .2px; }
.login-box {
  background: var(--surf); border-radius: 12px; width: 380px; max-width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,.4); overflow: hidden;
}
.logo-text { font-size: 21px; font-weight: 800; color: var(--wk); letter-spacing: -.4px; }
.login-body { padding: 24px 28px 28px; }
.login-type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.type-btn {
  padding: 12px 10px; border: 1.5px solid var(--bdr); border-radius: var(--rad);
  background: var(--surf2); cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 5px; transition: all .1s;
}
.type-btn:hover, .type-btn.active { border-color: var(--wk); background: var(--wk-l); }
.type-ico { width: 32px; height: 32px; background: var(--surf3); border-radius: var(--rad-sm); display: flex; align-items: center; justify-content: center; }
.type-ico svg { width: 16px; height: 16px; stroke: var(--txt2); }
.type-btn.active .type-ico { background: rgba(26,175,230,.15); }
.type-btn.active .type-ico svg { stroke: var(--wk); }
.type-btn span:nth-child(2) { font-size: 12.5px; font-weight: 700; color: var(--txt); }
.type-hint { font-size: 10px; color: var(--txt2); }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  padding: 10px 18px; border-radius: var(--rad-sm); font-size: 13px; font-weight: 500;
  z-index: 9998; opacity: 0; transition: all .2s; pointer-events: none;
  background: var(--txt); color: #fff; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-ok   { background: var(--green); }
.toast.toast-err  { background: var(--red);   }
.toast.toast-warn { background: var(--amber); }
@media (min-width: 769px) { .toast { bottom: 24px; } }

/* ── Offline banner ──────────────────────────────────────── */
.rs-pill {
  display: inline-block; cursor: pointer; padding: 5px 14px; border-radius: 20px;
  font-size: 12px; font-weight: 600; border: 1.5px solid var(--bdr);
  color: var(--txt2); background: var(--surf); transition: all .12s; user-select: none;
  line-height: 1.4;
}
.rs-pill:hover { border-color: var(--wk); color: var(--wk); }
.rs-pill.rs-pill-on {
  background: rgba(26,175,230,.12); color: var(--wk); border-color: var(--wk); font-weight: 700;
}

.offline-banner {
  border-bottom: 1px solid rgba(217,119,6,.3);
  background: var(--amber-bg); color: var(--amber);
  padding: 7px 20px; font-size: 12.5px; font-weight: 500;
  text-align: center; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.offline-banner.offline-queue {
  background: rgba(234,179,8,.18); border-bottom-color: rgba(234,179,8,.45); color: #92400e;
}
.offline-banner .oq-sync-btn {
  background: rgba(217,119,6,.2); border: 1px solid rgba(217,119,6,.5); color: inherit;
  border-radius: 6px; padding: 2px 10px; font-size: 12px; cursor: pointer; font-weight: 600;
}
.offline-banner .oq-sync-btn:hover { background: rgba(217,119,6,.35); }

/* ── Bottom nav (mobile) ─────────────────────────────────── */
.bottom-nav { display: none; }
@media (max-width: 768px) {
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    background: var(--surf); border-top: 1px solid var(--bdr); z-index: 520;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
  .shell.has-sidebar .main-area { margin-left: 0; }
}
.bnav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; border: none; background: none;
  font-family: inherit; font-size: 10px; font-weight: 500; color: var(--txt3);
  cursor: pointer; padding: 4px 2px; transition: color .1s; min-width: 0;
}
.bnav-item.active { color: var(--wk); }
.bnav-item.active .bnav-ico svg { stroke: var(--wk); }
.bnav-hamburger { color: var(--txt2); }
.bnav-hamburger:active { color: var(--txt); }
.bnav-ico { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.bnav-ico svg { width: 20px; height: 20px; }

/* ── Pill xs ─────────────────────────────────────────────── */
.pill-xs { font-size: 9px !important; padding: 1px 5px !important; letter-spacing: .3px; }

/* ── Category tabs (eventi) ──────────────────────────────── */
.cat-tabs {
  display: flex; gap: 4px; margin-bottom: 12px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  padding-bottom: 2px; /* prevent clipping of focus ring */
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex-shrink: 0; padding: 5px 12px; border-radius: 20px;
  border: 1.5px solid var(--bdr); background: var(--surf);
  font-size: 12px; font-weight: 500; color: var(--txt2);
  cursor: pointer; font-family: inherit; white-space: nowrap;
  transition: all .12s;
}
.cat-tab:hover  { border-color: var(--wk); color: var(--wk); }
.cat-tab.active { border-color: var(--wk); background: rgba(26,175,230,.1); color: var(--wk); font-weight: 600; }
@media (max-width: 768px) {
  .cat-tab { padding: 4px 10px; font-size: 11px; }
}

/* ── Event list row ──────────────────────────────────────── */
.ev-row { align-items: flex-start; gap: 10px; }
.ev-date-col {
  width: 32px; flex-shrink: 0; text-align: center; padding-top: 2px;
}
.ev-day { font-size: 18px; font-weight: 800; line-height: 1; color: var(--txt); }
.ev-dow { font-size: 10px; font-weight: 600; color: var(--txt3); text-transform: uppercase; letter-spacing: .5px; }
/* Mobile: comprimi colonna data e nascondi le pill destra (info nel subline) */
@media (max-width: 768px) {
  .ev-row { gap: 8px; padding: 10px 12px !important; }
  .ev-date-col { width: 28px; }
  .ev-day { font-size: 16px; }
  .ev-dow { font-size: 9px; }
  .ev-pills-col { display: none; }
  /* Assicura che il contenuto non esca dallo schermo */
  .list-row { overflow: hidden; }
  .list-row-main { min-width: 0; overflow: hidden; }
  .list-row-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ── Genera calendario wizard ────────────────────────────── */
.gcal-regola {
  border: 1.5px solid var(--bdr); border-radius: var(--rad-sm);
  padding: 12px; margin-bottom: 10px; background: var(--surf2);
}
.gcal-regola-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}

/* ── Cassa POS ───────────────────────────────────────────── */
.cassa-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; height: calc(100vh - 108px); }
@media (max-width: 900px) { .cassa-layout { grid-template-columns: 1fr; height: auto; } }
.cassa-products { overflow-y: auto; }
.cassa-right { display: flex; flex-direction: column; gap: 10px; }
.cassa-display { background: var(--surf); border: 1px solid var(--bdr); border-radius: var(--rad); padding: 16px; text-align: center; }
.cassa-total { font-size: 42px; font-weight: 800; letter-spacing: -2px; }
.cassa-sub { font-size: 11px; color: var(--txt2); margin-top: 2px; }
.cart-list { flex: 1; overflow-y: auto; background: var(--surf); border: 1px solid var(--bdr); border-radius: var(--rad); min-height: 120px; }
.cart-item { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-bottom: 1px solid var(--bdr); }
.cart-item:last-child { border-bottom: none; }
.cart-name  { flex: 1; font-size: 13px; font-weight: 500; }
.qty-ctrl   { display: flex; align-items: center; gap: 6px; }
.qty-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--bdr2);
  background: var(--surf2); cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 17px; font-weight: 700; color: var(--txt);
  transition: background .08s; flex-shrink: 0;
}
.qty-btn:hover { background: var(--surf3); }
@media (max-width: 768px) { .qty-btn { width: 36px; height: 36px; font-size: 20px; } }
.cart-price { font-weight: 700; font-size: 13.5px; min-width: 58px; text-align: right; }
.prodotti-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap: 8px; }
.prod-card {
  background: var(--surf); border: 1px solid var(--bdr); border-radius: var(--rad);
  overflow: hidden; cursor: pointer; transition: all .12s;
}
.prod-card:hover, .prod-card:active { border-color: var(--wk); }
.prod-img  { height: 64px; background: var(--surf2); display: flex; align-items: center; justify-content: center; font-size: 28px; }
.prod-info { padding: 8px 10px; }
.prod-name { font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.prod-price{ font-size: 12.5px; font-weight: 700; color: var(--wk-d); }
.prod-stock{ font-size: 10px; color: var(--txt2); margin-top: 1px; }
.banconote-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; }
.banconota {
  background: var(--surf2); border: 1.5px solid var(--bdr); border-radius: var(--rad-sm);
  padding: 10px 4px; text-align: center; cursor: pointer; font-weight: 700;
  font-size: 12.5px; transition: all .08s; user-select: none;
  min-height: 44px; display: flex; align-items: center; justify-content: center;
}
.banconota:hover, .banconota:active { border-color: var(--wk); background: var(--wk-l); }

/* ── Progress bar ────────────────────────────────────────── */
.prog-bar  { height: 4px; background: var(--bdr); border-radius: 3px; }
.prog-fill { height: 4px; border-radius: 3px; transition: width .3s; }

/* ── Serata wizard ───────────────────────────────────────── */
.wiz-steps { display: flex; gap: 3px; margin-bottom: 20px; overflow-x: auto; padding-bottom: 2px; }
.wiz-step {
  flex: 1; min-width: 60px; padding: 7px 4px; text-align: center; border-radius: var(--rad-sm);
  font-size: 11px; font-weight: 600; border: 1px solid var(--bdr); background: var(--surf2);
  color: var(--txt2); white-space: nowrap;
}
.wiz-step.done    { background: var(--green-bg); color: var(--green); border-color: rgba(5,150,105,.2); }
.wiz-step.current { background: var(--wk-l); color: var(--wk-d); border-color: rgba(13,143,191,.3); font-weight: 700; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-ov { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 300; align-items: center; justify-content: center; padding: 16px; }
.modal-ov.open { display: flex; }
.modal {
  background: var(--surf); border-radius: 10px;
  width: 520px; max-width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
}
.modal.wide { width: 720px; }
.modal.sm   { width: 360px; }
.modal.fullscreen { width: 98vw; max-width: 98vw; height: 95vh; height: 95dvh; max-height: 95vh; max-height: 95dvh; padding: 0; display: flex; flex-direction: column; overflow: hidden; border-radius: 12px; }
.modal.fullscreen .modal-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 16px 20px; }
.modal.tall {
  height: 88vh; height: 88dvh; max-height: 88vh; max-height: 88dvh; padding: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal.tall .modal-body {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 20px 22px;
}
.modal-hdr {
  padding: 15px 18px 12px; border-bottom: 1px solid var(--bdr);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--surf); z-index: 1;
  flex-shrink: 0;
}
.modal-title  { font-size: 14.5px; font-weight: 700; }
.modal-close  {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--bdr); background: var(--surf2);
  cursor: pointer; font-size: 14px; display: flex; align-items: center;
  justify-content: center; color: var(--txt2); line-height: 1;
}
.modal-body   { padding: 16px 18px; }
.modal-footer {
  padding: 12px 18px; border-top: 1px solid var(--bdr);
  display: flex; gap: 8px; justify-content: flex-end;
  position: sticky; bottom: 0; background: var(--surf);
  flex-shrink: 0;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 24px; color: var(--txt2); }
.empty-ico { width: 52px; height: 52px; background: var(--surf2); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.empty-ico svg { width: 22px; height: 22px; stroke: var(--txt3); }

/* ── Section header ──────────────────────────────────────── */
.section-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-hdr h2 { font-size: 15px; font-weight: 700; }

/* ── List rows ───────────────────────────────────────────── */
.list-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 11px 16px;
  border-bottom: 1px solid var(--bdr); transition: background .08s;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surf2); }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row-sub   { font-size: 11.5px; color: var(--txt2); margin-top: 1px; }

/* ── Person list row (avatar + info + pills responsive) ── */
.lrp-left  { display:flex; align-items:center; gap:12px; flex:1; min-width:0; }
.lrp-right { display:flex; flex-direction:column; align-items:flex-end; gap:4px; flex-shrink:0; }
.lrp-pills { display:flex; align-items:center; gap:4px; flex-wrap:wrap; justify-content:flex-end; }
.lrp-proj  { display:flex; gap:4px; flex-wrap:wrap; justify-content:flex-end; }

/* Classe per pill con accesso (App / Admin) */
.p-portal { background:#6366F1; color:#fff; }

/* Access pill → pallino colorato (desktop + mobile) */
.list-row-person .pill-access {
  width: 9px; height: 9px;
  padding: 0; border-radius: 50%;
  font-size: 0; flex-shrink: 0;
  overflow: hidden;
}
/* Pallino verde app: usa il verde intenso invece dello sfondo chiaro */
.list-row-person .pill-access.p-active {
  background: rgb(5, 150, 105);
}

/* Role pill → abbreviazione via data-abbr (desktop + mobile) */
.list-row-person .pill-role {
  font-size: 0; padding: 2px 5px;
}
.list-row-person .pill-role::after {
  content: attr(data-abbr);
  font-size: 10px; font-weight: 700;
}

@media (max-width: 600px) {
  /* Layout: nome a sinistra, pills a destra in colonna */
  .list-row-person { align-items: flex-start; }
  .lrp-left { align-items: flex-start; padding-top: 2px; }
  .lrp-right { flex-direction: column; align-items: flex-end; gap: 3px; }
  .lrp-pills { flex-wrap: nowrap; justify-content: flex-end; gap: 3px; }

  /* Project pills: nascosti nel team su mobile */
  #team-list .lrp-proj { display: none; }
}

/* ── Sticky filters (desktop + mobile) ──────────────────── */
.sticky-filters {
  position: sticky;
  top: 52px; /* altezza topbar desktop */
  z-index: 50;
  background: var(--bg);
  padding-top: 8px;
  padding-bottom: 4px;
}
.sticky-filters .search-bar { margin-bottom: 8px; }
.sticky-filters .cat-tabs   { margin-bottom: 8px; }

@media (max-width: 768px) {
  .sticky-filters {
    /* mobile: .content è scroll container, top:0 incolla subito sotto mob-actions-bar */
    top: -14px;
    padding-top: 14px;
    margin: -14px -16px 0;
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ── Search bar ──────────────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
}
.search-input-wrap { position: relative; flex: 1; }
.search-input-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; stroke: var(--txt3); pointer-events: none; }
.search-input { width: 100%; padding: 8px 32px 8px 32px; border-radius: var(--rad-sm); border: 1.5px solid var(--bdr); font-size: 13.5px; font-family: inherit; background: var(--surf); color: var(--txt); outline: none; transition: border-color .1s; }
.search-input:focus { border-color: var(--wk); }
.search-clear {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: 2px;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  color: var(--txt3); opacity: 0; pointer-events: none;
  transition: opacity .15s, color .1s;
}
.search-clear svg { width: 14px; height: 14px; }
.search-clear:hover { color: var(--txt); }
.search-bar:has(input:not(:placeholder-shown)) .search-clear { opacity: 1; pointer-events: all; }

/* ── Misc ────────────────────────────────────────────────── */
.flex     { display: flex; }
.flex-col { flex-direction: column; }
.ai-c     { align-items: center; }
.jc-b     { justify-content: space-between; }
.gap-2    { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2     { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2     { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.muted    { color: var(--txt2); }
.fw7      { font-weight: 700; }
.text-sm  { font-size: 12.5px; }
.text-xs  { font-size: 11px; }
.divider  { border: none; border-top: 1px solid var(--bdr); margin: 14px 0; }
hr        { border: none; border-top: 1px solid var(--bdr); margin: 14px 0; }

/* ── Drawer (pannello laterale persona) ─────────────────────── */
.wk-drawer-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.38); z-index: 529;
}
.wk-drawer-backdrop.open { display: block; }
.wk-drawer {
  /* sopra la .bottom-nav (z-index 520): come bottom-sheet mobile deve coprirla,
     altrimenti l'ultima riga della lista resta nascosta dietro la barra */
  position: fixed; top: 0; right: 0; height: 100%;
  width: 500px; max-width: 100%; background: var(--bg);
  box-shadow: -6px 0 40px rgba(0,0,0,.14); z-index: 530;
  transform: translateX(110%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column; overflow: hidden;
}
.wk-drawer.open { transform: translateX(0); }
.wk-drawer-hdr {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px 20px; border-bottom: none;
  flex-shrink: 0; background: var(--surf);
}
.wk-drawer-hdr-info { flex: 1; min-width: 0; }
.wk-drawer-hdr-name {
  font-size: 16px; font-weight: 700;
  white-space: normal; overflow-wrap: break-word; line-height: 1.3;
}
.wk-drawer-hdr-sub { font-size: 12px; color: var(--txt2); margin-top: 2px; }
.wk-drawer-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 24px; }

/* ── Tabs ────────────────────────────────────────────────────── */
.tab-bar {
  display: flex; border-bottom: 1px solid var(--bdr);
  background: var(--surf); overflow-x: auto; scrollbar-width: none;
  flex-shrink: 0; padding: 4px 4px 0;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 13px; font-size: 12.5px; font-weight: 500;
  color: var(--txt2); border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
  transition: color .15s, border-color .15s; outline: none; font-family: inherit;
}
.tab-btn:hover { color: var(--txt); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-pane { display: none; padding: 20px 18px 16px; }
.tab-pane.active { display: block; }

/* ── Credential box ──────────────────────────────────────────── */
.cred-box {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--bg); border: 1.5px solid var(--bdr);
  border-radius: 8px; padding: 10px 14px; margin-top: 4px;
}
.cred-val {
  font-family: monospace; font-size: 20px; font-weight: 700;
  letter-spacing: 3px; flex: 1; color: var(--txt); min-width: 120px;
}
.cred-btn {
  font-size: 11px; color: var(--txt2); cursor: pointer;
  padding: 4px 8px; border-radius: 4px; border: 1px solid var(--bdr);
  background: var(--surf); font-family: inherit; white-space: nowrap;
}
.cred-btn:hover { background: var(--bdr); }

/* ── Radio access selector ───────────────────────────────────── */
.acc-options { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.acc-option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1.5px solid var(--bdr);
  border-radius: 8px; cursor: pointer; transition: border-color .12s, background .12s;
}
.acc-option input[type=radio] { margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }
.acc-option-label { font-size: 13px; font-weight: 600; }
.acc-option-sub { font-size: 11.5px; color: var(--txt2); margin-top: 1px; }

/* ── Detail grid (inside drawer panes) ───────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.detail-item { margin-top: 14px; }
.detail-item.full { grid-column: 1/-1; }
.detail-label { font-size: 11px; color: var(--txt2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.detail-val { font-size: 14px; font-weight: 500; line-height: 1.4; white-space: pre-wrap; }
.career-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--bdr);
}
.career-row:last-child { border-bottom: none; }

/* ── Modal z-index fix (must be above drawer z-index 530) ── */
.modal-ov { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 600; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-ov.open { display: flex; }

/* ── Mobile page header (title + actions, below mob-topbar) ── */
.mob-actions-bar {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 8px 14px; background: var(--sidebar-bg);
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0; gap: 8px; min-height: 46px;
}
.mob-page-title {
  font-size: 14px; font-weight: 700; color: #fff;
  flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* button non-primary sulla barra mobile scura */
.mob-actions-bar .btn:not(.primary) {
  background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.2);
}
.mob-actions-bar .btn:not(.primary):hover {
  background: rgba(255,255,255,.18);
}
@media (max-width: 768px) {
  .mob-actions-bar { display: flex; flex-wrap: wrap; row-gap: 4px; min-height: 46px; height: auto; padding: 6px 12px; flex-shrink: 0; }
  /* shrink buttons in mobile action bar */
  .mob-actions-bar .btn { padding: 5px 10px; font-size: 12px; }
  /* back button: solo icona su schermi stretti */
  .mob-actions-bar .btn-back { padding: 5px 8px; }
  .mob-actions-bar .btn-back .btn-label { display: none; }
  #wk-mob-actions { flex-wrap: wrap; gap: 4px; }
}

/* ── Modal → bottom sheet on mobile ─────────────────────── */
@media (max-width: 768px) {
  .modal-ov {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .modal, .modal.wide, .modal.sm {
    width: 100%; max-width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    display: flex; flex-direction: column;
    animation: mob-modal-up .3s cubic-bezier(.4,0,.2,1);
  }
  @keyframes mob-modal-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .modal::before {
    content: ''; display: block; width: 36px; height: 4px;
    background: var(--bdr2); border-radius: 2px;
    margin: 10px auto 2px; flex-shrink: 0;
  }
  .modal-hdr { flex-shrink: 0; position: sticky; top: 0; }
  .modal-body { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
  .modal-footer {
    flex-shrink: 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* ── Mobile sidebar (responsive) ────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0;
    height: calc(100% - 56px - env(safe-area-inset-bottom, 0px));
    width: 100% !important;           /* larghezza intera su mobile */
    transform: translateX(-110%); z-index: 510;
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    /* Safe area: padding ai lati e in basso */
    padding-left:  env(safe-area-inset-left,  0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  /* La safe area in alto è già gestita dal primo elemento .sb-logo tramite il topbar */
  .sidebar .sb-logo {
    height: auto;
    padding-top: max(20px, calc(env(safe-area-inset-top, 0px) + 16px));
    padding-bottom: 16px;
  }
  .sidebar.mob-open { transform: translateX(0); box-shadow: none; }
  .shell.has-sidebar .main-area { margin-left: 0; }
  .mob-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 505; backdrop-filter: blur(2px); }
  .mob-backdrop.mob-open { display: block; }
}

/* ── Persona drawer: bottom sheet on mobile ──────────────── */
@media (max-width: 768px) {
  .wk-drawer {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; height: 92vh; height: 92dvh;
    border-radius: 16px 16px 0 0;
    transform: translateY(110%);
    box-shadow: 0 -6px 40px rgba(0,0,0,.16);
    background: var(--surf);
  }
  .wk-drawer.open { transform: translateY(0); }
  .wk-drawer::before {
    content: ''; display: block; width: 36px; height: 4px;
    background: var(--bdr2); border-radius: 2px;
    margin: 10px auto 0; flex-shrink: 0;
  }
  /* il drawer ora copre la bottom-nav: basta lo spazio per la safe-area + respiro */
  .wk-drawer-body { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); background: var(--bg); }
}

/* ── Contact action buttons ──────────────────────────────── */
.contact-actions { display: flex; align-items: center; gap: 4px; margin-left: 6px; }
.contact-action {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--bdr);
  background: var(--surf); color: var(--txt2); cursor: pointer;
  text-decoration: none; transition: background .1s, color .1s; flex-shrink: 0;
}
.contact-action svg { width: 13px; height: 13px; }
.contact-action:hover { background: var(--wk); color: #fff; border-color: var(--wk); }
.contact-action.wa:hover { background: #25D366; border-color: #25D366; }

/* ── Autocomplete ─────────────────────────────────────────── */
.ac-wrap { position: relative; }
.ac-list {
  position: absolute; top: 100%; left: 0; right: 0; background: var(--surf);
  border: 1px solid var(--bdr); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 200; max-height: 180px; overflow-y: auto; margin-top: 2px; display: none;
}
.ac-list.open { display: block; }
.ac-item {
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--bdr); transition: background .08s;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: var(--surf2); }
.ac-item b { color: var(--primary); }

/* ── Step indicator ───────────────────────────────────────── */
.step-row { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; }
.step-dot {
  width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0;
  background: var(--surf2); color: var(--txt2); border: 1.5px solid var(--bdr); transition: all .15s;
}
.step-dot.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.step-dot.done { background: #10B981; color: #fff; border-color: #10B981; }
.step-line { flex: 1; height: 2px; background: var(--bdr); }
.step-line.done { background: #10B981; }

/* ── Tab icons ────────────────────────────────────────────── */
.tab-btn { min-width: 40px; }
.tab-btn svg { width: 16px; height: 16px; display: block; margin: 0 auto 2px; }
.tab-btn span > svg { margin: 0; }
.tab-label { font-size: 10px; }

/* ── Dup match card ───────────────────────────────────────── */
.dup-card {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border: 1.5px solid var(--bdr); border-radius: 10px; margin-bottom: 8px;
  cursor: pointer; transition: border-color .12s, background .12s;
}
.dup-card:hover { border-color: var(--primary); background: rgba(26,175,230,.04); }

/* ══════════════════════════════════════════════════════════
   PWA RESPONSIVE — regole globali mobile (max 768px)
   Si applicano a tutta l'app, non solo agli eventi
   ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Form layout: le righe diventano colonne su mobile stretto */
  /* .form-row è una grid — il singolo colonna è già gestito dal @media 480px sopra */

  /* Card: padding ridotto */
  .card { border-radius: 10px; }
  .card-hdr, .card-body { padding: 10px 12px; }

  /* List row: tocco più comodo */
  .list-row { padding: 10px 12px; min-height: 44px; }
  .list-row-title { font-size: 13px; }
  .list-row-sub   { font-size: 11px; }

  /* Section header */
  .section-hdr { padding: 4px 0; }
  .section-hdr h2 { font-size: 13px; }

  /* Testo piccolo: leggibile su mobile */
  .text-sm { font-size: 12px; }

  /* Drawer: padding laterale ridotto */
  .wk-drawer-hdr { padding: 14px 14px 18px !important; }
  .tab-bar { padding: 4px 8px 0; gap: 2px; }
  .tab-btn  { padding: 8px 10px; font-size: 11px; }
  .tab-pane { padding: 0 14px 16px !important; }

  /* Search bar: più compatta */
  .search-input { font-size: 13px; padding: 7px 30px 7px 30px; }

  /* Wizard regole: layout stretto */
  .gcal-regola { padding: 10px 12px; }

  /* Bottoni touch-friendly (minimo 44px di altezza) */
  .btn.big { min-height: 44px; }
  .btn-icon { min-width: 36px; min-height: 36px; }

  /* POS mobile: carrello nascosto, barra carrello + bottom nav in basso */
  .pos-cart-panel { display: none !important; }
  #pos-wrap { height: calc(100vh - 120px - 52px) !important; } /* -52px per la barra carrello */

  /* Griglia prodotti: 3 colonne su mobile */
  #pos-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
    padding-bottom: 80px;
  }

  /* Carrello bottom sheet: righe più grandi */
  #pos-cart-items-sh .pos-ci {
    padding: 14px 4px !important;
    gap: 12px !important;
  }
  #pos-cart-items-sh .pos-ci-th {
    width: 52px !important;
    height: 52px !important;
    font-size: 30px !important;
    border-radius: 8px !important;
  }
  #pos-cart-items-sh .pos-ci-nome {
    font-size: 15px !important;
  }
  #pos-cart-items-sh .pos-ci-prezzo {
    font-size: 13px !important;
    margin-top: 3px;
  }
  #pos-cart-items-sh .pos-ci-btn {
    width: 36px !important;
    height: 36px !important;
    font-size: 20px !important;
  }
  #pos-cart-items-sh .pos-ci-qty {
    font-size: 17px !important;
    min-width: 28px !important;
  }

  /* Modal tall: quasi tutta altezza su mobile, lascia spazio alla top bar */
  .modal.tall { height: calc(100vh - 56px) !important; height: calc(100dvh - 56px) !important;
                max-height: calc(100vh - 56px) !important; max-height: calc(100dvh - 56px) !important;
                border-radius: 12px 12px 0 0 !important; }

  /* Modal pagamento contanti: fullscreen su mobile per avere spazio alle banconote */
  .modal-box.wide { width: 100% !important; max-width: 100% !important;
                    border-radius: 0 !important;
                    height: 100vh !important; height: 100dvh !important;
                    max-height: 100vh !important; max-height: 100dvh !important;
                    margin: 0 !important; }
  .modal-body { max-height: calc(100vh - 130px) !important; max-height: calc(100dvh - 130px) !important; }
  /* Griglia monete: 3 colonne su mobile per evitare overflow */
  #cassa-monete-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

/* ── POS: search + pill bar sticky su mobile ─────────── */
@media (max-width: 768px) {
  #pos-search-wrap,
  #pos-cat-bar {
    position: sticky;
    top: -2px; /* sotto mob-actions-bar che è fuori da .content */
    z-index: 10;
    background: var(--bg);
    padding: 4px 0;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
}
body.force-mobile-pos #pos-search-wrap,
body.force-mobile-pos #pos-cat-bar {
  position: sticky;
  top: -2px;
  z-index: 10;
  background: var(--bg);
  padding: 4px 16px;
  margin: 0 -16px;
}

/* ── POS forzato mobile (iPad junior/senior) ──────────── */
body.force-mobile-pos .pos-cart-panel { display: none !important; }
body.force-mobile-pos #pos-wrap { height: calc(100vh - 120px - 52px) !important; }
body.force-mobile-pos #pos-grid {
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 8px !important;
  padding-bottom: 80px;
}
body.force-mobile-pos #pos-cart-fab { display: flex !important; }
body.force-mobile-pos.pos-checkout-open #pos-cart-fab { display: none !important; }
body.force-mobile-pos #pos-cart-items-sh .pos-ci { padding: 14px 4px !important; gap: 12px !important; }
body.force-mobile-pos #pos-cart-items-sh .pos-ci-th { width: 52px !important; height: 52px !important; font-size: 30px !important; border-radius: 8px !important; }
body.force-mobile-pos #pos-cart-items-sh .pos-ci-nome { font-size: 15px !important; }
body.force-mobile-pos #pos-cart-items-sh .pos-ci-btn { width: 36px !important; height: 36px !important; font-size: 20px !important; }
body.force-mobile-pos #pos-cart-items-sh .pos-ci-qty { font-size: 17px !important; min-width: 28px !important; }

/* ── POS Cart Bar (mobile) ─────────────────────────────── */
#pos-cart-fab {
  display: none;
  position: fixed;
  bottom: calc(56px + env(safe-area-inset-bottom, 0px)); /* sopra la bottom-nav */
  left: 0; right: 0;
  z-index: 525;
  height: 52px;
  background: var(--wk);
  color: #fff;
  border: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 20px;
  gap: 8px;
  box-shadow: 0 -2px 12px rgba(0,0,0,.15);
}
#pos-cart-fab-open {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  height: 100%;
}
#pos-cart-fab-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
#pos-cart-fab-left svg { width: 22px; height: 22px; flex-shrink: 0; }
#pos-cart-fab-badge {
  background: #fff;
  color: var(--wk);
  font-size: 11px;
  font-weight: 800;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
}
#pos-cart-fab-label {
  font-size: 15px;
  font-weight: 700;
}
#pos-cart-fab-total {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 768px) {
  #pos-cart-fab { display: flex; }
  /* nasconde la barra carrello quando il checkout è aperto */
  body.pos-checkout-open #pos-cart-fab { display: none !important; }
}

/* ── POS Cart Bottom Sheet ─────────────────────────────── */
#pos-cart-sheet {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
#pos-cart-sheet.open {
  pointer-events: all;
  opacity: 1;
}
#pos-cart-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
}
#pos-cart-sheet-box {
  position: relative;
  background: var(--surf);
  border-radius: 20px 20px 0 0;
  height: 92vh;
  height: 92dvh;
  max-height: 92vh;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.32,.72,0,1);
}
#pos-cart-sheet.open #pos-cart-sheet-box {
  transform: translateY(0);
}
#pos-cart-sheet-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--bdr);
  flex-shrink: 0;
}
#pos-cart-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
}
#pos-cart-sheet-ftr {
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--bdr);
  flex-shrink: 0;
}
