/* ============================================================
   InDubai Portal — Design System
   ============================================================ */

:root {
  --primary: #1a3a5c;
  --primary-light: #2563a8;
  --accent: #c9a84c;
  --accent-light: #f0d080;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --surface2: #f7f9fc;
  --border: #dde3ed;
  --text: #1e2d42;
  --text-muted: #6b7a95;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --info: #0369a1;
  --info-bg: #e0f2fe;
  --pending-bg: #f3f4f6;
  --sidebar-w: 240px;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(26,58,92,0.08);
  --shadow-lg: 0 8px 32px rgba(26,58,92,0.14);
  --transition: 0.18s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── LAYOUT ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo .logo-mark {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
}
.sidebar-logo .logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 8px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.35);
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: all var(--transition);
  border-radius: 0;
  position: relative;
}
.nav-item:hover { color: white; background: rgba(255,255,255,0.07); }
.nav-item.active {
  color: white;
  background: rgba(201,168,76,0.18);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.nav-badge.warn { background: var(--warning); }
.nav-badge.info { background: var(--info); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user .avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--primary);
}
.sidebar-user .user-info { flex: 1; }
.sidebar-user .user-name { font-size: 13px; font-weight: 600; color: white; }
.sidebar-user .user-role { font-size: 11px; color: rgba(255,255,255,0.45); }
.btn-logout {
  background: none; border: none; color: rgba(255,255,255,0.4);
  cursor: pointer; padding: 4px; font-size: 16px;
  transition: color var(--transition);
}
.btn-logout:hover { color: var(--danger); }

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.topbar-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 1px;
}

.page-content {
  padding: 28px;
  flex: 1;
}

/* ── CARDS & KPIs ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius) var(--radius) 0 0;
}
.kpi-card.danger::after { background: var(--danger); }
.kpi-card.success::after { background: var(--success); }
.kpi-card.info::after { background: var(--info); }

.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; margin: 4px 0; }
.kpi-sub { font-size: 12px; color: var(--text-muted); }
.kpi-icon { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); font-size: 32px; opacity: 0.08; }

/* ── TABLE ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface2);
}
.card-title { font-size: 15px; font-weight: 700; flex: 1; }
.card-subtitle { font-size: 12px; color: var(--text-muted); }

.table-wrap { overflow-x: auto; width: 100%; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: var(--surface2);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
td {
  padding: 10px 14px;
  vertical-align: middle;
}
.td-company { font-weight: 600; color: var(--primary); }
.td-contact { font-size: 12px; color: var(--text-muted); }

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-fail { background: var(--danger-bg); color: var(--danger); }
.badge-warn { background: var(--warning-bg); color: var(--warning); }
.badge-pending { background: var(--pending-bg); color: var(--text-muted); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* Month grid badges */
.month-cell {
  width: 28px; height: 22px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
}
.month-ok { background: var(--success-bg); color: var(--success); }
.month-fail { background: var(--danger-bg); color: var(--danger); }
.month-warn { background: var(--warning-bg); color: var(--warning); }
.month-empty { background: var(--pending-bg); color: #ccc; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: var(--primary); }
.btn-accent:hover { background: var(--accent-light); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: 8px; }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(37,99,168,0.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── CHECKLIST ── */
.checklist { display: flex; flex-direction: column; gap: 10px; }
.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.check-item:hover { border-color: var(--primary-light); }
.check-item.done { background: var(--success-bg); border-color: var(--success); }
.check-item .check-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: all var(--transition);
}
.check-item.done .check-icon { background: var(--success); border-color: var(--success); color: white; }
.check-label { font-size: 13.5px; font-weight: 500; }
.check-item.done .check-label { text-decoration: line-through; color: var(--text-muted); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.modal-title { font-size: 17px; font-weight: 700; flex: 1; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── LOGIN ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #2563a8 100%);
}
.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .mark { font-size: 32px; font-weight: 900; color: var(--primary); }
.login-logo .sub { font-size: 12px; color: var(--text-muted); letter-spacing: 2px; text-transform: uppercase; margin-top: 4px; }
.login-title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 24px; }

/* ── SEARCH & FILTERS ── */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-box input {
  padding-left: 36px;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

/* ── PROGRESS BAR ── */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.progress-fill.green { background: var(--success); }
.progress-fill.orange { background: var(--warning); }
.progress-fill.red { background: var(--danger); }

/* ── ALERTS & TOAST ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(220,38,38,0.2); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(22,163,74,0.2); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(217,119,6,0.2); }

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; margin-bottom: 6px; color: var(--text); }
.empty-state p { font-size: 13px; }

/* ── LOADING ── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

/* ── MONTH GRID TABLE ── */
.month-grid-table th:not(:first-child) {
  text-align: center;
  width: 48px;
}
.month-grid-table td:not(:first-child) { text-align: center; }

/* ── DETAIL PAGE ── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.detail-section { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.detail-section.full { grid-column: 1 / -1; }
.detail-field { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; }
.detail-field:last-child { border-bottom: none; }
.detail-key { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; width: 140px; flex-shrink: 0; padding-top: 2px; }
.detail-val { font-size: 13.5px; flex: 1; }

/* ── DEADLINE INDICATORS ── */
.deadline-ok { color: var(--success); }
.deadline-soon { color: var(--warning); font-weight: 600; }
.deadline-overdue { color: var(--danger); font-weight: 700; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

/* ============================================================
   MOBILE RESPONSIVE — Complete overhaul
   ============================================================ */

/* Prevent horizontal scroll globally */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

/* Mobile hamburger button — hidden on desktop */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 6px;
  border: none;
  background: none;
  flex-shrink: 0;
  z-index: 200;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.25s ease;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

@media (max-width: 768px) {
  /* Show hamburger */
  .hamburger { display: flex; }

  /* Sidebar: slide in from left */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    width: 280px;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }

  /* Main content takes full width */
  .main-content {
    margin-left: 0 !important;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* Topbar */
  .topbar {
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 10px;
  }
  .topbar-title { font-size: 16px; }

  /* Page content */
  .page-content {
    padding: 16px;
    overflow-x: hidden;
  }

  /* KPI grid: 2 columns on mobile */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
  .kpi-card { padding: 14px 16px; }
  .kpi-value { font-size: 22px; }
  .kpi-icon { font-size: 22px; }

  /* Cards */
  .card { padding: 14px 16px; }

  /* Dashboard grid: single column */
  .dashboard-grid,
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="display: grid"] {
    grid-template-columns: 1fr !important;
  }

  /* Tables: horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }
  table { min-width: 500px; }
  th, td { padding: 8px 10px; font-size: 12px; }

  /* Forms */
  .form-row, .form-row-3 { grid-template-columns: 1fr !important; }

  /* Modals: full screen on mobile */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Tasks: single column */
  .tasks-wrap {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  /* Hide sidebar filters on mobile, show as horizontal scroll */
  .t-sidebar {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto;
    gap: 6px;
    padding: 10px !important;
    -webkit-overflow-scrolling: touch;
  }
  .t-sidebar .t-section-label,
  .t-sidebar .t-sep { display: none; }
  .t-filter {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 12px;
    padding: 6px 12px;
  }

  /* Task detail panel: full width below list */
  .t-detail {
    position: static !important;
    max-height: none !important;
  }

  /* Buttons */
  .btn { font-size: 13px; padding: 8px 14px; }
  .btn-sm { font-size: 11px; padding: 5px 10px; }

  /* Detail grid */
  .detail-grid { grid-template-columns: 1fr !important; }
  .detail-section.full { grid-column: 1 !important; }

  /* Client detail tabs */
  .tab-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    gap: 4px;
  }
  .tab-btn { white-space: nowrap; font-size: 12px; padding: 8px 12px; }

  /* User cards */
  .user-card { flex-wrap: wrap; gap: 10px; }
  .user-card .btn { font-size: 11px; padding: 5px 10px; }

  /* Hide non-essential columns on mobile */
  .hide-mobile { display: none !important; }

  /* Dashboard grids: single column */
  .dash-grid {
    grid-template-columns: 1fr !important;
  }

  /* Tables: proper horizontal scroll container */
  .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: block !important;
    width: 100% !important;
    max-width: calc(100vw - 32px) !important;
  }
  .table-wrap table {
    min-width: 480px;
    width: max-content;
    max-width: none;
  }

  /* Fix overflow on any inline grid styles */
  [style*="grid-template-columns: 260px"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns: 220px"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns: 1fr 2fr"] {
    grid-template-columns: 1fr !important;
  }
  [style*="display:grid"] {
    max-width: 100%;
  }

  /* Fix max-width containers */
  [style*="max-width:700px"],
  [style*="max-width:720px"],
  [style*="max-width:680px"],
  [style*="max-width:640px"] {
    max-width: 100% !important;
  }

  /* Notification dropdown */
  #notif-dropdown {
    right: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 0 0 12px 12px;
  }
}

/* Small phones */
@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr 1fr !important; }
  .kpi-value { font-size: 18px; }
  .page-content { padding: 12px; }
  .topbar { padding: 10px 12px; }
}

/* ═══════════════════════════════════════════════════════════
   iOS-STYLE MOBILE SHELL — Admin PWA
   ═══════════════════════════════════════════════════════════ */

/* iOS topbar — sostituisce hamburger su mobile */
.ios-admin-bar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  z-index: 300;
  background: rgba(15, 22, 40, 0.88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  padding-top: env(safe-area-inset-top, 0px);
}
.ios-admin-bar-logo {
  font-family: 'Playfair Display', 'Georgia', serif;
  font-size: 17px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.3px;
}
.ios-admin-bar-logo span { color: #c9a84c; }
.ios-admin-bar-page {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  pointer-events: none;
  white-space: nowrap;
}
.ios-admin-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ios-bar-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background .15s;
}
.ios-bar-btn:active { background: rgba(255,255,255,0.2); }
.ios-bar-badge {
  position: absolute;
  top: -3px; right: -3px;
  background: #dc2626;
  color: white;
  border-radius: 50%;
  width: 15px; height: 15px;
  font-size: 9px;
  font-weight: 800;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #0f1628;
}

/* Bottom navigation */
.ios-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 300;
  background: rgba(15, 22, 40, 0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.ios-bottom-nav-inner {
  display: flex;
  height: 56px;
}
.ios-bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  padding: 0;
  transition: color .15s;
  position: relative;
}
.ios-bnav-item.active { color: #c9a84c; }
.ios-bnav-item:active { color: rgba(201,168,76,0.7); }
.ios-bnav-icon { font-size: 19px; line-height: 1; }
.ios-bnav-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
.ios-bnav-dot {
  position: absolute;
  top: 6px; right: calc(50% - 14px);
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #dc2626;
  display: none;
  border: 1.5px solid #0f1628;
}

/* iOS sheet drawer (same as client portal) */
.ios-admin-sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 400;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity .3s;
}
.ios-admin-sheet-overlay.open { opacity: 1; }
.ios-admin-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 401;
  background: #1c1c1e;
  border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 20px);
  transform: translateY(100%);
  transition: transform .38s cubic-bezier(.32,.72,0,1);
  max-height: 88vh;
  overflow-y: auto;
}
.ios-admin-sheet.open { transform: translateY(0); }
.ios-admin-sheet-handle {
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  margin: 12px auto 6px;
}
.ios-admin-sheet-user {
  padding: 10px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.ios-admin-sheet-name { font-size: 15px; font-weight: 700; color: white; }
.ios-admin-sheet-role { font-size: 12px; color: rgba(255,255,255,0.4); margin-top:2px; }
.ios-admin-sheet-section {
  padding: 14px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.ios-admin-sheet-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 500;
  color: rgba(255,255,255,0.88);
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: none;
  width: 100%;
  border-left: none; border-right: none; border-top: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background .1s;
}
.ios-admin-sheet-link:active { background: rgba(255,255,255,0.06); }
.ios-admin-sheet-link.active-page { color: #c9a84c; }
.ios-admin-sheet-link .si-icon { font-size: 18px; width: 28px; text-align: center; }
.ios-admin-sheet-link .si-chevron { margin-left: auto; color: rgba(255,255,255,0.2); font-size: 13px; }
.ios-admin-sheet-logout {
  margin: 16px 16px 4px;
  padding: 14px;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.2);
  border-radius: 14px;
  color: #f87171;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: calc(100% - 32px);
  font-family: inherit;
}

/* Pull to refresh bar (admin) */
.admin-ptr-bar {
  position: fixed;
  top: 52px; left: 0; right: 0;
  z-index: 299;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.admin-ptr-bar.visible { opacity: 1; }
.admin-ptr-pill {
  background: white;
  border-radius: 20px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: #1a3a5c;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.admin-ptr-spin {
  width: 13px; height: 13px;
  border: 2.5px solid #e2e8f0;
  border-top-color: #1a3a5c;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes admin-spin { to { transform: rotate(360deg); } }
.admin-ptr-spin { animation: admin-spin .7s linear infinite; }

@media (max-width: 768px) {
  /* Hide desktop elements */
  .hamburger { display: none !important; }
  .topbar { display: none !important; }

  /* Show iOS elements */
  .ios-admin-bar { display: flex; }
  .ios-bottom-nav { display: block; }

  /* Compensate for fixed bars */
  .main-content {
    padding-top: calc(52px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    margin-left: 0 !important;
  }
  .page-content { padding: 14px; }
}

/* ============================================================
   FULL-WIDTH DESKTOP — layout aperto, niente boxing
   ============================================================ */

/* Layout base */
.app-layout { display: flex; min-height: 100vh; }
.main-content { flex: 1; min-width: 0; overflow-x: hidden; }

/* Sidebar sempre fissa su desktop */
@media (min-width: 901px) {
  .sidebar {
    position: fixed !important;
    top: 0; left: 0;
    height: 100vh;
    transform: translateX(0) !important;
    z-index: 100;
  }
  .main-content { margin-left: var(--sidebar-w) !important; }
  .hamburger { display: none !important; }
  .sidebar-overlay { display: none !important; }
}

/* page-content: padding generoso, mai max-width limitante */
@media (min-width: 901px) {
  .page-content {
    padding: 32px 36px;
    width: 100%;
    box-sizing: border-box;
    max-width: none !important;
  }
}

/* Topbar: sempre flex, no wrap */
.topbar {
  display: flex !important;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  box-sizing: border-box;
}
.topbar-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* KPI grid: usa tutto lo spazio disponibile */
@media (min-width: 901px) {
  .kpi-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) !important;
  }
}

/* Card: no max-width fisso — si espandono */
@media (min-width: 901px) {
  .card { max-width: none !important; }
}

/* Griglie inline con style: si adattano al container */
@media (min-width: 1100px) {
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
  [style*="grid-template-columns: repeat(2"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (min-width: 1400px) {
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* Tabelle: scroll orizzontale senza limitare la larghezza */
@media (min-width: 901px) {
  .table-wrap, .table-container { overflow-x: auto; width: 100%; }
  table { width: 100%; }
}

/* Notif panel: non esca dallo schermo */
#notif-panel { max-width: calc(100vw - 280px - 48px); right: 0; }

/* Rimuovi max-width hardcoded che boxano il layout */
@media (min-width: 901px) {
  [style*="max-width:700px"],
  [style*="max-width: 700px"],
  [style*="max-width:720px"],
  [style*="max-width: 720px"],
  [style*="max-width:800px"],
  [style*="max-width: 800px"],
  [style*="max-width:900px"],
  [style*="max-width: 900px"],
  [style*="max-width:1000px"],
  [style*="max-width: 1000px"] {
    max-width: 100% !important;
  }
}
