/* ============================================================
   MicroAnalytics — Stili principali
   Font: Inter (Google Fonts)
   Framework base: Bootstrap 5.3 (CDN)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800&display=swap');

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  /* Brand */
  --ma-primary:       #6366f1;
  --ma-primary-dark:  #4f46e5;
  --ma-primary-light: #818cf8;
  --ma-primary-glow:  rgba(99, 102, 241, 0.25);

  /* Status */
  --ma-success: #10b981;
  --ma-danger:  #ef4444;
  --ma-warning: #f59e0b;
  --ma-info:    #3b82f6;

  /* Sidebar */
  --sb-width:       260px;
  --sb-bg:          #0f172a;
  --sb-border:      rgba(255,255,255,0.06);
  --sb-text:        #94a3b8;
  --sb-text-hover:  #e2e8f0;
  --sb-hover-bg:    rgba(255,255,255,0.05);
  --sb-active-bg:   rgba(99,102,241,0.15);
  --sb-active-text: #a5b4fc;

  /* Layout */
  --body-bg:    #f1f5f9;
  --card-bg:    #ffffff;
  --border-col: #e2e8f0;
  --text-1:     #0f172a;
  --text-2:     #475569;
  --text-3:     #94a3b8;

  /* Misc */
  --radius:    12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --tr:        all .2s ease;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text-1);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ma-primary); }
a:hover { color: var(--ma-primary-dark); }

/* ============================================================
   APP WRAPPER
   ============================================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sb-width);
  background: var(--sb-bg);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 200;
  border-right: 1px solid var(--sb-border);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Logo */
.sb-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--sb-border);
  text-decoration: none;
}

.sb-logo-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--ma-primary), var(--ma-primary-light));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 17px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--ma-primary-glow);
}

.sb-logo-name {
  font-size: 15px; font-weight: 700; color: #fff;
  line-height: 1.2;
}

.sb-logo-ver {
  font-size: 11px; color: var(--sb-text); font-weight: 400;
}

/* Site selector */
.sb-site-selector {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--sb-border);
}

.sb-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--sb-text);
  display: block;
  margin-bottom: 8px;
}

.sb-select {
  width: 100%;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  color: #fff;
  padding: 8px 28px 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 11px;
  transition: var(--tr);
}

.sb-select:focus { outline: none; border-color: var(--ma-primary); }
.sb-select option { background: #1e293b; }

/* Nav */
.sb-nav { padding: 10px 8px; flex: 1; }

.sb-nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--sb-text);
  padding: 10px 10px 4px; margin-top: 4px;
  display: block;
}

.sb-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sb-text);
  text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: var(--tr);
  margin-bottom: 2px;
}

.sb-nav-item i { font-size: 16px; width: 18px; text-align: center; flex-shrink: 0; }
.sb-nav-item:hover  { background: var(--sb-hover-bg); color: var(--sb-text-hover); }
.sb-nav-item.active { background: var(--sb-active-bg); color: var(--sb-active-text); }

/* Sidebar footer / user */
.sb-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--sb-border);
}

.sb-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.sb-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--ma-primary), var(--ma-primary-light));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name  { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-email { color: var(--sb-text); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sb-logout {
  color: var(--sb-text);
  text-decoration: none;
  padding: 5px;
  border-radius: 6px;
  display: flex; align-items: center;
  transition: var(--tr);
  flex-shrink: 0;
}

.sb-logout:hover { color: var(--ma-danger); background: rgba(239,68,68,.1); }

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

/* ============================================================
   TOP HEADER
   ============================================================ */
.top-header {
  background: #fff;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-col);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  gap: 12px;
}

.page-title {
  font-size: 17px; font-weight: 700; color: var(--text-1);
  white-space: nowrap;
}

.header-right {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}

/* Date range buttons */
.date-group {
  display: flex;
  background: var(--body-bg);
  border: 1px solid var(--border-col);
  border-radius: var(--radius-sm);
  padding: 3px; gap: 2px;
}

.date-btn {
  padding: 5px 11px;
  border: none; background: transparent;
  color: var(--text-2);
  font-size: 12px; font-weight: 500;
  font-family: inherit;
  border-radius: 6px; cursor: pointer;
  transition: var(--tr); white-space: nowrap;
}

.date-btn:hover { background: #fff; color: var(--text-1); }
.date-btn.active {
  background: #fff; color: var(--text-1);
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

/* Realtime badge */
.realtime-badge {
  display: flex; align-items: center; gap: 6px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  padding: 5px 12px;
  border-radius: 20px; font-size: 12px; font-weight: 600;
  white-space: nowrap;
}

.rt-dot {
  width: 8px; height: 8px;
  background: #22c55e; border-radius: 50%;
  animation: rtPulse 2s ease-in-out infinite;
}

@keyframes rtPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(1.3); }
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content { padding: 24px; flex: 1; }

/* ============================================================
   CARDS
   ============================================================ */
.ma-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-col);
  transition: var(--tr);
}

.ma-card:hover { box-shadow: var(--shadow-md); }

.ma-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-col);
  display: flex; align-items: center; justify-content: space-between;
}

.ma-card-title {
  font-size: 13px; font-weight: 700; color: var(--text-1);
  display: flex; align-items: center; gap: 8px;
}

.ma-card-title i { color: var(--ma-primary); }

.ma-card-body { padding: 18px; }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border-col);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--tr);
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  border: 2px solid transparent;
  transition: var(--tr);
}

.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-card:hover::after { border-color: var(--ma-primary); opacity: .3; }

.kpi-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.kpi-icon.ci-primary { background: rgba(99,102,241,.12); color: var(--ma-primary); }
.kpi-icon.ci-success { background: rgba(16,185,129,.12); color: var(--ma-success); }
.kpi-icon.ci-warning { background: rgba(245,158,11,.12);  color: var(--ma-warning); }
.kpi-icon.ci-info    { background: rgba(59,130,246,.12);  color: var(--ma-info); }

.kpi-value {
  font-size: 30px; font-weight: 800; color: var(--text-1);
  line-height: 1; letter-spacing: -1px;
}

.kpi-label {
  font-size: 12.5px; color: var(--text-2); font-weight: 500;
  margin-top: 4px;
}

/* ============================================================
   ANALYTICS TABLE
   ============================================================ */
.at { width: 100%; border-collapse: collapse; }

.at th {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-col);
  text-align: left; white-space: nowrap; background: #fafbfc;
}

.at td {
  padding: 10px 12px; font-size: 13px; color: var(--text-1);
  border-bottom: 1px solid #f8fafc;
  vertical-align: middle;
}

.at tr:last-child td { border-bottom: none; }
.at tbody tr:hover td { background: #f8fafc; }

.at-url {
  max-width: 240px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  color: var(--ma-primary); font-weight: 500;
  display: block;
}

.at-title {
  font-size: 11px; color: var(--text-3); margin-top: 2px;
  max-width: 240px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

/* Bar cell */
.bar-cell { position: relative; }

.bar-bg {
  position: absolute;
  inset: 0;
  background: rgba(99,102,241,.07);
  transition: width .5s ease;
}

.bar-val { position: relative; z-index: 1; font-weight: 600; }

/* Source badge */
.src-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
}

.src-direct   { background: #f1f5f9; color: #475569; }
.src-organic  { background: #f0fdf4; color: #16a34a; }
.src-social   { background: #eff6ff; color: #1d4ed8; }
.src-email    { background: #fdf4ff; color: #7e22ce; }
.src-referral { background: #f0fdfa; color: #0f766e; }

/* ============================================================
   DEVICE LIST
   ============================================================ */
.dev-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-col);
}

.dev-item:last-child { border-bottom: none; }

.dev-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}

.dev-info { flex: 1; }
.dev-name { font-size: 13px; font-weight: 600; color: var(--text-1); }

.bar-micro {
  height: 4px; background: var(--border-col);
  border-radius: 2px; overflow: hidden; margin-top: 5px;
}

.bar-micro-fill {
  height: 100%; border-radius: 2px;
  transition: width 1s ease;
}

.dev-count { font-size: 13px; font-weight: 700; color: var(--text-1); text-align: right; }
.dev-pct   { font-size: 11px; color: var(--text-3); text-align: right; margin-top: 2px; }

/* ============================================================
   CHART
   ============================================================ */
.chart-wrap { position: relative; height: 270px; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-3);
}

.empty-state i { font-size: 40px; display: block; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 13.5px; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: radial-gradient(ellipse at 60% 0%, #2d1b69 0%, #0f172a 60%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.login-wrap {
  width: 100%; max-width: 400px;
}

.login-card {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 20px; padding: 40px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.login-head { text-align: center; margin-bottom: 32px; }

.login-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--ma-primary), var(--ma-primary-light));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #fff;
  margin: 0 auto 16px;
  box-shadow: 0 4px 20px var(--ma-primary-glow);
}

.login-head h1 { color: #fff; font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-head p  { color: rgba(255,255,255,.4); font-size: 13px; }

.login-form .form-label { color: rgba(255,255,255,.65); font-size: 13px; font-weight: 500; margin-bottom: 6px; }

.login-form .form-control {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: #fff; border-radius: 10px; padding: 11px 14px;
  font-size: 14px; font-family: inherit;
  transition: var(--tr);
}

.login-form .form-control:focus {
  background: rgba(255,255,255,.09);
  border-color: var(--ma-primary);
  box-shadow: 0 0 0 3px var(--ma-primary-glow);
  color: #fff; outline: none;
}

.login-form .form-control::placeholder { color: rgba(255,255,255,.22); }

.login-btn {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--ma-primary), var(--ma-primary-dark));
  border: none; border-radius: 10px;
  color: #fff; font-size: 14.5px; font-weight: 700;
  font-family: inherit; cursor: pointer;
  transition: var(--tr); letter-spacing: .3px;
}

.login-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px var(--ma-primary-glow);
}

.login-btn:disabled { opacity: .6; cursor: not-allowed; }

.login-alert {
  border-radius: 10px; padding: 11px 14px;
  font-size: 13px; margin-bottom: 16px;
}

.login-alert.danger {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.25);
  color: #fca5a5;
}

.login-alert.success {
  background: rgba(16,185,129,.12);
  border: 1px solid rgba(16,185,129,.25);
  color: #6ee7b7;
}

/* ============================================================
   SITES PAGE
   ============================================================ */
.site-card {
  background: var(--card-bg);
  border: 1px solid var(--border-col);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--tr);
}

.site-card:hover { box-shadow: var(--shadow-md); }

.site-card-domain {
  font-size: 16px; font-weight: 700; color: var(--text-1);
  margin-bottom: 2px;
}

.site-card-name { font-size: 13px; color: var(--text-2); margin-bottom: 12px; }

.tid-badge {
  font-family: 'Courier New', monospace;
  font-size: 11px; letter-spacing: 1px;
  background: #f1f5f9; color: #475569;
  padding: 3px 8px; border-radius: 5px;
  display: inline-block;
}

/* Stat pills */
.stat-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600;
}

.stat-pill.today { background: rgba(99,102,241,.1); color: var(--ma-primary); }
.stat-pill.month { background: rgba(16,185,129,.1); color: var(--ma-success); }

/* Code snippet */
.snippet-wrap {
  background: #0f172a;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  position: relative;
}

.snippet-wrap code {
  color: #e2e8f0;
  font-family: 'Courier New', monospace;
  font-size: 12px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-all;
  display: block;
}

.snippet-copy {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.6);
  padding: 3px 10px; border-radius: 5px;
  font-size: 11.5px; cursor: pointer;
  transition: var(--tr);
  font-family: inherit;
}

.snippet-copy:hover { background: rgba(255,255,255,.15); color: #fff; }

/* Tabs */
.snippet-tabs {
  display: flex; gap: 4px; margin-bottom: 10px;
}

.stab {
  padding: 5px 14px; border-radius: 7px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; border: none;
  background: #f1f5f9; color: var(--text-2);
  transition: var(--tr); font-family: inherit;
}

.stab.active {
  background: var(--ma-primary); color: #fff;
}

/* ============================================================
   FORM OVERRIDES (Bootstrap override)
   ============================================================ */
.form-control:focus {
  border-color: var(--ma-primary);
  box-shadow: 0 0 0 3px var(--ma-primary-glow);
}

.btn-primary {
  background: var(--ma-primary);
  border-color: var(--ma-primary);
}

.btn-primary:hover, .btn-primary:focus {
  background: var(--ma-primary-dark);
  border-color: var(--ma-primary-dark);
}

/* ============================================================
   ALERTS (no-site state)
   ============================================================ */
.no-site-msg {
  text-align: center; padding: 80px 20px;
}

.no-site-icon {
  width: 72px; height: 72px;
  background: rgba(99,102,241,.1);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: var(--ma-primary);
  margin: 0 auto 20px;
}

.no-site-msg h2 { font-size: 18px; font-weight: 700; color: var(--text-1); margin-bottom: 8px; }
.no-site-msg p  { color: var(--text-2); font-size: 14px; margin-bottom: 24px; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.anim { animation: fadeUp .35s ease both; }
.anim-d1 { animation-delay: .05s; }
.anim-d2 { animation-delay: .1s; }
.anim-d3 { animation-delay: .15s; }
.anim-d4 { animation-delay: .2s; }
.anim-d5 { animation-delay: .25s; }
.anim-d6 { animation-delay: .3s; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-content { border-radius: var(--radius); border: none; }
.modal-header  { border-bottom: 1px solid var(--border-col); padding: 16px 20px; }
.modal-body    { padding: 20px; }
.modal-footer  { border-top: 1px solid var(--border-col); padding: 14px 20px; }
.modal-title   { font-size: 15px; font-weight: 700; }

/* ============================================================
   MOBILE TOPBAR
   ============================================================ */
.mobile-topbar {
  display: none; /* mostrato via d-flex d-lg-none Bootstrap */
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--sb-bg);
  z-index: 300;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
  border-bottom: 1px solid var(--sb-border);
}

.hamburger-btn {
  background: none; border: none;
  color: var(--sb-text-hover);
  font-size: 22px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
  transition: var(--tr);
  flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--sb-hover-bg); color: #fff; }

.mobile-logo {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none;
  color: #fff; font-weight: 700; font-size: 15px;
}

/* Pulsante X nella sidebar (chiudi) */
.sb-close-btn {
  background: none; border: none;
  color: var(--sb-text);
  font-size: 16px; padding: 6px;
  border-radius: 6px; cursor: pointer;
  line-height: 1; transition: var(--tr);
}
.sb-close-btn:hover { color: #fff; background: var(--sb-hover-bg); }

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  z-index: 199;
  opacity: 0;
  transition: opacity .3s ease;
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ============================================================
   RESPONSIVE — lg (≤ 991px)
   ============================================================ */
@media (max-width: 991.98px) {
  :root { --sb-width: 240px; }
  .page-content { padding: 16px; }

  .top-header { padding: 10px 16px; gap: 8px; }

  /* Comprime i date-btn */
  .date-btn { padding: 5px 8px; font-size: 11px; }

  /* Snippet tabs su più righe se necessario */
  .date-group.d-inline-flex { flex-wrap: wrap; }
}

/* ============================================================
   RESPONSIVE — md (≤ 767px)  ← breakpoint principale mobile
   ============================================================ */
@media (max-width: 767.98px) {

  /* --- SIDEBAR DRAWER --- */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    z-index: 200;
    width: 280px;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }

  /* --- MAIN CONTENT --- */
  .main-content {
    margin-left: 0;
    padding-top: 56px; /* spazio per la mobile topbar fissa */
  }

  /* --- TOP HEADER (page header sotto la topbar mobile) --- */
  .top-header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
    position: sticky;
    top: 56px; /* sotto la mobile topbar */
  }

  .page-title { font-size: 15px; }

  /* Il badge del dominio scompare su mobile piccolo */
  .top-header .badge { display: none; }

  /* Header right: va a capo e occupa tutto lo schermo */
  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  /* Date group: scrollabile orizzontalmente */
  .date-group {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    max-width: 100%;
    scrollbar-width: none;
  }
  .date-group::-webkit-scrollbar { display: none; }
  .date-btn { white-space: nowrap; flex-shrink: 0; font-size: 11.5px; padding: 5px 9px; }

  /* Realtime badge compatto */
  .realtime-badge { font-size: 11px; padding: 4px 9px; }

  /* --- PAGE CONTENT --- */
  .page-content { padding: 12px; }

  /* --- KPI CARDS --- */
  .kpi-card { padding: 14px 16px; }
  .kpi-value { font-size: 26px; }
  .kpi-icon { width: 34px; height: 34px; font-size: 15px; }

  /* --- GRAFICO --- */
  .chart-wrap { height: 200px; }
  [style*="height: 320px"] { height: 200px !important; }

  /* --- TABELLE --- */
  .table-responsive { -webkit-overflow-scrolling: touch; }

  /* URL nelle top pages: meno troncamento */
  .at-url { max-width: 160px; }
  .at-title { max-width: 160px; }

  /* Colonna sessioni sparisce su mobile */
  .at th:last-child,
  .at td:last-child { display: none; }

  /* --- CARDS --- */
  .ma-card-header { padding: 12px 14px; }
  .ma-card-body { padding: 14px; }

  /* --- SITES PAGE --- */
  /* Stack verticale delle azioni (reset/delete) */
  .site-actions { flex-direction: column; align-items: flex-start !important; gap: 8px !important; }

  /* Snippet tabs wrap */
  .snippet-section .date-group { flex-wrap: wrap; gap: 4px; }
  .stab { font-size: 11px; padding: 4px 10px; }

  /* Snippet pre/code: font più piccolo */
  .snippet-wrap pre,
  .snippet-wrap code { font-size: 11px !important; }

  /* Quick stats: due colonne side-by-side */
  .snippet-section .col-lg-3 { margin-bottom: 12px; }

  /* --- USERS PAGE --- */
  /* Nasconde colonne secondarie tabella utenti */
  .users-table th:nth-child(3),
  .users-table td:nth-child(3) { display: none; }

  /* --- MODALS --- */
  .modal-dialog { margin: 12px; }

  /* --- DEVICES CHART --- */
  [style*="height: 200px"] { height: 160px !important; }
}

/* ============================================================
   RESPONSIVE — sm (≤ 575px)  ← smartphone piccoli
   ============================================================ */
@media (max-width: 575.98px) {
  .top-header { padding: 8px 12px; }
  .page-content { padding: 10px; }

  /* KPI a 1 colonna (Bootstrap col-6 rimane, ma compatta) */
  .kpi-value { font-size: 22px; letter-spacing: -.5px; }
  .kpi-card { padding: 12px 14px; }

  /* Bottom 2 col → stack */
  .kpi-top { margin-bottom: 8px; }

  /* Grafico ancora più compatto */
  [style*="height: 320px"] { height: 170px !important; }

  /* Snippet ancora più compatti */
  .snippet-wrap pre,
  .snippet-wrap code { font-size: 10px !important; }

  /* Pulsante copia snippet: solo icona */
  .snippet-wrap .btn-sm { font-size: 0 !important; width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center; }

  /* Nasconde il testo del pulsante nei snippet, lascia solo l'icona */
  .snippet-wrap .btn-sm::before { content: '⎘'; font-size: 14px; }

  .ma-card-header { padding: 10px 12px; }
  .ma-card-title { font-size: 12px; }
  .ma-card-body { padding: 12px; }
}

