/* HRX License Server — temi: chiaro | scuro | nero | blu */
:root {
  --hrx-radius: 0.75rem;
  --hrx-radius-lg: 1rem;
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 4.25rem;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Default = blu (allineato a HRX dark blue) */
:root,
[data-theme="blue"] {
  color-scheme: dark;
  --hrx-bg: #0b1120;
  --hrx-bg-header: #0d1117;
  --hrx-bg-surface: #0f172a;
  --hrx-bg-card: rgba(15, 23, 42, 0.65);
  --hrx-bg-input: rgba(2, 6, 23, 0.55);
  --hrx-bg-sidebar: rgba(13, 17, 23, 0.92);
  --hrx-bg-login-card: rgba(15, 23, 42, 0.72);
  --hrx-border: rgba(51, 65, 85, 0.85);
  --hrx-border-soft: rgba(51, 65, 85, 0.55);
  --hrx-text: #f1f5f9;
  --hrx-text-muted: #94a3b8;
  --hrx-text-dim: #64748b;
  --hrx-link: #93c5fd;
  --hrx-nav-text: #cbd5e1;
  --hrx-ghost-bg: rgba(15, 23, 42, 0.7);
  --hrx-ghost-hover: rgba(30, 41, 59, 0.9);
  --hrx-option-bg: #0f172a;
  --hrx-toggle-track: #1e293b;
  --hrx-accent: #2563eb;
  --hrx-accent-hover: #3b82f6;
  --hrx-accent-deep: #1d4ed8;
  --hrx-accent-soft: rgba(37, 99, 235, 0.14);
  --hrx-ok: #6ee7b7;
  --hrx-ok-bg: rgba(6, 78, 59, 0.45);
  --hrx-ok-border: rgba(4, 120, 87, 0.7);
  --hrx-warn: #fcd34d;
  --hrx-warn-bg: rgba(69, 26, 3, 0.5);
  --hrx-warn-border: rgba(180, 83, 9, 0.7);
  --hrx-bad: #fca5a5;
  --hrx-bad-bg: rgba(69, 10, 10, 0.5);
  --hrx-bad-border: rgba(185, 28, 28, 0.7);
  --hrx-info: #93c5fd;
  --hrx-info-bg: rgba(23, 37, 84, 0.55);
  --hrx-info-border: rgba(29, 78, 216, 0.7);
  --hrx-trial: #a78bfa;
  --hrx-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --hrx-glow-1: rgba(37, 99, 235, 0.16);
  --hrx-glow-2: rgba(99, 102, 241, 0.08);
  --hrx-brand-accent: #60a5fa;
  --hrx-theme-meta: #0d1117;
  --hrx-bg-elevated: rgba(15, 23, 42, 0.85);
  --hrx-bg-nested: rgba(2, 6, 23, 0.35);
  --hrx-bg-group: rgba(2, 6, 23, 0.25);
  --hrx-bg-table-head: rgba(15, 23, 42, 0.9);
  --hrx-bg-row-hover: rgba(30, 41, 59, 0.35);
  --hrx-pill-neutral-bg: rgba(30, 41, 59, 0.7);
  --hrx-feat-bg: rgba(2, 6, 23, 0.35);
  --hrx-feat-hover: rgba(15, 23, 42, 0.8);
  --hrx-feat-check-bg: #0b1220;
  --hrx-feat-check-border: #475569;
  --hrx-feat-text: #e2e8f0;
  --hrx-feat-text-on: #f8fafc;
  --hrx-key-once-text: #bbf7d0;
  --hrx-key-once-strong: #a7f3d0;
  --hrx-empty-bg: rgba(30, 41, 59, 0.8);
  --hrx-empty-text: #cbd5e1;
}

/* Scuro — slate neutro */
[data-theme="dark"] {
  color-scheme: dark;
  --hrx-bg: #111827;
  --hrx-bg-header: #0f172a;
  --hrx-bg-surface: #1e293b;
  --hrx-bg-card: rgba(30, 41, 59, 0.72);
  --hrx-bg-input: rgba(15, 23, 42, 0.75);
  --hrx-bg-sidebar: rgba(15, 23, 42, 0.95);
  --hrx-bg-login-card: rgba(30, 41, 59, 0.85);
  --hrx-border: rgba(71, 85, 105, 0.9);
  --hrx-border-soft: rgba(71, 85, 105, 0.55);
  --hrx-text: #f8fafc;
  --hrx-text-muted: #94a3b8;
  --hrx-text-dim: #64748b;
  --hrx-link: #93c5fd;
  --hrx-nav-text: #cbd5e1;
  --hrx-ghost-bg: rgba(30, 41, 59, 0.75);
  --hrx-ghost-hover: rgba(51, 65, 85, 0.9);
  --hrx-option-bg: #1e293b;
  --hrx-toggle-track: #334155;
  --hrx-accent: #3b82f6;
  --hrx-accent-hover: #60a5fa;
  --hrx-accent-deep: #2563eb;
  --hrx-accent-soft: rgba(59, 130, 246, 0.16);
  --hrx-ok: #6ee7b7;
  --hrx-ok-bg: rgba(6, 78, 59, 0.45);
  --hrx-ok-border: rgba(4, 120, 87, 0.7);
  --hrx-warn: #fcd34d;
  --hrx-warn-bg: rgba(69, 26, 3, 0.5);
  --hrx-warn-border: rgba(180, 83, 9, 0.7);
  --hrx-bad: #fca5a5;
  --hrx-bad-bg: rgba(69, 10, 10, 0.5);
  --hrx-bad-border: rgba(185, 28, 28, 0.7);
  --hrx-info: #93c5fd;
  --hrx-info-bg: rgba(23, 37, 84, 0.55);
  --hrx-info-border: rgba(29, 78, 216, 0.7);
  --hrx-trial: #a78bfa;
  --hrx-shadow: 0 10px 36px rgba(0, 0, 0, 0.4);
  --hrx-glow-1: rgba(148, 163, 184, 0.08);
  --hrx-glow-2: rgba(100, 116, 139, 0.06);
  --hrx-brand-accent: #93c5fd;
  --hrx-theme-meta: #0f172a;
  --hrx-bg-elevated: rgba(30, 41, 59, 0.95);
  --hrx-bg-nested: rgba(15, 23, 42, 0.55);
  --hrx-bg-group: rgba(15, 23, 42, 0.4);
  --hrx-bg-table-head: rgba(15, 23, 42, 0.95);
  --hrx-bg-row-hover: rgba(51, 65, 85, 0.4);
  --hrx-pill-neutral-bg: rgba(51, 65, 85, 0.75);
  --hrx-feat-bg: rgba(15, 23, 42, 0.45);
  --hrx-feat-hover: rgba(30, 41, 59, 0.85);
  --hrx-feat-check-bg: #0f172a;
  --hrx-feat-check-border: #475569;
  --hrx-feat-text: #e2e8f0;
  --hrx-feat-text-on: #f8fafc;
  --hrx-key-once-text: #bbf7d0;
  --hrx-key-once-strong: #a7f3d0;
  --hrx-empty-bg: rgba(30, 41, 59, 0.8);
  --hrx-empty-text: #cbd5e1;
}

/* Nero — puro */
[data-theme="black"] {
  color-scheme: dark;
  --hrx-bg: #000000;
  --hrx-bg-header: #000000;
  --hrx-bg-surface: #0a0a0a;
  --hrx-bg-card: rgba(14, 14, 14, 0.92);
  --hrx-bg-input: rgba(10, 10, 10, 0.95);
  --hrx-bg-sidebar: rgba(0, 0, 0, 0.96);
  --hrx-bg-login-card: rgba(12, 12, 12, 0.92);
  --hrx-border: rgba(38, 38, 38, 0.95);
  --hrx-border-soft: rgba(38, 38, 38, 0.7);
  --hrx-text: #f5f5f5;
  --hrx-text-muted: #a3a3a3;
  --hrx-text-dim: #737373;
  --hrx-link: #93c5fd;
  --hrx-nav-text: #d4d4d4;
  --hrx-ghost-bg: rgba(23, 23, 23, 0.9);
  --hrx-ghost-hover: rgba(38, 38, 38, 0.95);
  --hrx-option-bg: #0a0a0a;
  --hrx-toggle-track: #262626;
  --hrx-accent: #3b82f6;
  --hrx-accent-hover: #60a5fa;
  --hrx-accent-deep: #2563eb;
  --hrx-accent-soft: rgba(59, 130, 246, 0.14);
  --hrx-ok: #6ee7b7;
  --hrx-ok-bg: rgba(6, 78, 59, 0.4);
  --hrx-ok-border: rgba(4, 120, 87, 0.65);
  --hrx-warn: #fcd34d;
  --hrx-warn-bg: rgba(69, 26, 3, 0.45);
  --hrx-warn-border: rgba(180, 83, 9, 0.65);
  --hrx-bad: #fca5a5;
  --hrx-bad-bg: rgba(69, 10, 10, 0.45);
  --hrx-bad-border: rgba(185, 28, 28, 0.65);
  --hrx-info: #93c5fd;
  --hrx-info-bg: rgba(23, 37, 84, 0.5);
  --hrx-info-border: rgba(29, 78, 216, 0.65);
  --hrx-trial: #a78bfa;
  --hrx-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
  --hrx-glow-1: transparent;
  --hrx-glow-2: transparent;
  --hrx-brand-accent: #60a5fa;
  --hrx-theme-meta: #000000;
  --hrx-bg-elevated: #111111;
  --hrx-bg-nested: #0a0a0a;
  --hrx-bg-group: #080808;
  --hrx-bg-table-head: #111111;
  --hrx-bg-row-hover: rgba(38, 38, 38, 0.7);
  --hrx-pill-neutral-bg: rgba(38, 38, 38, 0.9);
  --hrx-feat-bg: #0a0a0a;
  --hrx-feat-hover: #141414;
  --hrx-feat-check-bg: #000;
  --hrx-feat-check-border: #404040;
  --hrx-feat-text: #e5e5e5;
  --hrx-feat-text-on: #fafafa;
  --hrx-key-once-text: #bbf7d0;
  --hrx-key-once-strong: #a7f3d0;
  --hrx-empty-bg: #171717;
  --hrx-empty-text: #a3a3a3;
}

/* Chiaro */
[data-theme="light"] {
  color-scheme: light;
  --hrx-bg: #f1f5f9;
  --hrx-bg-header: #ffffff;
  --hrx-bg-surface: #ffffff;
  --hrx-bg-card: #ffffff;
  --hrx-bg-input: #ffffff;
  --hrx-bg-sidebar: rgba(255, 255, 255, 0.96);
  --hrx-bg-login-card: #ffffff;
  --hrx-border: #e2e8f0;
  --hrx-border-soft: #e2e8f0;
  --hrx-text: #0f172a;
  --hrx-text-muted: #64748b;
  --hrx-text-dim: #64748b;
  --hrx-link: #2563eb;
  --hrx-nav-text: #334155;
  --hrx-ghost-bg: #f8fafc;
  --hrx-ghost-hover: #f1f5f9;
  --hrx-option-bg: #ffffff;
  --hrx-toggle-track: #cbd5e1;
  --hrx-accent: #2563eb;
  --hrx-accent-hover: #3b82f6;
  --hrx-accent-deep: #1d4ed8;
  --hrx-accent-soft: rgba(37, 99, 235, 0.1);
  --hrx-ok: #047857;
  --hrx-ok-bg: #ecfdf5;
  --hrx-ok-border: #a7f3d0;
  --hrx-warn: #b45309;
  --hrx-warn-bg: #fffbeb;
  --hrx-warn-border: #fcd34d;
  --hrx-bad: #b91c1c;
  --hrx-bad-bg: #fef2f2;
  --hrx-bad-border: #fecaca;
  --hrx-info: #1d4ed8;
  --hrx-info-bg: #eff6ff;
  --hrx-info-border: #bfdbfe;
  --hrx-trial: #7c3aed;
  --hrx-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --hrx-glow-1: rgba(37, 99, 235, 0.08);
  --hrx-glow-2: rgba(148, 163, 184, 0.12);
  --hrx-brand-accent: #2563eb;
  --hrx-theme-meta: #f1f5f9;
  --hrx-bg-elevated: #f8fafc;
  --hrx-bg-nested: #f8fafc;
  --hrx-bg-group: #ffffff;
  --hrx-bg-table-head: #f8fafc;
  --hrx-bg-row-hover: #f1f5f9;
  --hrx-pill-neutral-bg: #f1f5f9;
  --hrx-feat-bg: #f8fafc;
  --hrx-feat-hover: #f1f5f9;
  --hrx-feat-check-bg: #ffffff;
  --hrx-feat-check-border: #cbd5e1;
  --hrx-feat-text: #0f172a;
  --hrx-feat-text-on: #0f172a;
  --hrx-key-once-text: #065f46;
  --hrx-key-once-strong: #047857;
  --hrx-empty-bg: #f8fafc;
  --hrx-empty-text: #64748b;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--hrx-bg);
  color: var(--hrx-text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(900px 420px at 12% -8%, var(--hrx-glow-1), transparent 55%),
    radial-gradient(700px 360px at 90% 0%, var(--hrx-glow-2), transparent 50%),
    var(--hrx-bg);
}

[hidden] { display: none !important; }
a { color: var(--hrx-link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
}
.muted { color: var(--hrx-text-muted); font-size: 12px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
button, .btn {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid transparent;
  border-radius: var(--hrx-radius);
  background: var(--hrx-accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease, transform .1s ease;
  line-height: 1.2;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--hrx-accent-hover); }
button:active, .btn:active { background: var(--hrx-accent-deep); transform: translateY(0.5px); }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-link {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 650;
  color: var(--hrx-accent, #3b82f6);
  text-decoration: underline;
  cursor: pointer;
}
.btn-link:hover { opacity: 0.85; }

.btn-ghost, button.secondary {
  background: var(--hrx-ghost-bg);
  border-color: var(--hrx-border);
  color: var(--hrx-text);
}
.btn-ghost:hover, button.secondary:hover {
  background: var(--hrx-ghost-hover);
  border-color: var(--hrx-border);
  color: var(--hrx-text);
}

.btn-danger, button.danger {
  background: var(--hrx-bad-bg);
  border-color: var(--hrx-bad-border);
  color: var(--hrx-bad);
}
.btn-danger:hover, button.danger:hover {
  filter: brightness(0.95);
  border-color: var(--hrx-bad);
}

.btn-ok, button.ok {
  background: var(--hrx-ok-bg);
  border-color: var(--hrx-ok-border);
  color: var(--hrx-ok);
}
.btn-ok:hover, button.ok:hover {
  filter: brightness(0.97);
  border-color: var(--hrx-ok);
}

.btn-sm, .actions button {
  padding: 0.35rem 0.65rem;
  font-size: 11px;
  border-radius: 0.65rem;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* ── Inputs / selects / textarea ─────────────────────────────────────── */
label.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hrx-text-dim);
  min-width: 0;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
select,
textarea {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  color: var(--hrx-text);
  background: var(--hrx-bg-input);
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius);
  padding: 0.65rem 0.85rem;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  color-scheme: inherit;
}
input[type="search"] {
  /* Safari/Chrome: rimuove stile nativo e il bordo interno */
  -webkit-appearance: none;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
}
select {
  padding-right: 2.2rem;
  background-color: var(--hrx-bg-input);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--hrx-text-muted) 50%),
    linear-gradient(135deg, var(--hrx-text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
select option,
select optgroup {
  background: var(--hrx-option-bg);
  color: var(--hrx-text);
}
textarea { resize: vertical; min-height: 84px; }
input:hover, select:hover, textarea:hover {
  border-color: var(--hrx-border);
  background: var(--hrx-bg-elevated);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--hrx-accent-hover);
  box-shadow: 0 0 0 3px var(--hrx-accent-soft);
  background: var(--hrx-bg-input);
}
input::placeholder, textarea::placeholder { color: var(--hrx-text-dim); }

/* ── Custom select (sostituisce il menu nativo OS) ───────────────────── */
.hrx-select {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}
.hrx-select > select.hrx-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.hrx-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  min-height: 2.55rem;
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  text-align: left;
  color: var(--hrx-text);
  background: var(--hrx-bg-input);
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius);
  padding: 0.65rem 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  box-shadow: none;
}
.hrx-select-trigger:hover {
  background: var(--hrx-bg-elevated);
  border-color: var(--hrx-border);
}
.hrx-select.is-open .hrx-select-trigger,
.hrx-select-trigger:focus {
  border-color: var(--hrx-accent-hover);
  box-shadow: 0 0 0 3px var(--hrx-accent-soft);
  background: var(--hrx-bg-input);
}
.hrx-select.is-disabled .hrx-select-trigger {
  opacity: 0.55;
  cursor: not-allowed;
}
.hrx-select-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hrx-select-label.is-placeholder { color: var(--hrx-text-dim); }
.hrx-select-chevron {
  flex-shrink: 0;
  width: 0.65rem;
  height: 0.65rem;
  color: var(--hrx-text-muted);
  transition: transform .15s ease;
}
.hrx-select.is-open .hrx-select-chevron { transform: rotate(180deg); }
.hrx-select-menu {
  position: absolute;
  z-index: 80;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: min(280px, 50vh);
  overflow: auto;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: var(--hrx-bg-elevated);
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius);
  box-shadow: var(--hrx-shadow);
  backdrop-filter: blur(10px);
}
.hrx-select-menu[hidden] { display: none !important; }
.hrx-select-option {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  color: var(--hrx-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: calc(var(--hrx-radius) - 2px);
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  transition: background .1s ease, border-color .1s ease, color .1s ease;
  box-shadow: none;
}
.hrx-select-option:hover,
.hrx-select-option.is-active {
  background: var(--hrx-accent-soft);
  border-color: rgba(37, 99, 235, 0.25);
  color: var(--hrx-text);
}
.hrx-select-option.is-selected {
  background: var(--hrx-accent-soft);
  color: var(--hrx-brand-accent);
  border-color: rgba(37, 99, 235, 0.35);
}
.hrx-select-option:disabled,
.hrx-select-option.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.hrx-select-group-label {
  padding: 0.45rem 0.7rem 0.25rem;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hrx-text-dim);
}

/* ── Custom toggles (no native checkbox look) ────────────────────────── */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
  font-size: 13px;
  color: var(--hrx-text);
}
.toggle input {
  position: absolute;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.toggle-track {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--hrx-toggle-track);
  border: 1px solid var(--hrx-border);
  position: relative;
  flex-shrink: 0;
  transition: background .15s ease, border-color .15s ease;
}
.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #94a3b8;
  transition: transform .15s ease, background .15s ease;
}
.toggle input:checked + .toggle-track {
  background: rgba(37, 99, 235, 0.55);
  border-color: #3b82f6;
}
.toggle input:checked + .toggle-track::after {
  transform: translateX(18px);
  background: #fff;
}
.toggle input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.feat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.feat-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--hrx-radius);
  border: 1px solid var(--hrx-border);
  background: var(--hrx-feat-bg);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
  font-size: 12px;
  color: var(--hrx-feat-text);
}
.feat-card:hover { border-color: var(--hrx-border); background: var(--hrx-feat-hover); }
.feat-card input {
  position: absolute;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.feat-check {
  width: 18px;
  height: 18px;
  border-radius: 0.4rem;
  border: 1px solid var(--hrx-feat-check-border);
  background: var(--hrx-feat-check-bg);
  flex-shrink: 0;
  margin-top: 1px;
  display: grid;
  place-items: center;
  transition: all .15s ease;
}
.feat-check svg { opacity: 0; width: 12px; height: 12px; color: #fff; }
.feat-card input:checked ~ .feat-check {
  background: var(--hrx-accent);
  border-color: var(--hrx-accent-hover);
}
.feat-card input:checked ~ .feat-check svg { opacity: 1; }
.feat-card input:checked ~ .feat-meta { color: var(--hrx-feat-text-on); }
.feat-card:has(input:checked) {
  border-color: var(--hrx-accent-hover);
  background: var(--hrx-accent-soft);
}
.feat-meta { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.feat-meta strong { font-size: 12px; font-weight: 600; }
.feat-meta span { font-size: 11px; color: var(--hrx-text-dim); font-weight: 400; }

/* ── Pills ───────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 0.5rem;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--hrx-border);
  background: var(--hrx-pill-neutral-bg);
  color: var(--hrx-text-muted);
  white-space: nowrap;
}
.pill.tone-ok,
.pill.ok { color: var(--hrx-ok); background: var(--hrx-ok-bg); border-color: var(--hrx-ok-border); }
.pill.tone-warn { color: var(--hrx-warn); background: var(--hrx-warn-bg); border-color: var(--hrx-warn-border); }
.pill.tone-bad { color: var(--hrx-bad); background: var(--hrx-bad-bg); border-color: var(--hrx-bad-border); }
.pill.tone-info { color: var(--hrx-info); background: var(--hrx-info-bg); border-color: var(--hrx-info-border); }
.pill.tone-neutral { color: var(--hrx-text-muted); }
.pill.TRIAL { color: #fff; background: var(--hrx-trial); border-color: transparent; }
.pill.on { color: var(--hrx-ok); background: var(--hrx-ok-bg); border-color: var(--hrx-ok-border); }
.pill.off { color: var(--hrx-text-dim); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 11px;
  color: var(--hrx-text-muted);
  background: var(--hrx-pill-neutral-bg);
  border: 1px solid var(--hrx-border-soft);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
}

/* ── Login (layout allineato a HRX) ──────────────────────────────────── */
#login-view {
  position: relative;
  min-height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
}
#login-view[hidden] { display: none !important; }

.login-bg {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}
.login-glow {
  position: absolute;
  border-radius: 999px;
  filter: blur(64px);
}
.login-glow-a {
  top: -8rem;
  left: -8rem;
  width: 28rem;
  height: 28rem;
  background: rgba(37, 99, 235, 0.12);
}
.login-glow-b {
  top: 33%;
  right: -6rem;
  width: 20rem;
  height: 20rem;
  background: rgba(99, 102, 241, 0.08);
}
.login-glow-c {
  bottom: 0;
  left: 33%;
  width: 24rem;
  height: 12rem;
  background: rgba(59, 130, 246, 0.06);
}
.login-dots {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: radial-gradient(circle at 1px 1px, rgb(148 163 184) 1px, transparent 0);
  background-size: 24px 24px;
}
[data-theme="light"] .login-glow-a,
[data-theme="light"] .login-glow-b,
[data-theme="light"] .login-glow-c {
  opacity: 0.45;
}
[data-theme="black"] .login-glow-a,
[data-theme="black"] .login-glow-b,
[data-theme="black"] .login-glow-c {
  opacity: 0;
}

.login-layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100dvh;
  min-height: 100vh;
}
@media (min-width: 1024px) {
  .login-layout { flex-direction: row; }
}

.login-aside {
  display: none;
  flex-direction: column;
  justify-content: flex-start;
  width: 46%;
  max-width: 40rem;
  padding: 3.25rem 3rem 2.5rem;
  border-right: 1px solid var(--hrx-border-soft);
  background: rgba(2, 6, 23, 0.35);
  gap: 0;
}
@media (min-width: 1024px) {
  .login-aside { display: flex; }
}
@media (min-width: 1280px) {
  .login-aside {
    width: 44%;
    max-width: 44rem;
    padding: 4rem 3.75rem 3rem;
  }
  .login-aside-logo {
    height: 9.5rem;
    max-height: 9.5rem;
    max-width: min(40rem, 100%);
  }
  .login-lead {
    font-size: 1.25rem;
  }
  .login-features li {
    font-size: 1.05rem;
  }
  .login-feat-ico {
    width: 2.75rem;
    height: 2.75rem;
  }
  .login-feat-ico svg { width: 20px; height: 20px; }
}
[data-theme="light"] .login-aside {
  background: rgba(255, 255, 255, 0.55);
  border-right-color: rgba(203, 213, 225, 0.9);
}
[data-theme="black"] .login-aside {
  background: rgba(0, 0, 0, 0.55);
}

.login-aside-hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.login-aside-logo {
  height: 8rem;
  width: auto;
  max-width: min(36rem, 100%);
  max-height: 8rem;
  object-fit: contain;
  object-position: left center;
  margin: 0.5rem 0 2rem;
}
.login-eyebrow {
  margin: 0 0 0.85rem;
  color: var(--hrx-brand-accent);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.login-title {
  margin: 0 0 1rem;
  font-size: clamp(2.5rem, 4vw, 3.5rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--hrx-text);
}
.login-lead {
  margin: 0;
  max-width: 34rem;
  color: var(--hrx-text-muted);
  font-size: 1.125rem;
  line-height: 1.55;
  font-weight: 400;
}
.login-features {
  list-style: none;
  margin: 2.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}
.login-features li {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  color: var(--hrx-text-muted);
  font-size: 0.95rem;
  line-height: 1.4;
}
.login-feat-ico {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.7rem;
  background: var(--hrx-accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.22);
  color: var(--hrx-brand-accent);
}
.login-feat-ico svg { width: 18px; height: 18px; }
.login-features li > span:last-child { padding-top: 0; }
.login-copy {
  margin: auto 0 0;
  padding-top: 2.5rem;
  color: var(--hrx-text-dim);
  font-size: 0.8rem;
}

.login-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem 2.5rem;
}
@media (min-width: 640px) {
  .login-main { padding-left: 1.5rem; padding-right: 1.5rem; }
}
@media (min-width: 1024px) {
  .login-main { padding: 2.5rem 2.5rem; }
}
@media (min-width: 1280px) {
  .login-main { padding-left: 4rem; padding-right: 4rem; }
}

.login-mobile-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 2rem;
}
.login-mobile-brand img {
  height: 5.5rem;
  width: auto;
  max-width: min(380px, 92vw);
  max-height: 5.5rem;
  object-fit: contain;
  margin-bottom: 1rem;
}
.login-mobile-brand h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--hrx-text);
}
.login-mobile-brand p {
  margin: 0.35rem 0 0;
  color: var(--hrx-text-dim);
  font-size: 0.875rem;
}
@media (min-width: 1024px) {
  .login-mobile-brand { display: none; }
}

.login-card {
  width: min(30rem, 100%);
  border: 1px solid var(--hrx-border);
  background: var(--hrx-bg-login-card);
  backdrop-filter: blur(12px);
  border-radius: 1.25rem;
  box-shadow: var(--hrx-shadow);
  padding: 1.75rem 1.5rem;
  animation: login-fade-in 0.35s ease both;
}
@media (min-width: 640px) {
  .login-card {
    border-radius: 1.5rem;
    padding: 2.25rem 2.1rem;
  }
}
@keyframes login-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.login-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  color: var(--hrx-text);
  font-size: 0.9rem;
  font-weight: 650;
}
.login-card-head-ico {
  width: 15px;
  height: 15px;
  color: var(--hrx-brand-accent);
  flex-shrink: 0;
}

.login-fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-field .login-input-wrap {
  position: relative;
  display: block;
}
.login-input-ico {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--hrx-text-dim);
  pointer-events: none;
}
.login-field input {
  padding-left: 2.55rem;
  padding-right: 0.9rem;
  border-radius: 0.75rem;
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
  font-size: 0.875rem;
  background: rgba(2, 6, 23, 0.55);
}
[data-theme="light"] .login-field input {
  background: #fff;
}
[data-theme="dark"] .login-field input {
  background: rgba(15, 23, 42, 0.75);
}
[data-theme="black"] .login-field input {
  background: rgba(10, 10, 10, 0.95);
}
.login-field input:focus {
  border-color: var(--hrx-accent);
  box-shadow: 0 0 0 3px var(--hrx-accent-soft);
}
.login-field #admin-pass {
  padding-right: 2.75rem;
}

.login-toggle-pwd {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--hrx-text-dim);
  box-shadow: none;
}
.login-toggle-pwd:hover {
  background: rgba(30, 41, 59, 0.55);
  color: var(--hrx-text-muted);
}
.login-toggle-pwd:active { transform: translateY(-50%); }
.login-toggle-pwd svg { width: 16px; height: 16px; display: block; }
[data-theme="light"] .login-toggle-pwd:hover {
  background: rgba(241, 245, 249, 0.95);
}

.login-submit {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.9rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
}
.login-submit svg { width: 17px; height: 17px; }
.login-submit.is-loading { opacity: 0.7; pointer-events: none; }

.login-err {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-radius: 0.75rem;
  background: var(--hrx-bad-bg);
  border: 1px solid var(--hrx-bad-border);
  color: var(--hrx-bad);
  font-size: 0.8125rem;
  line-height: 1.4;
}
.login-err:empty { display: none; }
.login-err::before {
  content: "";
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E") center / contain no-repeat;
}

#shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}
#shell[hidden] { display: none !important; }
#shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--sidebar-w);
  border-right: 1px solid var(--hrx-border);
  background: var(--hrx-bg-sidebar);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.85rem;
  gap: 0.5rem;
  overflow: hidden;
  transition: width 0.2s ease, padding 0.2s ease;
}
#shell.sidebar-collapsed .sidebar {
  width: var(--sidebar-w-collapsed);
  padding: 1rem 0.45rem;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.55rem 1rem;
  border-bottom: 1px solid var(--hrx-border-soft);
  margin-bottom: 0.5rem;
  min-height: 2.75rem;
}
#shell.sidebar-collapsed .sidebar-brand {
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.25rem 0 0.85rem;
  justify-content: center;
}
.sidebar-brand img.ls-app-icon {
  height: 36px;
  width: 36px;
  border-radius: 0.55rem;
  object-fit: cover;
  flex-shrink: 0;
}
.sidebar-brand-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sidebar-brand-text strong {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.sidebar-brand-text span { font-size: 11px; color: var(--hrx-text-dim); }
#shell.sidebar-collapsed .sidebar-brand-text { display: none; }

.sidebar-collapse-btn {
  appearance: none;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  color: var(--hrx-text-muted);
  box-shadow: none;
  transform: none;
}
.sidebar-collapse-btn:hover {
  background: var(--hrx-ghost-hover);
  border-color: var(--hrx-border-soft);
  color: var(--hrx-text);
  box-shadow: none;
  transform: none;
}
.sidebar-collapse-btn:active {
  background: var(--hrx-ghost-hover);
  transform: none;
}
.sidebar-collapse-ico {
  font-size: 1.15rem;
  line-height: 1;
  font-weight: 600;
  transition: transform 0.2s ease;
}
#shell.sidebar-collapsed .sidebar-collapse-btn {
  margin-left: 0;
}
#shell.sidebar-collapsed .sidebar-collapse-ico {
  transform: rotate(180deg);
}

.nav-tabs {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}
.nav-tabs button {
  width: 100%;
  justify-content: flex-start;
  gap: 0.55rem;
  background: transparent;
  border: 1px solid transparent;
  color: var(--hrx-nav-text);
  font-weight: 560;
  padding: 0.65rem 0.75rem;
  border-radius: var(--hrx-radius);
}
.nav-tabs button:hover {
  background: var(--hrx-ghost-hover);
  border-color: var(--hrx-border-soft);
  color: var(--hrx-text);
}
.nav-tabs button.active {
  background: var(--hrx-accent);
  border-color: var(--hrx-accent-hover);
  color: #fff;
  box-shadow: 0 4px 16px var(--hrx-accent-soft);
}
.nav-tabs button .nav-ico {
  width: 1.15rem;
  flex-shrink: 0;
  text-align: center;
  opacity: 0.9;
}
.nav-tabs button .nav-label {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
#shell.sidebar-collapsed .nav-tabs button {
  justify-content: center;
  padding: 0.65rem 0.35rem;
  gap: 0;
}
#shell.sidebar-collapsed .nav-tabs button .nav-label {
  display: none;
}

.sidebar-foot {
  border-top: 1px solid var(--hrx-border-soft);
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sidebar-foot .auth-label {
  font-size: 11px;
  color: var(--hrx-text-dim);
  padding: 0 0.35rem;
  word-break: break-all;
}
#shell.sidebar-collapsed .sidebar-foot .auth-label {
  display: none;
}
.sidebar-foot #btn-logout {
  width: auto;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.sidebar-foot #btn-logout .logout-ico {
  display: none;
  font-size: 0.95rem;
  line-height: 1;
}
#shell.sidebar-collapsed .sidebar-foot #btn-logout {
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}
#shell.sidebar-collapsed .sidebar-foot #btn-logout .logout-label {
  display: none;
}
#shell.sidebar-collapsed .sidebar-foot #btn-logout .logout-ico {
  display: inline;
}

.content {
  min-width: 0;
  padding: 1.25rem 1.5rem 2.5rem;
  max-width: 1280px;
}
.content:has(#tab-settings:not([hidden])) {
  max-width: none;
  padding: 0;
  width: 100%;
}
/* Clienti / Piani / Report: occupano tutta l’area utile dello schermo */
.content:has(#tab-licenses:not([hidden])),
.content:has(#tab-plans:not([hidden])),
.content:has(#tab-report:not([hidden])) {
  max-width: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: 100vh;
  overflow: hidden;
  padding: 1rem 1.25rem 1rem;
  box-sizing: border-box;
}

#tab-settings {
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: calc(100vh - 0px);
}

/* ── Impostazioni: layout a sotto-pagine (stile HRX) ─────────────────── */
.settings-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 0.5rem);
  align-items: stretch;
}
.settings-subnav {
  border-right: 1px solid var(--hrx-border);
  background: var(--hrx-bg-sidebar);
  padding: 1rem 0.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}
.settings-subnav-head {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.35rem 0.55rem 0.85rem;
  border-bottom: 1px solid var(--hrx-border-soft);
  margin-bottom: 0.25rem;
}
.settings-subnav-head strong {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.settings-subnav-head span {
  font-size: 11px;
  color: var(--hrx-text-dim);
}
.settings-subnav-group {
  margin: 0.65rem 0.55rem 0.25rem;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hrx-text-dim);
}
.settings-subnav-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.settings-subnav-list > button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--hrx-nav-text);
  padding: 0.65rem 0.7rem;
  border-radius: var(--hrx-radius);
  gap: 0.65rem;
  font-weight: 500;
  white-space: normal;
}
.settings-subnav-list > button:hover {
  background: var(--hrx-ghost-hover);
  color: var(--hrx-text);
}
.settings-subnav-list > button.active {
  background: var(--hrx-accent-soft);
  border-color: var(--hrx-accent-hover);
  color: var(--hrx-text);
  box-shadow: none;
}
.settings-sub-ico {
  width: 1.35rem;
  text-align: center;
  opacity: 0.85;
  flex-shrink: 0;
}
.settings-sub-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.settings-sub-copy strong {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.settings-sub-copy em {
  font-style: normal;
  font-size: 11px;
  color: var(--hrx-text-dim);
  font-weight: 400;
  line-height: 1.3;
}
.settings-subnav-list > button.active .settings-sub-copy em {
  color: var(--hrx-text-muted);
}

.settings-main {
  min-width: 0;
  padding: 1.15rem 1.35rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.settings-mobile-nav { display: none; }
.settings-panel {
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius-lg);
  background: var(--hrx-bg-card);
  overflow: hidden;
  box-shadow: var(--hrx-shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.settings-panel-head {
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--hrx-border-soft);
  background: var(--hrx-bg-elevated);
}
.settings-panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.settings-panel-head p {
  margin: 0.25rem 0 0;
  color: var(--hrx-text-muted);
  font-size: 12px;
}
.settings-panel-body {
  padding: 1rem 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.settings-pane-card {
  margin-bottom: 0;
  box-shadow: none;
}
.settings-sub { display: flex; flex-direction: column; gap: 0.85rem; }

@media (max-width: 960px) {
  .settings-layout { grid-template-columns: 210px minmax(0, 1fr); }
}

@media (max-width: 780px) {
  #tab-settings {
    margin: 0;
  }
  .settings-layout {
    grid-template-columns: 1fr;
  }
  .settings-subnav {
    display: none;
  }
  .settings-mobile-nav {
    display: block;
    padding: 0.85rem 1rem 0;
  }
  .settings-main {
    padding: 0.75rem 1rem 1.25rem;
  }
  .settings-panel {
    border-radius: var(--hrx-radius);
  }
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.page-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-head p { margin: 0.25rem 0 0; color: var(--hrx-text-muted); font-size: 12px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.1rem;
}
.card {
  background: var(--hrx-bg-card);
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius);
  padding: 0.85rem 0.9rem;
}
.card .label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--hrx-text-dim);
}
.card .value {
  margin-top: 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel {
  background: var(--hrx-bg-card);
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius-lg);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.panel-title {
  margin: 0 0 0.85rem;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}
.panel-head .panel-title { margin: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  align-items: end;
}
.form-grid .span-2 { grid-column: span 2; }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.85rem;
}
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0.85rem 0 0.25rem;
}

.key-once {
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--hrx-radius);
  background: var(--hrx-ok-bg);
  border: 1px solid var(--hrx-ok-border);
  color: var(--hrx-key-once-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}
.key-once strong { display: block; margin-bottom: 0.35rem; font-family: inherit; color: var(--hrx-key-once-strong); }

/* ── Clienti master-detail ───────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.clients-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.clients-page .page-head { margin-bottom: 0.75rem; flex-shrink: 0; }

.kpi-strip {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
  margin-bottom: 0.85rem;
  scrollbar-width: thin;
  flex-shrink: 0;
}
.kpi-strip .kpi {
  flex: 1 0 auto;
  min-width: 88px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius);
  background: var(--hrx-bg-card);
}
.kpi-strip .kpi .label {
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--hrx-text-dim);
  white-space: nowrap;
}
.kpi-strip .kpi .value {
  margin-top: 0.2rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.kpi-strip .kpi-btn {
  appearance: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.kpi-strip .kpi-btn:hover {
  border-color: var(--hrx-info-border);
  background: var(--hrx-accent-soft);
}
.kpi-strip .kpi-btn.is-active {
  border-color: var(--hrx-info-border);
  background: var(--hrx-accent-soft);
}

.clients-layout {
  display: grid;
  grid-template-columns: clamp(220px, 26vw, 340px) minmax(0, 1fr);
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}
.clients-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius-lg);
  background: var(--hrx-bg-card);
  overflow: hidden;
  box-shadow: var(--hrx-shadow);
}
.clients-sidebar-tools {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--hrx-border-soft);
  background: var(--hrx-bg-elevated);
}
.clients-sidebar-tools .field { margin: 0; }
.clients-sidebar-tools input,
.clients-sidebar-tools select { width: 100%; }
.clients-list {
  flex: 1;
  overflow: auto;
  padding: 0.35rem;
}
.tenant-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.75rem;
  margin: 0 0 0.25rem;
  border: 1px solid transparent;
  border-radius: var(--hrx-radius);
  background: transparent;
  color: var(--hrx-text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.tenant-row:hover { background: var(--hrx-bg-elevated); }
.tenant-row.is-active {
  background: var(--hrx-accent-soft);
  border-color: var(--hrx-info-border);
}
.tenant-row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.tenant-row-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}
.tenant-row-meta {
  font-size: 11px;
  color: var(--hrx-text-muted);
  line-height: 1.35;
}
.tenant-row-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.clients-detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius-lg);
  background: var(--hrx-bg-card);
  box-shadow: var(--hrx-shadow);
  overflow: hidden;
}
.clients-back {
  align-self: flex-start;
  margin: 0.65rem 0.75rem 0;
}
.clients-detail-body {
  flex: 1;
  overflow: auto;
  padding: 0.85rem 1rem 1.1rem;
}
.clients-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 220px;
  gap: 0.35rem;
  padding: 1rem 0.25rem;
}
.clients-empty strong { font-size: 14px; }

.tenant-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.85rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--hrx-border-soft);
}
.tenant-detail-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.tenant-detail-sub {
  margin: 0.25rem 0 0;
  font-size: 12px;
  color: var(--hrx-text-muted);
}

.branding-panel {
  padding: 0.85rem 0 0;
  margin-top: 0.5rem;
  border-top: 1px solid var(--hrx-border-soft);
}
.branding-panel-head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.75rem;
}
.branding-labels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}
.branding-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}
.branding-slot {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 12px;
}
.branding-preview {
  max-width: 100%;
  max-height: 64px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0.5rem;
  border: 1px solid var(--hrx-border-soft);
  background: #fff;
  padding: 0.35rem;
}

.license-panels { display: flex; flex-direction: column; gap: 0.75rem; }
.license-panel {
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius-lg);
  background: var(--hrx-bg-elevated);
  overflow: hidden;
}
.license-panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.85rem 0.95rem;
  border-bottom: 1px solid var(--hrx-border-soft);
  background: var(--hrx-bg-card);
}
.license-panel-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
}
.license-panel-title .mono { font-size: 12px; }
.license-panel-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  margin-top: 0.4rem;
  font-size: 12px;
  color: var(--hrx-text-muted);
}
.license-panel-facts strong {
  color: var(--hrx-text);
  font-weight: 600;
}
.license-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.license-panel-body { padding: 0.85rem 0.95rem; }
.reseller-edit {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: 140px 100px 1fr auto;
  align-items: start;
  margin-bottom: 0.85rem;
}
.reseller-edit .field { margin: 0; }

.license-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.65rem;
}
.license-subtab {
  appearance: none;
  border: 1px solid var(--hrx-border);
  background: transparent;
  color: var(--hrx-text-muted);
  font-size: 11px;
  font-weight: 650;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
}
.license-subtab.is-active {
  background: var(--hrx-accent-soft);
  border-color: var(--hrx-info-border);
  color: var(--hrx-text);
}
.license-subpane[hidden] { display: none !important; }

.install-panel {
  padding: 0.75rem 0.85rem;
  border-radius: var(--hrx-radius);
  border: 1px solid var(--hrx-border-soft);
  background: var(--hrx-bg-nested);
}
.install-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
  align-items: center;
}
.install-block {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  padding: 0.55rem 0;
  border-top: 1px dashed var(--hrx-border-soft);
}
.install-block:first-of-type { border-top: none; padding-top: 0; }
.feature-panel,
.events-panel {
  padding: 0.85rem;
  border-radius: var(--hrx-radius);
  border: 1px solid var(--hrx-info-border);
  background: var(--hrx-accent-soft);
}
.events-panel { border-color: var(--hrx-border-soft); background: var(--hrx-bg-nested); }

/* Drawer nuova licenza */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 81;
  width: min(440px, 100vw);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--hrx-bg-card);
  border-left: 1px solid var(--hrx-border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.25);
}
.drawer[hidden],
.drawer-backdrop[hidden] { display: none !important; }
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--hrx-border-soft);
  background: var(--hrx-bg-elevated);
}
.drawer-body {
  flex: 1;
  overflow: auto;
  padding: 1rem 1.1rem 1.5rem;
}

@media (max-width: 1100px) {
  .clients-layout {
    grid-template-columns: clamp(200px, 32vw, 280px) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .content:has(#tab-licenses:not([hidden])),
  .content:has(#tab-report:not([hidden])) {
    padding: 0.75rem 0.85rem 0.85rem;
    height: auto;
    min-height: 100dvh;
    min-height: 100vh;
    overflow: auto;
  }
  .clients-page,
  .report-page {
    overflow: visible;
    height: auto;
    min-height: calc(100dvh - 1.5rem);
  }
  .clients-layout {
    grid-template-columns: 1fr;
    min-height: calc(100dvh - 11rem);
    flex: 1 1 auto;
  }
  .clients-layout.show-detail .clients-sidebar { display: none; }
  .clients-layout:not(.show-detail) .clients-detail { display: none; }
  .clients-back { display: inline-flex !important; }
  .clients-sidebar,
  .clients-detail {
    min-height: calc(100dvh - 11rem);
  }
  .reseller-edit {
    grid-template-columns: 1fr 1fr;
  }
  .reseller-edit .field:nth-child(3) { grid-column: 1 / -1; }
}

/* ── Report page ─────────────────────────────────────────────────────── */
.report-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.report-page .page-head { margin-bottom: 0.75rem; flex-shrink: 0; }
.report-view-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  padding: 0.25rem;
  margin-bottom: 0.75rem;
  max-width: 420px;
  border-radius: var(--hrx-radius);
  background: var(--hrx-bg-elevated);
  border: 1px solid var(--hrx-border);
  flex-shrink: 0;
}
.report-view-btn {
  border: 0;
  background: transparent;
  color: var(--hrx-text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 0.55rem 0.65rem;
  border-radius: calc(var(--hrx-radius) - 2px);
  cursor: pointer;
}
.report-view-btn:hover { color: var(--hrx-text); }
.report-view-btn.is-active {
  background: var(--hrx-bg-card);
  color: var(--hrx-text);
  box-shadow: var(--hrx-shadow);
}
.report-pane {
  display: none;
  flex: 1;
  min-height: 0;
}
.report-pane.is-active {
  display: flex;
  flex-direction: column;
}
.report-pane-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius-lg);
  background: var(--hrx-bg-card);
  box-shadow: var(--hrx-shadow);
  overflow: hidden;
  padding: 0.75rem 0.85rem 0.85rem;
}
.report-pane-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  margin-bottom: 0.55rem;
}
.report-pane-toolbar-main {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
}
.report-pane-toolbar-main .field { margin: 0; min-width: 0; }
.report-search { flex: 1 1 220px; }
.report-filter-field { flex: 0 1 180px; }
.report-billing-tenant { flex: 1 1 220px; min-width: 180px; }
.report-billing-trial {
  align-self: center;
  margin: 0;
  padding: 0.35rem 0;
  white-space: nowrap;
}
.report-pane-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.report-pane-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.report-legend {
  flex-shrink: 0;
  margin: 0 0 0.55rem;
}
.report-billing-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
  flex-shrink: 0;
}
.report-billing-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 96px;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius);
  background: var(--hrx-bg-elevated);
}
.report-billing-kpi .label {
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--hrx-text-dim);
}
.report-billing-kpi strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.report-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius);
  background: var(--hrx-bg-group);
}
.report-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--hrx-bg-elevated);
}
.report-table td.num,
.report-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.report-row.tone-warn td:first-child { box-shadow: inset 3px 0 0 var(--hrx-warn); }
.report-row.tone-bad td:first-child { box-shadow: inset 3px 0 0 var(--hrx-bad); }
.report-row.tone-ok td:first-child { box-shadow: inset 3px 0 0 var(--hrx-ok); }
.report-row.tone-info td:first-child { box-shadow: inset 3px 0 0 var(--hrx-info); }

@media (max-width: 900px) {
  .report-view-toggle { max-width: none; }
  .report-pane-card { min-height: calc(100dvh - 14rem); }
  .report-pane-toolbar-actions { width: 100%; justify-content: space-between; }
}

@media (max-width: 560px) {
  .report-pane-toolbar-main { width: 100%; }
  .report-search,
  .report-filter-field { flex: 1 1 100%; }
}

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius);
  background: var(--hrx-bg-group);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
table.data th,
table.data td {
  text-align: left;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--hrx-border-soft);
  vertical-align: middle;
  color: var(--hrx-text);
}
table.data th {
  color: var(--hrx-text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--hrx-bg-table-head);
  position: sticky;
  top: 0;
}
table.data tbody tr:hover td { background: var(--hrx-bg-row-hover); }
table.data tbody tr:last-child td { border-bottom: none; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin: 0.5rem 0 0.85rem;
  font-size: 12px;
  color: var(--hrx-text-muted);
}
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.dot {
  width: 8px; height: 8px; border-radius: 999px; display: inline-block;
}
.dot.ok { background: #34d399; }
.dot.warn { background: #fbbf24; }
.dot.bad { background: #f87171; }
.dot.info { background: #60a5fa; }

.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.55rem 0 0.75rem; }
.badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--hrx-text);
  background: var(--hrx-pill-neutral-bg);
  border: 1px solid var(--hrx-border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

/* ── Piani master-detail ─────────────────────────────────────────────── */
.plans-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.plans-page .page-head { margin-bottom: 0.75rem; flex-shrink: 0; }
.plans-layout {
  display: grid;
  grid-template-columns: clamp(220px, 26vw, 340px) minmax(0, 1fr);
  gap: 0.85rem;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}
.plans-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius-lg);
  background: var(--hrx-bg-card);
  box-shadow: var(--hrx-shadow);
  overflow: hidden;
}
.plans-sidebar-tools {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--hrx-border);
  background: var(--hrx-bg-elevated);
}
.plans-sidebar-tools .field { margin: 0; }
.plans-sidebar-tools input,
.plans-sidebar-tools select { width: 100%; }
.plans-list {
  flex: 1;
  overflow: auto;
  padding: 0.35rem;
}
.plan-row {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.75rem;
  margin: 0 0 0.25rem;
  border: 1px solid transparent;
  border-radius: var(--hrx-radius);
  background: transparent;
  color: var(--hrx-text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.plan-row:hover { background: var(--hrx-bg-elevated); }
.plan-row.is-active {
  background: var(--hrx-accent-soft);
  border-color: var(--hrx-info-border);
}
.plan-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.plan-row-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}
.plan-row-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--hrx-accent);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.plan-row-meta {
  font-size: 11px;
  color: var(--hrx-text-muted);
  line-height: 1.35;
}
.plan-row-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.1rem;
}
.plans-detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border: 1px solid var(--hrx-border);
  border-radius: var(--hrx-radius-lg);
  background: var(--hrx-bg-card);
  box-shadow: var(--hrx-shadow);
  overflow: hidden;
}
.plans-back {
  align-self: flex-start;
  margin: 0.65rem 0.75rem 0;
}
.plans-detail-body {
  flex: 1;
  overflow: auto;
  padding: 0.85rem 1rem 1.25rem;
}
.plan-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--hrx-border);
  margin-bottom: 0.85rem;
}
.plan-detail-kicker {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}
.plan-detail-head h3 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--hrx-text);
}
.plan-detail-code {
  margin: 0.3rem 0 0;
  font-size: 12px;
  color: var(--hrx-text-muted);
}
.plan-detail-priceblock {
  text-align: right;
  flex-shrink: 0;
  padding: 0.55rem 0.75rem;
  border-radius: var(--hrx-radius);
  background: var(--hrx-bg-elevated);
  border: 1px solid var(--hrx-border);
  min-width: 7.5rem;
}
.plan-detail-price {
  font-size: 1.65rem;
  font-weight: 750;
  line-height: 1.1;
  color: var(--hrx-accent);
  font-variant-numeric: tabular-nums;
}
.plan-detail-price span {
  font-size: 0.95rem;
  font-weight: 650;
}
.plan-detail-price-sub {
  margin-top: 0.2rem;
  font-size: 11px;
  color: var(--hrx-text-muted);
}
.plan-detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.plan-detail-section {
  margin-bottom: 1.1rem;
}
.plan-section-label {
  margin: 0 0 0.55rem;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hrx-text-muted);
}
.plan-detail-actions {
  margin-top: 0.25rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--hrx-border);
}
.plan-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  padding: 0.25rem;
  border-radius: var(--hrx-radius);
  background: var(--hrx-bg-elevated);
  border: 1px solid var(--hrx-border);
}
.plan-type-btn {
  border: 0;
  background: transparent;
  color: var(--hrx-text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 0.55rem 0.65rem;
  border-radius: calc(var(--hrx-radius) - 2px);
  cursor: pointer;
}
.plan-type-btn:hover { color: var(--hrx-text); }
.plan-type-btn.is-active {
  background: var(--hrx-bg-card);
  color: var(--hrx-text);
  box-shadow: var(--hrx-shadow);
}

.plan-detail .feat-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
}
.plan-detail .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
}

/* Override responsive Piani (dopo le regole base, altrimenti perdono) */
@media (max-width: 1100px) {
  .plans-layout {
    grid-template-columns: clamp(200px, 32vw, 280px) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .content:has(#tab-plans:not([hidden])) {
    padding: 0.75rem 0.85rem 0.85rem;
    height: auto;
    min-height: 100dvh;
    min-height: 100vh;
    overflow: auto;
  }
  .plans-page {
    overflow: visible;
    height: auto;
    min-height: calc(100dvh - 1.5rem);
  }
  .plans-layout {
    grid-template-columns: 1fr;
    min-height: calc(100dvh - 11rem);
    flex: 1 1 auto;
  }
  .plans-layout.show-detail .plans-sidebar { display: none; }
  .plans-layout:not(.show-detail) .plans-detail { display: none; }
  .plans-back { display: inline-flex !important; }
  .plans-sidebar,
  .plans-detail {
    min-height: calc(100dvh - 11rem);
    width: 100%;
  }
  .plan-detail-head { flex-direction: column; }
  .plan-detail-priceblock { text-align: left; width: 100%; box-sizing: border-box; }
}

@media (max-width: 560px) {
  .kpi-strip .kpi { min-width: 76px; padding: 0.45rem 0.55rem; }
  .kpi-strip .kpi .value { font-size: 1rem; }
  .plan-detail-head h3 { font-size: 1.15rem; }
  .plan-detail-price { font-size: 1.35rem; }
  .plan-detail .feat-grid { grid-template-columns: 1fr; }
  .page-head .actions { width: 100%; }
  .page-head .actions button { flex: 1; }
}

.empty {
  padding: 1.25rem;
  text-align: center;
  color: var(--hrx-empty-text);
  background: var(--hrx-empty-bg);
  font-size: 13px;
  border-radius: var(--hrx-radius);
}

@media (max-width: 960px) {
  :root { --sidebar-w: 200px; }
  .sidebar-brand-text strong { font-size: 12px; }
}

@media (max-width: 780px) {
  #shell,
  #shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }
  .sidebar,
  #shell.sidebar-collapsed .sidebar {
    position: relative;
    height: auto;
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--hrx-border);
    padding: 0.75rem;
  }
  .sidebar-brand,
  #shell.sidebar-collapsed .sidebar-brand {
    margin-bottom: 0.25rem;
    padding: 0.4rem 0.55rem 0.65rem;
    flex-direction: row;
    gap: 0.65rem;
    justify-content: flex-start;
  }
  .sidebar-brand-text,
  #shell.sidebar-collapsed .sidebar-brand-text {
    display: flex;
  }
  .sidebar-collapse-btn {
    display: none;
  }
  .nav-tabs {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .nav-tabs button,
  #shell.sidebar-collapsed .nav-tabs button {
    width: auto;
    flex: 1 1 calc(50% - 0.35rem);
    justify-content: center;
    padding: 0.55rem 0.5rem;
    font-size: 12px;
    gap: 0.4rem;
  }
  #shell.sidebar-collapsed .nav-tabs button .nav-label {
    display: inline;
  }
  .sidebar-foot,
  #shell.sidebar-collapsed .sidebar-foot {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.75rem;
  }
  #shell.sidebar-collapsed .sidebar-foot .auth-label {
    display: block;
  }
  .sidebar-foot #btn-logout {
    align-self: stretch;
    flex: 0 0 auto;
    min-width: 0;
  }
  #shell.sidebar-collapsed .sidebar-foot #btn-logout .logout-label {
    display: inline;
  }
  #shell.sidebar-collapsed .sidebar-foot #btn-logout .logout-ico {
    display: none;
  }
  .form-grid .span-2 { grid-column: span 1; }
  .content { padding: 1rem; }
  .page-head h2 { font-size: 1rem; }
}

/* ── Theme switcher ──────────────────────────────────────────────────── */
.theme-switch {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.3rem;
  border: 1px solid var(--hrx-border-soft);
  border-radius: var(--hrx-radius);
  background: var(--hrx-bg-input);
}
.theme-switch.theme-switch-settings {
  max-width: 520px;
}
.theme-switch button {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  color: var(--hrx-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.5rem 0.2rem;
  min-width: 0;
  gap: 0.25rem;
  flex-direction: column;
}
.theme-switch button:hover {
  background: var(--hrx-ghost-hover);
  color: var(--hrx-text);
}
.theme-switch button.active {
  background: var(--hrx-accent);
  border-color: var(--hrx-accent-hover);
  color: #fff;
  box-shadow: none;
}
.theme-switch .swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  display: block;
}
.theme-switch .swatch.system {
  background:
    linear-gradient(90deg, #f8fafc 50%, #0d1117 50%);
}
.theme-switch .swatch.light { background: linear-gradient(135deg, #f8fafc, #e2e8f0); }
.theme-switch .swatch.dark { background: linear-gradient(135deg, #1e293b, #334155); }
.theme-switch .swatch.black { background: linear-gradient(135deg, #000, #262626); }
.theme-switch .swatch.blue { background: linear-gradient(135deg, #0d1117, #1e3a5f); }

/* ── Login topbar: health + theme quick (come HRX) ───────────────────── */
.login-topbar {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
@media (min-width: 640px) {
  .login-topbar {
    top: 1rem;
    right: 1rem;
  }
}
.login-topbar[hidden] { display: none !important; }

.health-badge { position: relative; }
.health-badge-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-radius: 0.55rem;
  border: 1px solid #334155;
  background: #1e293b;
  color: #94a3b8;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  cursor: default;
  box-shadow: none;
}
.health-badge-btn:hover { background: #1e293b; }
.health-badge-btn:active { transform: none; }
.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #64748b;
  flex-shrink: 0;
}
.health-badge[data-status="checking"] .health-dot {
  background: #64748b;
  animation: health-pulse 1.2s ease-in-out infinite;
}
.health-badge[data-status="ok"] .health-badge-btn {
  border-color: #065f46;
  background: #1e293b;
}
.health-badge[data-status="ok"] .health-dot { background: #10b981; }
.health-badge[data-status="ok"] .health-label { color: #34d399; }
.health-badge[data-status="error"] .health-badge-btn {
  border-color: #b91c1c;
  background: #7f1d1d;
  cursor: pointer;
}
.health-badge[data-status="error"] .health-badge-btn:hover { background: #991b1b; }
.health-badge[data-status="error"] .health-dot {
  background: #ef4444;
  animation: health-pulse 1.2s ease-in-out infinite;
}
.health-badge[data-status="error"] .health-label { color: #fca5a5; }
@keyframes health-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.health-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 14rem;
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid #334155;
  background: #1e293b;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  z-index: 50;
  font-size: 12px;
}
.health-tooltip[hidden] { display: none !important; }
.health-tooltip-title {
  margin: 0 0 0.55rem;
  font-weight: 650;
  color: #e2e8f0;
}
.health-tooltip-rows {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.health-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: #94a3b8;
}
.health-row > span:last-child {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
}
.health-row > span:last-child i {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #64748b;
  display: inline-block;
}
.health-row > span:last-child.is-ok { color: #34d399; }
.health-row > span:last-child.is-ok i { background: #10b981; }
.health-row > span:last-child.is-bad { color: #f87171; }
.health-row > span:last-child.is-bad i { background: #ef4444; }
.health-tooltip-meta {
  margin: 0.55rem 0 0;
  color: #475569;
  font-size: 10px;
}
.health-tooltip-msg {
  margin: 0.35rem 0 0;
  color: #64748b;
  font-size: 10px;
  line-height: 1.35;
}
.health-retry {
  margin-top: 0.55rem;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  background: #334155;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  box-shadow: none;
}
.health-retry:hover { background: #475569; }

.theme-quick {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.theme-quick-cycle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border: none;
  border-radius: 0.75rem;
  background: transparent;
  color: #94a3b8;
  box-shadow: none;
}
.theme-quick-cycle:hover {
  background: rgba(30, 41, 59, 0.8);
  color: #e2e8f0;
}
.theme-quick-cycle:active { transform: none; }
.theme-quick-cycle svg {
  width: 18px;
  height: 18px;
  display: block;
}
.theme-quick-surface {
  padding: 0.2rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(29, 78, 216, 0.55);
  background: rgba(23, 37, 84, 0.45);
  color: #93c5fd;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: none;
  line-height: 1.3;
}
.theme-quick-surface:hover {
  filter: brightness(1.08);
}
.theme-quick-surface.is-black {
  border-color: #475569;
  background: rgba(30, 41, 59, 0.85);
  color: #cbd5e1;
}
[data-theme="light"] .theme-quick-cycle {
  color: #64748b;
}
[data-theme="light"] .theme-quick-cycle:hover {
  background: rgba(226, 232, 240, 0.9);
  color: #0f172a;
}
[data-theme="light"] .health-badge-btn {
  background: #fff;
  border-color: #cbd5e1;
}
[data-theme="light"] .health-badge[data-status="ok"] .health-badge-btn {
  border-color: #6ee7b7;
  background: #fff;
}
[data-theme="light"] .health-tooltip {
  background: #fff;
  border-color: #cbd5e1;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}
[data-theme="light"] .health-tooltip-title { color: #0f172a; }
[data-theme="light"] .health-retry {
  background: #f1f5f9;
  color: #334155;
}

/* ── Anagrafica clienti ──────────────────────────────────────────────── */
.anagrafica-form {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: 920px;
}
.ana-section {
  margin: 0 0 1rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--hrx-border-soft);
  border-radius: var(--hrx-radius);
  background: var(--hrx-bg-elevated);
}
.ana-section h4 {
  margin: 0 0 0.65rem;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hrx-text-dim);
}
.anagrafica-form .sticky-actions {
  position: sticky;
  bottom: 0;
  margin-top: 0.25rem;
  padding: 0.75rem 0 0.15rem;
  background: linear-gradient(to top, var(--hrx-bg-card) 70%, transparent);
  align-items: center;
  gap: 0.75rem;
}

@media (max-width: 520px) {
  .theme-switch {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
