:root{
  --bg:#f4f4f4;
  --card:#ffffff;
  --border:#d7d7d7;
  --text:#17212b;
  --muted:#6f7b86;
  --primary:#19c98b;
  --secondary:#17324a;
  --danger:#ef3b3b;
  --warning:#f2a51a;
  --info:#176d9c;
  --sidebar:#122334;
  --sidebar-active:#21384d;
}
*{box-sizing:border-box}
html,body{width:100%;min-height:100%;margin:0;padding:0}
body{font-family:Arial,Helvetica,sans-serif;background:var(--bg);color:var(--text);font-size:14px;line-height:1.35}
a{color:var(--secondary);text-decoration:none}
a:hover{text-decoration:none}

/* Layout applicativo unico */
.app-body{overflow-x:hidden;background:var(--bg)}
.app-shell{width:100%;min-height:100vh;display:grid;grid-template-columns:220px minmax(0,1fr);background:var(--bg)}
.app-sidebar{grid-column:1;width:220px;min-height:100vh;background:var(--sidebar);color:#fff;padding:20px 16px;position:sticky;top:0;align-self:start;z-index:50}
.sidebar-brand{margin-bottom:32px}
.sidebar-title{font-size:18px;font-weight:800;letter-spacing:.2px;color:#fff}
.sidebar-subtitle{font-size:12px;color:#9fb0bf;margin-top:2px}
.sidebar-profile{text-align:center;margin-bottom:30px}
.sidebar-avatar{width:64px;height:64px;border-radius:50%;background:#e5e5e5;color:var(--sidebar);display:flex;align-items:center;justify-content:center;margin:0 auto 11px;font-size:26px;font-weight:800}
.sidebar-profile strong{display:block;color:#fff;font-weight:800}
.sidebar-profile span{display:block;color:#9fb0bf;font-size:12px;margin-top:2px}
.sidebar-nav{display:flex;flex-direction:column;gap:6px}
.sidebar-nav a{display:block;color:#d8e3ed;padding:12px 13px;border-radius:6px;font-weight:700}
.sidebar-nav a:hover,.sidebar-nav a.active{background:var(--sidebar-active);color:#fff}
.app-main{grid-column:2;min-width:0;min-height:100vh;background:var(--bg)}
.app-topbar{height:60px;background:#fff;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:18px;padding:0 24px;position:sticky;top:0;z-index:20}
.topbar-title strong{display:block;color:var(--secondary);font-size:18px}
.topbar-title span{display:block;color:var(--muted);font-size:12px;margin-top:2px}
.topbar-user{display:flex;align-items:center;gap:10px}
.topbar-user>span{background:#f0f2f4;border-radius:6px;padding:9px 12px;font-size:13px;font-weight:700;color:#334}
.sidebar-logout-btn,
.topbar-logout-form button{
  border:0;
  background:transparent;
  color:inherit;
  font:inherit;
  padding:0;
  cursor:pointer;
  text-align:left;
}
.sidebar-logout-btn{
  display:block;
  width:100%;
  color:#d8e3ed;
  padding:12px 13px;
  border-radius:6px;
  font-weight:700;
}
.sidebar-logout-btn:hover{
  background:var(--sidebar-active);
  color:#fff;
}
.topbar-logout-form{margin:0}
.topbar-logout-form button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:var(--secondary);
  color:#fff;
  border-radius:6px;
  padding:9px 12px;
  font-size:13px;
  font-weight:700;
}
.topbar-logout-form button:hover{filter:brightness(.98)}
.page-container{width:min(1320px,calc(100% - 56px));margin:24px auto 36px}

/* Nasconde layout legacy eventualmente emessi dai controller precedenti */
.app-shell .topbar,.app-shell .source-sidebar,.app-shell .fullscreen-layout>.source-sidebar,.app-shell .operator-layout>.source-sidebar{display:none!important}
.app-shell .operator-layout,.app-shell .fullscreen-layout{display:block!important;margin:0!important;padding:0!important}
.app-shell .operator-main{padding:0!important}
.app-shell .container{max-width:none;margin:0;padding:0}

/* Componenti base */
.card,.wizard-card,.source-panel,.device-card,.measure-card,.admin-card{background:var(--card);border:1px solid var(--border);border-radius:7px;padding:18px;box-shadow:0 1px 2px rgba(0,0,0,.05);margin-bottom:18px}
.card h1,.card h2,.wizard-card h1,.page-title-row h1{margin-top:0;color:#073052}
.muted{color:var(--muted)}
.grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px}
.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.two-cols{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:24px}
.card-head,.page-title-row{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:14px}
.hidden{display:none!important}
label{display:block;font-weight:700;margin:12px 0 6px}
input,select,textarea{width:100%;border:1px solid #cfcfcf;border-radius:5px;padding:9px 10px;background:#fff;font-size:14px}
textarea{min-height:86px;resize:vertical}
.btn,button.btn{display:inline-block;border:0;border-radius:5px;padding:10px 16px;font-weight:700;cursor:pointer;text-align:center;text-decoration:none;line-height:1.2}
.btn-primary{background:var(--primary);color:#fff}.btn-secondary{background:var(--secondary);color:#fff}.btn-danger{background:var(--danger);color:#fff}.btn-light{background:#e7e7e7;color:#333}.btn-outline{background:#fff;border:1px solid #111;color:#333}
.btn-small,.btn.small,.small{padding:7px 10px;font-size:12px}.btn.big{font-size:20px;padding:14px 58px}
.actions,.footer-actions{display:flex;gap:10px;align-items:center;margin-top:18px}.footer-actions{justify-content:space-between;border-top:1px solid var(--border);padding-top:16px}
table{width:100%;border-collapse:collapse;background:#fff}th,td{border-bottom:1px solid var(--border);text-align:left;padding:10px;vertical-align:top}th{background:#f0f0f0;color:#073052}.admin-card{overflow-x:auto}.admin-table{width:100%}.actions-col{min-width:180px}.row-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.inline-form{display:inline-flex;margin:0}
.badge{display:inline-block;border-radius:999px;padding:4px 9px;font-size:12px;font-weight:700;background:#eee}.badge-ok{background:#dff5ec;color:#09663f}.badge-warn{background:#fff4d8;color:#8a5a00}.badge-danger{background:#ffe1e1;color:#8b1f1f}.badge-info{background:#e6f3ff;color:#0b5f93}.green{color:#00a66a}.alert{border-radius:6px;padding:12px;background:#fff4d8;border:1px solid #f3d38a;margin-bottom:14px}.alert-success{background:#e7f8ef;border-color:#bce8cf;color:#12633a}.alert-danger{background:#fee2e2;border-color:#fecaca;color:#991b1b}.alert-info{background:#e6f3ff;border-color:#bfdbfe;color:#0b5f93}.inline{display:inline}

/* Tab */
.tabs{display:flex;gap:8px;margin-bottom:14px;flex-wrap:wrap}.tabs span,.tabs a{padding:9px 13px;background:#e7e7e7;border-radius:5px;font-weight:700}.tabs .active{background:var(--secondary);color:#fff}
.source-tabs,.device-tabs{display:flex;gap:0;border-bottom:2px solid #1f1f1f;margin:0 0 24px}.source-tabs a,.source-tabs span,.device-tabs a,.device-tabs span{padding:12px 22px;color:#888;font-weight:700;font-size:18px}.source-tabs .active,.device-tabs .active{color:#111;border-bottom:3px solid #111;margin-bottom:-2px}.device-tabs{justify-content:space-around}
.admin-tabs{display:flex;gap:8px;margin:0 0 14px;border-bottom:1px solid #d8d8d8}.admin-tabs a{padding:10px 14px;color:#4d5965;border-bottom:3px solid transparent;font-weight:700}.admin-tabs a.active{color:#0d2f4f;border-bottom-color:#0d2f4f}

/* Wizard e form dispositivo */
.wizard-card{padding:0}.wizard-card h1{font-size:28px;color:#999;border-bottom:1px solid var(--border);padding:18px;margin:0}.wizard-card form{padding:24px 18px 0}.wizard-steps{display:flex;align-items:center;justify-content:center;gap:12px;margin:16px 0 28px}.wizard-steps span{color:#999}.wizard-steps .active{color:var(--secondary);font-weight:700}.wizard-steps span:before{content:'1';display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;background:var(--secondary);color:#fff;border-radius:50%;font-size:11px;margin-right:6px}.wizard-steps span:nth-of-type(2):before{content:'2'}.wizard-steps b{height:2px;background:var(--secondary);width:70px}.source-form{padding:0 18px 18px}.phone-line{display:flex}.phone-line span{display:inline-flex;align-items:center;justify-content:center;min-width:78px;border:1px solid #aaa;border-right:0;background:#fff;border-radius:5px 0 0 5px}.phone-line input{border-radius:0 5px 5px 0}.bar-title{background:var(--secondary);color:#fff;text-align:center;border-radius:5px;padding:8px;margin:16px 0 18px}.bar-title.outline{background:#fff;color:var(--secondary);border:1px solid #14a3d2}.spaced{margin-top:28px}.disabled-like{background:#e9ecef;color:#777}

/* Range/toggle */
.range-row{display:grid;grid-template-columns:1fr 48% 100px;gap:14px;align-items:center;border-bottom:1px solid #eee;padding:12px 0}.range-row p{font-size:12px;color:#777;margin:5px 0 0}.compact-range{grid-template-columns:120px 1fr 120px}.range-value{font-weight:700;color:#111}input[type=range]{padding:0;accent-color:#2285c6}.toggle-row{display:flex!important;align-items:center;gap:12px;margin:12px 0}.toggle-row input{display:none}.toggle-row i{width:28px;height:14px;background:#bbb;border-radius:999px;position:relative;order:-1;flex:0 0 auto}.toggle-row i:after{content:'';position:absolute;width:12px;height:12px;background:#fff;border-radius:50%;top:1px;left:1px}.toggle-row input:checked+i{background:#1d78a0}.toggle-row input:checked+i:after{left:15px}.toggle-row small{display:block;color:#777;font-weight:400;margin-top:4px}.condition-list{max-width:360px}.sms-row{margin:20px 0}

/* Dashboard operativa */
.searchbar{display:flex;gap:12px;align-items:center;margin-bottom:22px}.searchbar input{max-width:380px}.inactive-box{margin:20px 0}.inactive-box input{width:60%;display:block}.operator-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin:20px 0}.operator-stats div{background:#fff;border:1px solid var(--border);border-radius:7px;padding:14px}.operator-stats b{display:block;font-size:28px}.operator-stats span{color:#777}.operator-stats .danger b,.operator-stats .danger span{color:#c50000}.user-card-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px}.user-tile{background:#fff;border:1px solid var(--border);border-radius:7px;overflow:hidden}.user-tile .tile-icons{padding:12px;color:var(--secondary)}.user-tile .patient-row{display:flex;align-items:center;gap:10px;padding:0 14px}.user-tile h2{font-size:22px;margin:0}.user-tile p{padding:0 14px;color:#777}.tile-btn{display:block;background:var(--secondary);color:#fff;text-align:center;padding:12px}

/* Dettaglio dispositivo, grafici, farmaci */
.device-header{display:flex;justify-content:space-between;align-items:center;color:#888;font-size:18px;margin:18px 0}.select-like{border:1px solid var(--secondary);background:#fff;border-radius:6px;padding:10px 22px}.device-card{display:grid;grid-template-columns:1fr 1fr;gap:40px;min-height:420px;background:#f7f7f7}.patient-title{display:flex;align-items:center;gap:16px}.patient-title h1,.patient-title h2{margin:0;color:#111}.watch-icon{font-size:44px}.device-left p{font-size:17px;color:#999}.device-left strong{color:#111}.details-link{display:block;margin-top:60px;font-weight:700}.device-right{padding-top:20px}.device-right .block{display:block;width:210px;margin:0 0 14px auto;font-size:18px}.red-dot{display:inline-block;width:9px;height:9px;background:#c60000;border-radius:50%;margin-left:6px}.status-icons{text-align:right;font-size:26px}.measure-card{background:#eee}.chart-head{display:flex;justify-content:space-between;align-items:center}.chart-head small{color:#777;font-weight:400}.chart-head b{background:var(--secondary);color:#fff;padding:7px 10px;font-size:12px}.css-chart{height:230px;border-left:1px solid #ddd;border-bottom:1px solid #ddd;display:flex;align-items:flex-end;gap:18px;padding:20px 14px 35px;margin:10px 0;background:repeating-linear-gradient(to top,#eee 0,#eee 23px,#ddd 24px)}.bar{width:20px;background:var(--info);position:relative}.bar:nth-child(even){background:#8ab3c9}.bar span{position:absolute;bottom:-34px;left:-22px;width:70px;transform:rotate(-35deg);font-size:10px;color:#777}.chart-stats{display:flex;justify-content:space-around;color:#888;margin-top:28px}.grey-card{background:#eee}.pager b,.pager span{display:inline-block;padding:6px 10px;margin:10px 2px;background:#fff}.pager b{background:var(--secondary);color:#fff}

/* Sensori */
.sensor-panel{text-align:center;min-height:360px}.sensor-tabs{display:flex;justify-content:space-around;border-bottom:1px solid #111;margin-bottom:50px}.sensor-tabs span{font-size:20px;padding:15px;width:50%;color:#999}.sensor-tabs .active{color:var(--secondary);border-bottom:2px solid #111}.sensor-panel p{font-size:20px;color:#8a8a8a;max-width:1200px;margin:40px auto}

/* SOS */
.live-toolbar{display:flex;justify-content:space-between;align-items:center;gap:16px;margin:12px 0 18px}.sos-panel.has-alarms{border:2px solid var(--danger);box-shadow:0 0 0 3px rgba(239,59,59,.08)}.alarm-card{border:1px solid #f0b7b7;background:#fffafa;border-left:8px solid var(--danger);border-radius:8px;padding:14px;margin:10px 0}.alarm-actions{display:flex;gap:8px;margin-top:10px}.sos-modal{position:fixed;inset:0;background:rgba(0,0,0,.55);z-index:99;display:flex;align-items:center;justify-content:center}.sos-box{width:430px;background:#fff;border:4px solid var(--danger);border-radius:7px;overflow:hidden}.sos-box .modal-body{padding:22px}.sos-box h3{text-align:center;color:#999}.sos-accept{display:block;background:var(--danger);color:#fff;text-align:center;font-size:18px;font-weight:700;padding:13px}.sos-detail-page{max-width:1200px;margin:0 auto}.sos-top{display:grid;grid-template-columns:420px 1fr;gap:34px;align-items:start}.sos-order-card{border:4px solid var(--danger);background:#fff;border-radius:7px;overflow:hidden}.sos-order-card h3{color:#999;text-align:center}.sos-order-card p,.sos-order-card .patient-title{padding:0 24px}.sos-order-card>div:last-child{background:var(--danger);color:#fff;text-align:center;font-size:20px;font-weight:700;padding:12px}.accordion{background:#fff;border:1px solid #ddd;padding:15px;margin:0 0 8px}.radio-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:18px 0}.sos-manage-form textarea{min-height:110px}.map-heading{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-bottom:14px}.map-heading h2{margin:0;font-size:20px}.real-map{height:260px;border:1px solid #d5d5d5;background:#e9eef2;overflow:hidden}.real-map iframe{display:block;width:100%;height:100%;border:0}.sos-radio-grid{display:grid;grid-template-columns:1fr 1fr;column-gap:52px;row-gap:18px;margin:18px 0 26px;align-items:center}.sos-radio-grid .radio-option{display:flex!important;align-items:center;gap:10px;margin:0;font-weight:700;line-height:1.25;min-height:30px}.sos-radio-grid .radio-option input[type=radio]{width:auto!important;min-width:14px;height:14px;margin:0;flex:0 0 auto;padding:0}.sos-manage-form input[type=radio]{width:auto!important}

/* Login */
.login-body{background:#f4f4f4}.login-page{min-height:100vh;display:grid;grid-template-columns:1.1fr .9fr}.login-hero{background:var(--secondary);color:#fff;display:flex;align-items:center;padding:48px}.login-hero h1{font-size:44px;margin:10px 0}.login-hero p{font-size:17px;color:#e6edf3;max-width:620px}.login-card-wrap{display:flex;align-items:center;justify-content:center;padding:48px}.login-card{width:min(520px,100%);background:#fff;border:1px solid var(--border);border-radius:14px;padding:32px;box-shadow:0 22px 46px rgba(0,0,0,.12)}.login-card h1{margin-top:0;color:#073052}.login-role-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;margin-top:28px}.login-role-grid div{background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.16);border-radius:12px;padding:16px}.login-role-grid strong{display:block;margin-bottom:8px}.login-role-grid span{display:block;color:rgba(255,255,255,.82);font-size:13px;line-height:1.45}

/* Utility responsive */
@media(max-width:1100px){.app-shell{grid-template-columns:1fr}.app-sidebar{position:relative;width:100%;min-height:auto}.sidebar-nav{flex-direction:row;flex-wrap:wrap}.app-main{grid-column:1}.app-topbar{height:auto;align-items:flex-start;padding:14px;flex-direction:column}.page-container{width:calc(100% - 32px);margin:16px auto}.grid,.form-grid,.two-cols,.device-card,.sos-top{grid-template-columns:1fr}.operator-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.user-card-grid{grid-template-columns:1fr}.inactive-box input{width:100%}.range-row{grid-template-columns:1fr}.source-tabs a,.source-tabs span,.device-tabs a,.device-tabs span{font-size:14px;padding:9px}.login-page{grid-template-columns:1fr}.login-hero{display:none}}
@media(max-width:700px){.operator-stats{grid-template-columns:1fr}.topbar-user{width:100%;justify-content:space-between}.sos-radio-grid,.radio-grid{grid-template-columns:1fr}.real-map{height:220px}.css-chart{gap:8px;overflow-x:auto}.card-head,.page-title-row{display:block}.btn{margin-top:4px}}


/* --- Fix UI 2026-05-13: admin users + alarm stats --- */
.page-header-row,
.page-heading-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:18px;
  margin-bottom:18px;
}
.page-header-row h1,
.page-heading-row h1{
  margin:0 0 6px;
  font-size:28px;
  line-height:1.15;
  color:#102f48;
}
.page-header-row p,
.page-heading-row p{margin:4px 0 0}
.mb-16{margin-bottom:16px}
.filter-form,
.alarm-filter-form{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:12px;
  align-items:end;
}
.filter-actions,
.form-actions,
.actions-cell{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}
.form-actions,
.filter-actions,
.span-2{grid-column:1 / -1}
.inline-form{display:inline-flex;margin:0}
.table{width:100%;border-collapse:separate;border-spacing:0}
.table th{background:#f6f9fb;color:#415364;font-size:12px;text-transform:uppercase;letter-spacing:.03em}
.table th,
.table td{padding:12px;border-bottom:1px solid #e6edf2;text-align:left;vertical-align:top}
.table tr:hover td{background:#fbfdfe}
.pagination-row{display:flex;flex-wrap:wrap;gap:8px;margin-top:16px}
.page-link{display:inline-flex;align-items:center;justify-content:center;min-width:36px;padding:8px 12px;border:1px solid #d9e1e7;border-radius:8px;background:#fff;color:#102f48;font-weight:700}
.page-link.active{background:var(--secondary);border-color:var(--secondary);color:#fff}
.badge-blue{background:#dbeafe;color:#1e40af}
.badge-green{background:#dcfce7;color:#166534}
.badge-red{background:#fee2e2;color:#991b1b}
.stats-grid,
.alarm-stats-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:14px;
  margin:0 0 18px;
}
.stat-card{
  background:#fff;
  border:1px solid #dce4ea;
  border-radius:14px;
  padding:16px 18px;
  box-shadow:0 6px 20px rgba(15,35,52,.05);
}
.stat-card strong{
  display:block;
  font-size:30px;
  line-height:1;
  color:#102f48;
  margin-bottom:8px;
}
.stat-card span{
  display:block;
  font-weight:700;
  color:#667789;
}
@media(max-width:1100px){
  .filter-form,
  .alarm-filter-form,
  .stats-grid,
  .alarm-stats-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .page-header-row,
  .page-heading-row{display:block}
}
@media(max-width:700px){
  .filter-form,
  .alarm-filter-form,
  .stats-grid,
  .alarm-stats-grid{grid-template-columns:1fr}
}

/* --- Fix 2026-05-13: associazione opzionale braccialetto --- */
.bracelet-choice-form .source-form{
  padding-top:22px;
}
.choice-card{
  border:1px solid #dce4ea;
  border-radius:14px;
  background:#f8fbfd;
  padding:16px 18px;
  margin-bottom:18px;
}
.checkbox-choice{
  display:flex !important;
  align-items:flex-start;
  gap:12px;
  margin:0;
  cursor:pointer;
}
.checkbox-choice input[type=checkbox]{
  width:18px;
  min-width:18px;
  height:18px;
  margin-top:2px;
  accent-color:var(--primary);
}
.checkbox-choice strong{
  display:block;
  color:#102f48;
  font-size:15px;
  margin-bottom:4px;
}
.checkbox-choice small{
  display:block;
  color:var(--muted);
  font-weight:400;
  line-height:1.45;
}
.bracelet-imei-field{
  border-top:1px solid #e4eaf0;
  padding-top:16px;
  margin-top:4px;
}
.bracelet-imei-field[hidden]{
  display:none !important;
}
.field-help{
  margin:7px 0 0;
  font-size:12px;
}


/* --- Global SOS alarm popup su tutte le pagine autenticate --- */
.global-sos-modal{
  position:fixed;
  inset:0;
  z-index:9999;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:rgba(8,18,28,.62);
  backdrop-filter:blur(2px);
}
.global-sos-modal.hidden{display:none!important}
.global-sos-box{
  width:min(560px,100%);
  background:#fff;
  border:4px solid var(--danger);
  border-radius:18px;
  overflow:hidden;
  box-shadow:0 30px 80px rgba(0,0,0,.35);
  animation:globalSosIn .18s ease-out;
}
.global-sos-header{
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:flex-start;
  background:#fff5f5;
  border-bottom:1px solid #fecaca;
  padding:18px 20px;
}
.global-sos-kicker{
  display:block;
  color:#991b1b;
  font-size:12px;
  font-weight:900;
  letter-spacing:.08em;
  text-transform:uppercase;
  margin-bottom:4px;
}
.global-sos-header h2{
  margin:0;
  color:#7f1d1d;
  font-size:26px;
  line-height:1.1;
}
.global-sos-close{
  width:36px;
  height:36px;
  border:0;
  border-radius:999px;
  background:#fee2e2;
  color:#991b1b;
  font-size:26px;
  line-height:1;
  cursor:pointer;
}
.global-sos-body{padding:20px}
.global-sos-main-row{
  display:flex;
  align-items:center;
  gap:14px;
  margin-bottom:16px;
}
.global-sos-main-row strong{
  display:block;
  color:#111827;
  font-size:22px;
  line-height:1.15;
}
.global-sos-main-row span:not(.global-sos-icon){
  display:block;
  color:#6b7280;
  margin-top:3px;
}
.global-sos-icon{
  width:54px;
  height:54px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 auto;
  background:#fee2e2;
  border-radius:16px;
  font-size:30px;
}
.global-sos-data{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
  margin:0;
}
.global-sos-data div{
  background:#f8fafc;
  border:1px solid #e5e7eb;
  border-radius:12px;
  padding:10px 12px;
}
.global-sos-data dt{
  font-size:11px;
  color:#64748b;
  text-transform:uppercase;
  letter-spacing:.04em;
  font-weight:800;
}
.global-sos-data dd{
  margin:3px 0 0;
  color:#111827;
  font-weight:800;
}
.global-sos-address{
  margin:14px 0 0;
  padding:12px;
  border-radius:12px;
  background:#fff7ed;
  color:#7c2d12;
  font-weight:700;
}
.global-sos-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  border-top:1px solid #e5e7eb;
  padding:16px 20px;
  background:#f8fafc;
}
.has-global-sos-modal{overflow:hidden}
@keyframes globalSosIn{
  from{opacity:0;transform:translateY(10px) scale(.98)}
  to{opacity:1;transform:translateY(0) scale(1)}
}
@media(max-width:640px){
  .global-sos-modal{padding:12px;align-items:flex-end}
  .global-sos-data{grid-template-columns:1fr}
  .global-sos-actions{flex-direction:column-reverse}
  .global-sos-actions .btn{width:100%}
}

/* --- Referenti strutturati Dettagli utente 2026-05-13 --- */
.section-help{margin-top:-4px;margin-bottom:14px}
.form-alert{border-radius:7px;padding:13px 14px;margin:0 0 18px;border:1px solid #ddd;background:#fff}
.form-alert strong{display:block;margin-bottom:6px}
.form-alert ul{margin:6px 0 0 18px;padding:0}
.form-alert-danger{border-color:#fecaca;background:#fff1f1;color:#8f1f1f}
.referents-accordion{display:grid;gap:10px;margin:12px 0 24px}
.referent-card{background:#fff;border:1px solid #cfd6dc;border-radius:7px;overflow:hidden;box-shadow:0 1px 2px rgba(0,0,0,.03)}
.referent-card summary{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:42px;padding:11px 13px;cursor:pointer;list-style:none;font-weight:800;color:#17212b;background:#fbfcfd}
.referent-card summary::-webkit-details-marker{display:none}
.referent-card summary:before{content:'▸';font-size:13px;color:#6f7b86;transition:transform .16s ease;margin-right:2px}
.referent-card[open] summary:before{transform:rotate(90deg)}
.referent-card summary span{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.referent-card summary small{font-size:11px;color:#6f7b86;background:#eef2f5;border-radius:999px;padding:4px 8px;text-transform:uppercase;letter-spacing:.03em}
.referent-fields{padding:14px;border-top:1px solid #e5eaee;background:#fff}
.referent-other-field[hidden]{display:none!important}
.health-profile-form .footer-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:18px}
@media(max-width:700px){.referent-card summary{align-items:flex-start}.referent-card summary span{white-space:normal}.health-profile-form .footer-actions{display:block}.health-profile-form .footer-actions .btn{width:100%;margin-top:8px}}


/* Audit log + profilo utente */
.alert{border-radius:12px;padding:12px 14px;margin:0 0 16px;font-weight:700}
.alert-success{background:#dcfce7;border:1px solid #bbf7d0;color:#166534}
.alert-danger{background:#fee2e2;border:1px solid #fecaca;color:#991b1b}
.profile-card{margin-bottom:16px}
.profile-card h2{margin:0 0 14px;color:#102f48;font-size:20px}
.details-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
.details-grid>div{background:#f8fafc;border:1px solid #e2e8f0;border-radius:12px;padding:12px}
.details-grid span,.details-grid strong{display:block}
.details-grid strong{margin-top:6px;color:#102f48}
.topbar-profile-link{background:#f4f6f8;border-radius:8px;padding:8px 10px;color:#102f48;text-decoration:none;font-weight:700}
.topbar-profile-link:hover{background:#e8eef3}
.table-card{overflow-x:auto}
@media(max-width:900px){.details-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:620px){.details-grid{grid-template-columns:1fr}}

/* --- 3CX live calls + doctors demo 2026-05-13 --- */
.threecx-live-panel{margin-bottom:22px;border-left:5px solid #102f48}
.threecx-live-head{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;margin-bottom:14px}
.threecx-live-head h2{margin:0 0 6px;color:#102f48}
.threecx-live-status{display:flex;align-items:center;gap:10px;white-space:nowrap}
.threecx-duty-box{display:flex;align-items:center;gap:12px;flex-wrap:wrap;background:#f6f9fb;border:1px solid #dce4ea;border-radius:12px;padding:12px 14px;margin-bottom:14px}
.threecx-duty-box strong{color:#687789;text-transform:uppercase;font-size:12px;letter-spacing:.04em}
.threecx-duty-box span{font-weight:800;color:#102f48}
.threecx-duty-box small{color:#687789}
.threecx-call-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.threecx-call-card{background:#fff;border:1px solid #dce4ea;border-radius:14px;padding:14px;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:center;box-shadow:0 8px 24px rgba(16,47,72,.05)}
.threecx-call-card.is-transferred{border-color:#86efac;background:#f0fdf4}
.threecx-call-card.live-new{border-color:#86efac;box-shadow:0 0 0 2px rgba(34,197,94,.12),0 12px 26px rgba(16,47,72,.08)}
.threecx-call-card.live-new .threecx-call-main strong{color:#0f5132}
.threecx-call-main{display:flex;align-items:center;gap:10px;min-width:0}
.threecx-call-main strong{display:block;color:#111827;font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.threecx-call-main span{display:block;color:#687789;font-size:13px;margin-top:3px}
.threecx-call-dot{width:12px;height:12px;border-radius:999px;background:#64748b;box-shadow:0 0 0 4px rgba(100,116,139,.14);flex:0 0 auto}
.threecx-call-dot.incoming{background:#ef4444;box-shadow:0 0 0 4px rgba(239,68,68,.14)}
.threecx-call-dot.in_call{background:#22c55e;box-shadow:0 0 0 4px rgba(34,197,94,.14)}
.threecx-call-meta{grid-column:1 / -1;display:flex;gap:12px;flex-wrap:wrap;color:#4b5563;font-size:13px;border-top:1px solid #eef2f6;padding-top:10px}
.threecx-transfer-btn{white-space:nowrap;align-self:start}
.threecx-transfer-result{grid-column:1 / -1;border-radius:10px;padding:10px 12px;background:#eff6ff;color:#1e3a8a;font-weight:700;font-size:13px}
.threecx-transfer-result.error{background:#fee2e2;color:#991b1b}
.compact-form label{display:flex;flex-direction:column;gap:6px;font-weight:700;color:#102f48}
.check-row{justify-content:center;align-self:end;min-height:42px;flex-direction:row!important;align-items:center!important}
.alert-success{background:#dcfce7;border:1px solid #86efac;color:#166534;padding:12px;border-radius:10px;margin-bottom:14px;font-weight:700}
@media(max-width:1050px){.threecx-call-list{grid-template-columns:1fr}.threecx-live-head{display:block}.threecx-live-status{margin-top:10px}.threecx-call-card{grid-template-columns:1fr}.threecx-transfer-btn{width:100%}}

/* --- 3CX call history + transfer workflow 2026-05-13 --- */
.threecx-transfer-result.in-progress{background:#fff7ed;color:#9a3412;border:1px solid #fed7aa}
.threecx-transfer-btn[disabled]{opacity:.72;cursor:not-allowed}
.call-history-card{padding:0;overflow:auto}
.call-history-table{min-width:1120px}
.call-history-table td{vertical-align:top;font-size:13px}
.call-history-table td strong{color:#102f48}
.call-error{display:inline-block;margin-top:4px;color:#991b1b;font-weight:700}
.doctor-actions-cell{align-items:flex-start}
.inline-select-form select{min-height:34px;border:1px solid #cfd8e3;border-radius:8px;padding:6px 8px;background:#fff;color:#102f48;font-weight:700}
.badge-red{background:#fee2e2;color:#991b1b}
.badge-green{background:#dcfce7;color:#166534}
@media(max-width:800px){.call-history-card{margin-left:-10px;margin-right:-10px;border-radius:0}.doctor-actions-cell{display:grid!important;grid-template-columns:1fr;gap:8px}.inline-select-form select{width:100%}}

/* --- 3CX prelievo chiamata + triage urgenza demo --- */
.threecx-urgency-card{grid-column:1 / -1;background:#f8fafc;border:1px solid #d7e0ea;border-radius:12px;padding:12px;margin-top:2px}
.threecx-urgency-card strong{display:block;color:#102f48;margin-bottom:4px}
.threecx-urgency-card p{margin:0 0 10px;color:#5f6b77;font-size:13px}
.threecx-urgency-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
.threecx-urgency-btn{border:1px solid #d1d9e2;border-radius:10px;background:#fff;padding:10px 8px;text-align:left;cursor:pointer;font-weight:800;color:#102f48}
.threecx-urgency-btn span,.threecx-urgency-btn small{display:block}
.threecx-urgency-btn small{font-weight:600;color:#65758b;margin-top:3px}
.threecx-urgency-btn.urgency-white{border-color:#d1d5db;background:#fff}
.threecx-urgency-btn.urgency-green{border-color:#86efac;background:#f0fdf4}
.threecx-urgency-btn.urgency-yellow{border-color:#fde68a;background:#fffbeb}
.threecx-urgency-btn.urgency-red{border-color:#fecaca;background:#fef2f2;color:#991b1b}
.threecx-urgency-btn:hover{box-shadow:0 6px 18px rgba(16,47,72,.10);transform:translateY(-1px)}
@media(max-width:900px){.threecx-urgency-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:520px){.threecx-urgency-grid{grid-template-columns:1fr}}

/* Configurazione integrazioni */
.settings-grid{display:grid;grid-template-columns:1fr;gap:18px}
.integration-card{border-left:4px solid #12324b}
.section-title-row{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:16px}
.section-title-row h2{margin:0 0 6px;color:#102f48}
.compact-form label{font-weight:700;color:#0d2f49}
.compact-form label input,.compact-form label select{margin-top:7px}
.check-row{display:flex!important;align-items:center;gap:10px;min-height:42px;padding:10px 12px;border:1px solid #dce4ea;border-radius:10px;background:#f8fafc}
.check-row input{width:auto!important;margin:0!important}
.integration-status-card .badge{align-self:flex-start}
.integration-test-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center;justify-content:flex-end}
.integration-test-actions form{margin:0}
.threecx-action-form{margin:0}
.threecx-page-note{margin-top:14px;padding:12px 14px;border:1px solid #dce4ea;border-radius:12px;background:#f8fbfd;color:#4f6171}
.advanced-diagnostics{margin-top:18px}
.advanced-diagnostics summary{display:flex;align-items:center;justify-content:space-between;gap:12px;cursor:pointer;list-style:none}
.advanced-diagnostics summary::-webkit-details-marker{display:none}
.advanced-diagnostics-body{margin-top:14px}
@media(max-width:900px){.section-title-row{display:block}.section-title-row form{margin-top:10px}}

/* Pazienti */
.patient-page-header{margin-bottom:16px}
.patient-header-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.patient-search-card{margin-bottom:16px}
.patient-search-head{display:flex;justify-content:space-between;gap:12px;align-items:flex-start;margin-bottom:12px}
.patient-search-head h2{margin:0;color:#102f48}
.patient-search-meta{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.patient-filter-form{display:grid;grid-template-columns:minmax(0,1fr) 180px 180px auto;gap:10px;align-items:end}
.patient-filter-form label{display:flex;flex-direction:column;gap:6px;font-weight:700;color:#102f48}
.patient-filter-form input,.patient-filter-form select{margin-top:0;min-height:42px}
.patient-filter-search{grid-column:1 / span 1}
.patient-filter-area,.patient-filter-sort{min-width:0}
.patient-filter-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap;justify-content:flex-end}
.patient-chip-row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-top:12px}
.patient-chip-group{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.patient-chip-group span{font-size:12px;font-weight:700;color:#617080;text-transform:uppercase;letter-spacing:.03em}
.patient-chip{display:inline-flex;align-items:center;gap:6px;padding:7px 11px;border:1px solid #cfdbe5;border-radius:999px;background:#fff;color:#18324a;font-weight:700;font-size:13px;text-decoration:none;transition:background .15s ease,border-color .15s ease,color .15s ease}
.patient-chip:hover,.patient-chip:focus{border-color:#9db1c2;background:#f3f8fb}
.patient-chip.active{background:#102f48;border-color:#102f48;color:#fff}
.patient-inactivity-card{margin-bottom:16px}
.patient-inactivity-row{display:flex;align-items:center;gap:14px;justify-content:space-between}
.patient-inactivity-copy{display:flex;flex-direction:column;gap:4px;min-width:0}
.patient-inactivity-label{font-size:12px;font-weight:800;letter-spacing:.04em;text-transform:uppercase;color:#617080}
.patient-inactivity-copy strong{display:block;color:#102f48;font-size:20px;line-height:1}
.patient-inactivity-copy small{color:#617080}
.patient-inactivity-card input[type=range]{width:220px;max-width:35vw}
.patient-cards-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.patient-card{display:block;padding:0;overflow:hidden}
.patient-card summary{list-style:none;cursor:pointer;display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 16px}
.patient-card summary::-webkit-details-marker{display:none}
.patient-card[open]{box-shadow:0 12px 28px rgba(16,47,72,.09)}
.patient-card-summary-main{min-width:0;flex:1}
.patient-card-title-row{display:flex;justify-content:space-between;gap:10px;align-items:flex-start}
.patient-card-title-row h3{margin:0;color:#102f48;font-size:18px;line-height:1.2}
.patient-card-summary-meta{display:flex;flex-wrap:wrap;gap:8px;margin-top:6px;color:#617080;font-size:13px}
.patient-card-toggle{font-size:12px;font-weight:800;color:#617080;white-space:nowrap;padding-top:2px}
.patient-card-body{padding:0 16px 16px;border-top:1px solid #e4ebf0}
.patient-card-summary-badges{display:flex;flex-wrap:wrap;gap:8px;padding:14px 0 10px}
.patient-card-detail-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.patient-card-detail-grid div{border:1px solid #dce4ea;border-radius:10px;background:#f8fbfd;padding:9px 11px;min-width:0}
.patient-card-detail-grid strong{display:block;color:#102f48;font-size:11px;text-transform:uppercase;letter-spacing:.03em;margin-bottom:4px}
.patient-card-detail-grid span{display:block;color:#17212b;overflow-wrap:anywhere}
.patient-card-span-2{grid-column:1 / -1}
.patient-card-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}
.patient-card-actions .btn-small{padding:8px 12px;font-size:13px}
.patient-empty-state{grid-column:1 / -1}
.patient-empty-state h2{margin:0 0 6px;color:#102f48}
@media(max-width:1100px){
  .patient-filter-form{grid-template-columns:minmax(0,1fr) 1fr 1fr}
  .patient-chip-row{grid-template-columns:1fr}
  .patient-cards-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .patient-card-detail-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:700px){
  .patient-filter-form,.patient-cards-grid,.patient-card-detail-grid,.patient-chip-row{grid-template-columns:1fr}
  .patient-filter-form{gap:8px}
  .patient-search-head,.patient-inactivity-row,.patient-card-summary{display:block}
  .patient-filter-actions{justify-content:stretch}
  .patient-filter-actions .btn,.patient-inactivity-card input[type=range],.patient-card-actions .btn,.patient-card-actions form{width:100%}
  .patient-header-actions{width:100%}
  .patient-header-actions .btn{width:100%}
  .patient-card-summary-badges,.patient-card-actions,.patient-chip-group{width:100%}
}

/* 3CX temporary debug panel */
.threecx-debug-panel{
  margin-top:18px;
  padding:16px;
  border:1px dashed #9fb2c4;
  border-radius:12px;
  background:#f8fbfd;
}
.threecx-debug-panel h3{
  margin:0 0 4px;
  font-size:16px;
  color:#12324b;
}
.debug-meta{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin:12px 0;
}
.debug-meta span{
  display:inline-flex;
  align-items:center;
  gap:4px;
  padding:6px 10px;
  border:1px solid #d7e0e8;
  border-radius:999px;
  background:#fff;
  color:#3f5568;
  font-size:12px;
}
.debug-json{
  max-height:420px;
  overflow:auto;
  margin:12px 0 0;
  padding:14px;
  border:1px solid #d7e0e8;
  border-radius:10px;
  background:#0d1b2a;
  color:#dbeafe;
  font-size:12px;
  line-height:1.55;
  white-space:pre-wrap;
  word-break:break-word;
}

/* Hotfix 3CX debug and integration container */
.settings-grid, .integration-card, .threecx-debug-panel, .debug-pre {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.debug-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.debug-actions form { margin: 0; }
.debug-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.debug-meta-grid > div {
  border: 1px solid #d7e0e8;
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  min-width: 0;
}
.debug-meta-grid strong,
.debug-meta-grid span {
  display: block;
  overflow-wrap: anywhere;
}
.debug-meta-grid strong { color: #102f48; font-size: 12px; margin-bottom: 4px; }
.debug-pre {
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  background: #0d1b2a;
  color: #dbeafe;
  border-radius: 12px;
  padding: 14px;
  font-size: 12px;
  line-height: 1.5;
}
@media (max-width: 900px) {
  .debug-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .debug-actions { justify-content: flex-start; margin-top: 10px; }
}
@media (max-width: 560px) {
  .debug-meta-grid { grid-template-columns: 1fr; }
}


.threecx-section-title{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;margin:14px 0 10px}
.threecx-section-title h3{margin:0;color:#102f48;font-size:16px}
.threecx-user-status-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-bottom:16px}
.threecx-user-status-card{display:flex;align-items:flex-start;gap:10px;border:1px solid #dce4ea;border-radius:12px;background:#fff;padding:12px;min-width:0;box-shadow:0 8px 20px rgba(16,47,72,.04)}
.threecx-user-status-card strong{display:block;color:#111827;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.threecx-user-status-card small{display:block;color:#687789;margin-top:3px;font-size:12px}
.threecx-user-status-card em{display:block;color:#102f48;margin-top:6px;font-style:normal;font-size:12px;font-weight:700;background:#eef6ff;border-radius:8px;padding:5px 7px;overflow:hidden;text-overflow:ellipsis}
.threecx-user-status-dot{width:11px;height:11px;margin-top:3px;border-radius:999px;background:#94a3b8;box-shadow:0 0 0 4px rgba(148,163,184,.16);flex:0 0 auto}
.threecx-user-status-dot.status-available{background:#22c55e;box-shadow:0 0 0 4px rgba(34,197,94,.14)}
.threecx-user-status-dot.status-in_call,.threecx-user-status-dot.status-busy{background:#f97316;box-shadow:0 0 0 4px rgba(249,115,22,.14)}
.threecx-user-status-dot.status-ringing{background:#3b82f6;box-shadow:0 0 0 4px rgba(59,130,246,.14)}
.threecx-user-status-dot.status-offline,.threecx-user-status-dot.status-unknown{background:#94a3b8;box-shadow:0 0 0 4px rgba(148,163,184,.16)}
.threecx-user-status-card.status-in_call,.threecx-user-status-card.status-busy{border-color:#fed7aa;background:#fff7ed}
.threecx-user-status-card.status-ringing{border-color:#bfdbfe;background:#eff6ff}
.threecx-user-status-card.status-available{border-color:#bbf7d0;background:#f0fdf4}
@media(max-width:1050px){.threecx-user-status-grid{grid-template-columns:1fr}.threecx-section-title{display:block}.threecx-section-title .muted{display:block;margin-top:4px}}

/* SOS vs allarmi tecnici */
.operator-stats .warning {
  border-left: 4px solid #f59e0b;
}
.emergency-panel.has-alarms {
  border-left: 5px solid #dc2626;
}
.device-alert-panel {
  border-left: 5px solid #f59e0b;
}
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.device-alert-list {
  display: grid;
  gap: 12px;
}
.device-alert-card {
  border: 1px solid #facc15;
  background: #fffbeb;
  border-radius: 10px;
  padding: 12px;
}
.device-alert-card strong {
  color: #92400e;
}
.btn-warning {
  background: #f59e0b;
  color: #111827;
  border: 0;
}
.btn-warning:hover {
  filter: brightness(0.95);
}

/* Dashboard: pazienti con eventi aperti */
.highlighted-patients-panel {
  margin-top: 18px;
}

.alert-only-grid .user-tile {
  border-width: 1px;
  border-style: solid;
}

.tile-emergency {
  border-color: #fecaca;
  background: #fff7f7;
}

.tile-device-alert {
  border-color: #facc15;
  background: #fffbeb;
}

.tile-emergency .tile-icons {
  color: #b91c1c;
  font-weight: 700;
}

.tile-device-alert .tile-icons {
  color: #92400e;
  font-weight: 700;
}

.danger-text {
  color: #b91c1c;
}

.warn-text {
  color: #92400e;
}

.highlighted-patients-panel .tile-btn {
  display: block;
  text-align: center;
}

.device-alert-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.inline-form {
  display: inline;
}

.btn-success {
  background: #10b981;
  color: #ffffff;
  border: 0;
}

.btn-success:hover {
  filter: brightness(0.95);
}

.device-alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.inline-form {
  display: inline;
}

.btn-success {
  background: #10b981;
  color: #ffffff;
  border: 0;
}

.btn-success:hover {
  filter: brightness(0.95);
}

/* Storico chiamate 3CX */
.call-history-filters {
  align-items: end;
}

.call-history-table td,
.call-history-table th {
  vertical-align: top;
}

.pagination-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-secondary {
  background: #e5e7eb;
  color: #374151;
}

/* Storico chiamate 3CX - filtri compatti */
.call-history-filter-card {
  padding: 14px 16px;
}

.call-history-compact-filters {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(170px, 1fr);
  gap: 10px 12px;
  align-items: end;
}

.call-history-compact-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
}

.call-history-compact-filters input,
.call-history-compact-filters select {
  height: 34px;
  padding: 6px 8px;
  font-size: 13px;
}

.call-history-compact-filters .filter-search {
  grid-column: span 1;
}

.call-history-compact-filters .filter-mini,
.call-history-compact-filters .filter-date {
  min-width: 0;
}

.call-history-compact-filters .filter-actions {
  display: flex;
  gap: 8px;
  align-items: end;
}

.call-history-compact-filters .filter-actions .btn {
  height: 34px;
  padding: 7px 14px;
}

@media (min-width: 1100px) {
  .call-history-compact-filters {
    grid-template-columns:
      minmax(300px, 2fr)
      minmax(150px, 1fr)
      minmax(150px, 1fr)
      minmax(170px, 1fr)
      minmax(90px, .7fr)
      minmax(130px, .8fr)
      minmax(130px, .8fr)
      minmax(130px, .8fr)
      auto;
  }

  .call-history-compact-filters .filter-actions {
    grid-column: auto;
  }
}

@media (max-width: 1099px) {
  .call-history-compact-filters {
    grid-template-columns: 1fr 1fr;
  }

  .call-history-compact-filters .filter-search {
    grid-column: span 2;
  }

  .call-history-compact-filters .filter-actions {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .call-history-compact-filters {
    grid-template-columns: 1fr;
  }

  .call-history-compact-filters .filter-search,
  .call-history-compact-filters .filter-actions {
    grid-column: span 1;
  }
}

/* Fix layout filtri storico chiamate: compatto, dentro card, max 2 righe desktop */
.call-history-filter-card {
  overflow: hidden;
}

.call-history-compact-filters {
  display: grid;
  grid-template-columns:
    minmax(260px, 2fr)
    minmax(120px, .8fr)
    minmax(140px, 1fr)
    minmax(150px, 1fr)
    minmax(85px, .6fr)
    minmax(120px, .8fr)
    minmax(115px, .7fr)
    minmax(115px, .7fr);
  gap: 10px;
  align-items: end;
  width: 100%;
}

.call-history-compact-filters label {
  min-width: 0;
  margin: 0;
}

.call-history-compact-filters input,
.call-history-compact-filters select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.call-history-compact-filters .filter-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.call-history-compact-filters .filter-actions .btn {
  min-width: 70px;
}

@media (max-width: 1100px) {
  .call-history-compact-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .call-history-compact-filters .filter-search {
    grid-column: span 2;
  }

  .call-history-compact-filters .filter-actions {
    grid-column: span 4;
  }
}

@media (max-width: 760px) {
  .call-history-compact-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .call-history-compact-filters .filter-search,
  .call-history-compact-filters .filter-actions {
    grid-column: span 2;
  }
}

@media (max-width: 520px) {
  .call-history-compact-filters {
    grid-template-columns: 1fr;
  }

  .call-history-compact-filters .filter-search,
  .call-history-compact-filters .filter-actions {
    grid-column: span 1;
  }

  .call-history-compact-filters .filter-actions {
    justify-content: stretch;
  }

  .call-history-compact-filters .filter-actions .btn {
    flex: 1;
  }
}

/* Planetcall audio alerts */
.planetcall-audio-enable {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  border: 0;
  border-radius: 999px;
  background: #0f3654;
  color: #ffffff;
  font-weight: 700;
  padding: 10px 14px;
  box-shadow: 0 8px 22px rgba(0,0,0,.18);
  cursor: pointer;
}

.planetcall-audio-enable:hover {
  filter: brightness(1.06);
}

.planetcall-audio-enable.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}

/* 3CX live UI stabilizer */
.threecx-user-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid #d7e2ec;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.threecx-user-card.is-available {
  background: #ecfdf3;
  border-color: #86efac;
}

.threecx-user-card.is-ringing {
  background: #fff7ed;
  border-color: #fdba74;
}

.threecx-user-card.is-busy {
  background: #eff6ff;
  border-color: #93c5fd;
}

.threecx-user-card.is-dnd {
  background: #fef2f2;
  border-color: #fca5a5;
}

.threecx-user-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-top: 3px;
  background: #94a3b8;
}

.threecx-user-card.is-available .threecx-user-dot {
  background: #22c55e;
}

.threecx-user-card.is-ringing .threecx-user-dot {
  background: #f97316;
}

.threecx-user-card.is-busy .threecx-user-dot {
  background: #3b82f6;
}

.threecx-user-card.is-dnd .threecx-user-dot {
  background: #ef4444;
}

.threecx-call-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #fdba74;
  border-radius: 10px;
  padding: 12px;
  background: #fff7ed;
  margin-bottom: 10px;
}

.threecx-call-number {
  font-size: 18px;
  font-weight: 800;
  color: #0f2435;
  margin: 4px 0;
}

/* Hard 3CX live renderer override */
.threecx-user-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid #d7e2ec;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  min-height: 56px;
}

.threecx-user-card.is-available {
  background: #ecfdf3;
  border-color: #86efac;
}

.threecx-user-card.is-ringing {
  background: #fff7ed;
  border-color: #fdba74;
}

.threecx-user-card.is-busy {
  background: #eff6ff;
  border-color: #93c5fd;
}

.threecx-user-card.is-dnd {
  background: #fef2f2;
  border-color: #fca5a5;
}

.threecx-user-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-top: 3px;
  background: #94a3b8;
  flex: 0 0 auto;
}

.threecx-user-card.is-available .threecx-user-dot {
  background: #22c55e;
}

.threecx-user-card.is-ringing .threecx-user-dot {
  background: #f97316;
}

.threecx-user-card.is-busy .threecx-user-dot {
  background: #3b82f6;
}

.threecx-user-card.is-dnd .threecx-user-dot {
  background: #ef4444;
}

.threecx-call-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #fdba74;
  border-radius: 10px;
  padding: 12px;
  background: #fff7ed;
  margin-bottom: 10px;
}

.threecx-call-number {
  font-size: 18px;
  font-weight: 800;
  color: #0f2435;
  margin: 4px 0;
}

/* 3CX live hard renderer */
.threecx-user-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid #d7e2ec;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  min-height: 56px;
}

.threecx-user-card.is-available {
  background: #ecfdf3;
  border-color: #86efac;
}

.threecx-user-card.is-ringing {
  background: #fff7ed;
  border-color: #fdba74;
}

.threecx-user-card.is-busy {
  background: #eff6ff;
  border-color: #93c5fd;
}

.threecx-user-card.is-dnd {
  background: #fef2f2;
  border-color: #fca5a5;
}

.threecx-user-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-top: 3px;
  background: #94a3b8;
  flex: 0 0 auto;
}

.threecx-user-card.is-available .threecx-user-dot {
  background: #22c55e;
}

.threecx-user-card.is-ringing .threecx-user-dot {
  background: #f97316;
}

.threecx-user-card.is-busy .threecx-user-dot {
  background: #3b82f6;
}

.threecx-user-card.is-dnd .threecx-user-dot {
  background: #ef4444;
}

.threecx-call-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #fdba74;
  border-radius: 10px;
  padding: 12px;
  background: #fff7ed;
  margin-bottom: 10px;
}

.threecx-call-number {
  font-size: 18px;
  font-weight: 800;
  color: #0f2435;
  margin: 4px 0;
}

/* 3CX live actions */
.threecx-hard-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.planetcall-audio-enable {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  border: 0;
  border-radius: 999px;
  background: #0f3654;
  color: #ffffff;
  font-weight: 700;
  padding: 10px 14px;
  box-shadow: 0 8px 22px rgba(0,0,0,.18);
  cursor: pointer;
}

.planetcall-audio-enable:hover {
  filter: brightness(1.06);
}

.planetcall-audio-enable.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}

/* Profilo - preferenze audio */
.profile-audio-form input[type="range"] {
  width: 100%;
  margin-top: 8px;
}

.profile-audio-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* Profilo - preferenze audio */
.profile-audio-form input[type="range"] {
  width: 100%;
  margin-top: 8px;
}

.profile-audio-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* Profilo utente */
.profile-card {
  margin-bottom: 16px;
}

.profile-card h2 {
  margin: 0 0 14px;
  color: #102f48;
  font-size: 20px;
}

.profile-details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.profile-details-grid div {
  border: 1px solid #d7e2ec;
  border-radius: 10px;
  padding: 12px;
  background: #f8fbfd;
}

.profile-details-grid span {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: #496174;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.profile-details-grid strong {
  color: #001f35;
}

.profile-audio-form input[type="range"] {
  width: 100%;
  margin-top: 8px;
}

.profile-audio-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 800px) {
  .profile-details-grid {
    grid-template-columns: 1fr;
  }
}

/* 3CX live card: layout operativo pulito */
.threecx-call-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px 14px;
  align-items: start;
  padding: 14px 16px;
}

.threecx-call-card .threecx-call-main {
  grid-column: 1 / -1;
  min-width: 0;
  padding-right: 0;
}

.threecx-call-card .threecx-transfer-btn {
  grid-column: 2;
  grid-row: 2;
  justify-self: end;
  align-self: end;
  min-width: 120px;
  white-space: nowrap;
  margin: 0;
}

.threecx-call-card .threecx-call-meta {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  min-width: 0;
}

.threecx-call-card .threecx-call-meta span {
  white-space: nowrap;
}

.threecx-call-card .threecx-transfer-result {
  grid-column: 1 / -1;
  margin-top: 4px;
}

.threecx-urgency-card {
  display: none !important;
}

@media (max-width: 760px) {
  .threecx-call-card {
    grid-template-columns: 1fr;
  }

  .threecx-call-card .threecx-transfer-btn,
  .threecx-call-card .threecx-call-meta {
    grid-column: 1;
    grid-row: auto;
    justify-self: stretch;
  }
}

/* 3CX live safety renderer */
.threecx-call-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 14px;
  align-items: center;
  padding: 14px 16px;
}

.threecx-call-main {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.threecx-call-main strong {
  font-size: 16px;
}

.threecx-call-main small {
  color: #425b70;
}

.threecx-call-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  min-width: 0;
}

.threecx-call-actions {
  justify-self: end;
  display: flex;
  gap: 8px;
  align-items: center;
}

.threecx-pickup-btn,
.threecx-transfer-btn {
  min-width: 110px;
  white-space: nowrap;
}

.threecx-call-card.ringing {
  border-color: #ff9800;
  background: #fff8ec;
}

.threecx-call-card.in_call {
  border-color: #24c96b;
  background: #effdf5;
}

.threecx-user-card.ringing {
  border-color: #ff9800;
  background: #fff8ec;
}

.threecx-user-card.busy {
  border-color: #4b8dff;
  background: #eef5ff;
}

@media (max-width: 760px) {
  .threecx-call-card {
    grid-template-columns: 1fr;
  }

  .threecx-call-actions {
    justify-self: stretch;
  }

  .threecx-pickup-btn,
  .threecx-transfer-btn {
    width: 100%;
  }
}

/* 3CX live stable renderer */
.threecx-call-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 14px;
  align-items: center;
  padding: 14px 16px;
}

.threecx-call-main {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.threecx-call-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.threecx-call-actions {
  justify-self: end;
}

.threecx-pickup-btn,
.threecx-transfer-btn {
  min-width: 130px;
  white-space: nowrap;
}

.threecx-transfer-result {
  grid-column: 1 / -1;
  background: #eef5ff;
  border-radius: 8px;
  padding: 10px 12px;
  color: #06327a;
  font-weight: 700;
}

.threecx-call-card.ringing {
  border-color: #ff9800;
  background: #fff8ec;
}

.threecx-call-card.in_call {
  border-color: #24c96b;
  background: #effdf5;
}

.threecx-user-card.ringing {
  border-color: #ff9800;
  background: #fff8ec;
}

.threecx-user-card.busy {
  border-color: #4b8dff;
  background: #eef5ff;
}

@media (max-width: 760px) {
  .threecx-call-card {
    grid-template-columns: 1fr;
  }

  .threecx-call-actions {
    justify-self: stretch;
  }

  .threecx-pickup-btn,
  .threecx-transfer-btn {
    width: 100%;
  }
}
