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

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

:root,
[data-theme="dark"] {
  --bg:        #111318;
  --bg2:       #16191f;
  --bg3:       #1c1f27;
  --bg4:       #21242e;
  --bg5:       #272b37;
  --border:    #252932;
  --border2:   #2e3340;
  --text:      #d4dae8;
  --text-muted:#8a9bbf;
  --text-dim:  #55637a;
  --accent:    #4f88f0;
  --accent2:   #7aa8f8;
  --accent-glow: rgba(79,136,240,.25);
  --green:     #2ecc71;
  --green-dim: rgba(46,204,113,.12);
  --yellow:    #e8a020;
  --yellow-dim:rgba(232,160,32,.12);
  --red:       #e05555;
  --red-dim:   rgba(224,85,85,.12);
  --purple:    #a78bfa;
  --purple-dim:rgba(167,139,250,.12);
  --cyan:      #22d3ee;
  --sidebar-w: 220px;
  --radius:    10px;
  --radius-lg: 14px;
}

[data-theme="light"] {
  --bg:        #f4f6fb;
  --bg2:       #ffffff;
  --bg3:       #f0f2f7;
  --bg4:       #e8ebf2;
  --bg5:       #dde1eb;
  --border:    #dde1eb;
  --border2:   #c8cedd;
  --text:      #1e2433;
  --text-muted:#5a6680;
  --text-dim:  #9aa3b8;
  --accent:    #3b72d9;
  --accent2:   #2a5ccc;
  --accent-glow: rgba(59,114,217,.2);
  --green:     #18a057;
  --green-dim: rgba(24,160,87,.1);
  --yellow:    #c47d10;
  --yellow-dim:rgba(196,125,16,.1);
  --red:       #c93535;
  --red-dim:   rgba(201,53,53,.1);
  --purple:    #7c5cbf;
  --purple-dim:rgba(124,92,191,.1);
  --cyan:      #0891b2;
}

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

a { color: var(--accent2); text-decoration: none; }
a:hover { color: #93c5fd; text-decoration: none; }
code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 12px; background: var(--bg4);
  padding: 2px 7px; border-radius: 5px; color: #7dd3fc;
}

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
  padding: 0;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-icon {
  width: 36px; height: 36px; border-radius: 9px;
  background: #2a5ccc;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand .brand-icon svg { color: #fff; }
.sidebar-brand .brand-name {
  font-size: 14px; font-weight: 700; color: var(--text);
  line-height: 1.2;
}
.sidebar-brand .brand-sub {
  font-size: 10px; color: var(--text-dim); font-weight: 400;
}

.sidebar-nav {
  flex: 1; padding: 12px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar-label {
  font-size: 10px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 10px 10px 4px;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  transition: all .15s;
}
.sidebar-nav a:hover { color: var(--text); background: var(--bg4); }
.sidebar-nav a.active {
  color: var(--accent2);
  background: linear-gradient(90deg, rgba(59,130,246,.15), rgba(59,130,246,.05));
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}
.sidebar-nav a svg { flex-shrink: 0; opacity: .8; }
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: #2a5ccc;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--text-dim); }
.btn-logout {
  color: var(--text-dim); font-size: 12px; padding: 4px 8px;
  border-radius: 6px; transition: all .15s;
  margin-top: 4px; display: block; text-align: center;
  border: 1px solid var(--border);
}
.btn-logout:hover { color: var(--red); border-color: rgba(239,68,68,.4); background: var(--red-dim); }

/* ─── Main content ───────────────────────────────────────────────────────── */
.main-with-nav {
  margin-left: var(--sidebar-w);
  padding: 2rem 2rem 3rem;
  min-height: 100vh;
  flex: 1;
}
.main-full {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 2rem; min-height: 100vh;
}

/* ─── Page header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.75rem;
}
.page-header h2 {
  font-size: 22px; font-weight: 700;
  color: var(--text);
}
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 3px; display: block; }
.breadcrumb { font-size: 12px; color: var(--text-dim); display: block; margin-bottom: 4px; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.card-header {
  padding: .8rem 1.25rem;
  font-size: 13px; font-weight: 600; color: var(--text);
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 1.25rem; }
.card-body.p-0 { padding: 0; }

/* ─── Stat cards ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  cursor: default;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--glow-color,rgba(59,130,246,.04)), transparent 60%);
  pointer-events: none;
}
.stat-card:hover { border-color: var(--border2); transform: translateY(-1px); box-shadow: 0 4px 20px rgba(0,0,0,.3); }
.stat-card.blue  { --glow-color: rgba(59,130,246,.08); }
.stat-card.green { --glow-color: rgba(34,197,94,.08); }
.stat-card.red   { --glow-color: rgba(239,68,68,.08); }
.stat-card.yellow{ --glow-color: rgba(245,158,11,.08); }
.stat-card.purple{ --glow-color: rgba(167,139,250,.08); }

.stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon-blue   { background: rgba(79,136,240,.14);  color: var(--accent2); }
.stat-icon-green  { background: rgba(46,204,113,.14);  color: var(--green); }
.stat-icon-red    { background: rgba(224,85,85,.14);   color: var(--red); }
.stat-icon-yellow { background: rgba(232,160,32,.14);  color: var(--yellow); }
.stat-icon-purple { background: rgba(167,139,250,.14); color: var(--purple); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; letter-spacing: -.5px; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }

/* ─── GDPR bar ───────────────────────────────────────────────────────────── */
.gdpr-bar {
  height: 12px; border-radius: 6px;
  background: var(--bg4); overflow: hidden; display: flex;
}
.gdpr-segment { height: 100%; transition: width .6s cubic-bezier(.4,0,.2,1); }
.gdpr-ok       { background: linear-gradient(90deg, #16a34a, #22c55e); }
.gdpr-warning  { background: linear-gradient(90deg, #d97706, #f59e0b); }
.gdpr-critical { background: linear-gradient(90deg, #b91c1c, #ef4444); }
.gdpr-legend { display: flex; gap: 1.5rem; margin-top: .85rem; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-green  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.dot-red    { background: var(--red); box-shadow: 0 0 6px var(--red); }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: .65rem 1.1rem; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim); background: var(--bg3);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td {
  padding: .65rem 1.1rem; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text); vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover td { background: rgba(255,255,255,.025); }
.table a { color: var(--accent2); font-weight: 500; }
.table a:hover { color: #bfdbfe; }
.tag-link {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.25);
  color: var(--accent2); font-size: 12px; font-weight: 500;
  transition: background .15s;
}
.tag-link:hover { background: rgba(59,130,246,.2); color: #bfdbfe; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-success  { background: var(--green-dim);  color: #4ade80; border: 1px solid rgba(34,197,94,.25); }
.badge-warning  { background: var(--yellow-dim); color: #fbbf24; border: 1px solid rgba(245,158,11,.25); }
.badge-danger   { background: var(--red-dim);    color: #f87171; border: 1px solid rgba(239,68,68,.25); }
.badge-primary  { background: rgba(59,130,246,.12); color: var(--accent2); border: 1px solid rgba(59,130,246,.25); }
.badge-secondary{ background: var(--bg4); color: var(--text-muted); border: 1px solid var(--border); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 8px; font-size: 13px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  transition: all .15s; text-decoration: none; white-space: nowrap; line-height: 1;
  font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent2); border-color: var(--accent2);
  box-shadow: 0 0 12px var(--accent-glow); color: #fff;
}
.btn-secondary { background: var(--bg4); color: var(--text); border-color: var(--border2); }
.btn-secondary:hover { background: var(--bg5); }
.btn-ghost     { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg4); color: var(--text); }
.btn-danger    { background: var(--red-dim); color: var(--red); border-color: rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.2); }
.btn-warning   { background: var(--yellow-dim); color: var(--yellow); border-color: rgba(245,158,11,.3); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-full { width: 100%; justify-content: center; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 1rem; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group-sm { max-width: 110px; }
input[type="text"], input[type="password"], input[type="email"], input[type="file"],
select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 13px;
  font-size: 13px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
input::placeholder { color: var(--text-dim); }
select option { background: var(--bg3); }
.section-title {
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .1em;
  margin: 1.5rem 0 .9rem; padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
}

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  padding: .85rem 1.1rem; border-radius: 8px;
  font-size: 13px; margin-bottom: 1rem; line-height: 1.6;
  display: flex; align-items: flex-start; gap: 8px;
}
.alert-error,
.alert-danger  { background: var(--red-dim);    border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.alert-success { background: var(--green-dim);  border: 1px solid rgba(34,197,94,.3);  color: #86efac; }
.alert-info    { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.3); color: #93c5fd; }

/* ─── Auth / Login / Install ─────────────────────────────────────────────── */
.auth-bg {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(59,130,246,.2) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 90% 90%, rgba(124,58,237,.15) 0%, transparent 50%),
    var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 2rem;
}
.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%; max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.03);
  position: relative;
}
.auth-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, #3b82f6, #7c3aed, transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.install-card { max-width: 580px; }
.auth-logo {
  text-align: center; margin-bottom: 1.25rem;
  display: flex; justify-content: center;
}
.auth-logo-wrap {
  width: 60px; height: 60px; border-radius: 16px;
  background: #2a5ccc;
  display: flex; align-items: center; justify-content: center;
}
.auth-logo-wrap svg { color: #fff; }
.auth-card h1 { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: .3rem; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 1.75rem; }

/* ─── Filter bar ─────────────────────────────────────────────────────────── */
.filter-bar { padding: .85rem 1rem; margin-bottom: 1rem; border-radius: var(--radius-lg); }
.filter-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filter-input { flex: 1; min-width: 200px; }
.filter-select { min-width: 160px; width: auto; }

/* ─── Pagination ─────────────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  padding: .85rem 1rem; border-top: 1px solid var(--border);
  flex-wrap: wrap; row-gap: .5rem;
}

.table tbody tr:nth-child(even) td { background: rgba(255,255,255,.018); }
[data-theme="light"] .table tbody tr:nth-child(even) td { background: rgba(0,0,0,.025); }
.page-info { font-size: 12px; color: var(--text-muted); }

/* ─── Detail grid ────────────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.1rem;
}
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; }
.detail-list dt {
  font-size: 10px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .06em; padding-top: .15rem;
  white-space: nowrap;
}
.detail-list dd { font-size: 13px; color: var(--text); margin-bottom: .1rem; }

/* ─── GDPR score ─────────────────────────────────────────────────────────── */
.gdpr-score-big { display: flex; align-items: center; gap: 1rem; }
.score-circle {
  width: 68px; height: 68px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; flex-shrink: 0; border: 3px solid;
}
.score-ok       { border-color: var(--green); color: var(--green); box-shadow: 0 0 16px rgba(34,197,94,.25); }
.score-warning  { border-color: var(--yellow); color: var(--yellow); box-shadow: 0 0 16px rgba(245,158,11,.25); }
.score-critical { border-color: var(--red); color: var(--red); box-shadow: 0 0 16px rgba(239,68,68,.25); }
.score-label { display: flex; flex-direction: column; gap: 3px; }
.score-label strong { font-size: 15px; color: var(--text); }
.score-label span   { font-size: 12px; color: var(--text-muted); }

/* ─── Backup actions ─────────────────────────────────────────────────────── */
.backup-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.restore-form   { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.file-input { width: auto; flex: 1; min-width: 200px; }
.apikey-form    { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.apikey-form .filter-input { max-width: 300px; }
.key-display {
  display: block; margin-top: .6rem; padding: .6rem .85rem;
  background: rgba(34,197,94,.06); border: 1px solid rgba(34,197,94,.3);
  border-radius: 8px; word-break: break-all; font-size: 13px;
  color: #86efac; font-family: 'Cascadia Code', monospace;
  letter-spacing: .03em;
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3.5rem 1.5rem;
  color: var(--text-muted); font-size: 13px;
}
.empty-state svg { color: var(--text-dim); margin-bottom: 1rem; }
.empty-state p { line-height: 1.8; }

/* ─── Text utilities ─────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); font-size: 13px; margin-bottom: .75rem; }
.badge-admin {
  background: linear-gradient(90deg, rgba(59,130,246,.2), rgba(124,58,237,.2));
  color: #a5b4fc;
  border: 1px solid rgba(124,58,237,.35);
  padding: 2px 8px; border-radius: 20px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg5); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* ─── Light theme overrides ──────────────────────────────────────────────── */
[data-theme="light"] .sidebar {
  box-shadow: 2px 0 8px rgba(0,0,0,.06);
}
[data-theme="light"] .sidebar-nav a.active {
  background: rgba(59,114,217,.08);
  border-left-color: var(--accent);
  color: var(--accent2);
}
[data-theme="light"] .sidebar-nav a:hover {
  background: var(--bg3);
  color: var(--text);
}
[data-theme="light"] .stat-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
}
[data-theme="light"] .table-hover tbody tr:hover td {
  background: rgba(0,0,0,.025);
}
[data-theme="light"] .btn-ghost:hover {
  background: var(--bg3);
  color: var(--text);
}
[data-theme="light"] .auth-bg {
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(79,136,240,.12) 0%, transparent 60%),
    var(--bg);
}
[data-theme="light"] code {
  background: var(--bg3);
  color: #2a5ccc;
}
[data-theme="light"] .brand-icon,
[data-theme="light"] .user-avatar,
[data-theme="light"] .auth-logo-wrap {
  background: #3b72d9;
}

/* ─── Theme toggle button ────────────────────────────────────────────────── */
.btn-theme {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; width: 100%;
  padding: 6px 10px; border-radius: 8px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all .15s; margin-top: 6px;
  font-family: inherit;
}
.btn-theme:hover { background: var(--bg4); color: var(--text); border-color: var(--border2); }

/* ─── Mobile topbar ──────────────────────────────────────────────────────── */
.mobile-topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 98;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  align-items: center; padding: 0 16px; gap: 12px;
}
.mobile-topbar .brand-name { font-size: 14px; font-weight: 700; color: var(--text); }
.btn-hamburger {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; transition: all .15s;
}
.btn-hamburger:hover { background: var(--bg4); color: var(--text); }

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

/* ─── Responsive — tablet / mobile (≤768px) ─────────────────────────────── */
/* ─── Filtri collassabili mobile ─────────────────────────────────────────── */
.filter-toggle {
  display: none;
}
@media (max-width: 768px) {
  .filter-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 12px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    justify-content: space-between;
  }
  .filter-toggle .ft-arrow {
    transition: transform .2s;
    font-size: 10px;
    color: var(--text-muted);
  }
  .filter-toggle.open .ft-arrow { transform: rotate(180deg); }
  .ft-active-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent, #3b82f6);
    vertical-align: middle;
    margin-left: 2px;
  }
  .filter-collapsible {
    display: none;
    flex-direction: column;
    gap: .5rem;
    margin-top: .5rem;
  }
  .filter-collapsible.open { display: flex; }
  .filter-collapsible .filter-input,
  .filter-collapsible .filter-select { width: 100%; }
}

@media (max-width: 768px) {

  .mobile-topbar { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); }

  .main-with-nav {
    margin-left: 0;
    padding: 1rem 1rem 3rem;
    padding-top: calc(52px + 1rem);
  }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .page-header {
    flex-direction: column; gap: .75rem; align-items: flex-start;
  }
  .page-header > div[style*="margin-left:auto"],
  .page-header > div[style*="margin-left: auto"] { margin-left: 0 !important; }

  .form-row { grid-template-columns: 1fr; }

  .detail-grid { grid-template-columns: 1fr; }

  .filter-input { min-width: 0; width: 100%; }
  .filter-select { min-width: 0; width: 100%; }

  .card-body.p-0 { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card .table    { min-width: 600px; }
  .card:has(.table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ─── Responsive — smartphone (≤480px) ──────────────────────────────────── */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .main-with-nav { padding: .75rem .75rem 3rem; padding-top: calc(52px + .75rem); }
  .stat-value { font-size: 22px; }
}

/* ─── Stat badges (periferiche) ─────────────────────────────────────────── */
.stat-badge {
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
  text-decoration: none;
  cursor: pointer;
}
.stat-badge .sb-num  { font-size: 22px; font-weight: 700; }
.stat-badge .sb-lbl  { font-size: 12px; color: var(--text-muted); }

@media (max-width: 768px) {
  .stat-badges-wrap {
    gap: 6px;
  }
  .stat-badge {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    min-width: 0;
    border-radius: 20px;
  }
  .stat-badge .sb-num  { font-size: 13px; font-weight: 700; }
  .stat-badge .sb-lbl  { font-size: 12px; }
}
