/* Lead Finder - stile condiviso (login + app). Colori come token: tema chiaro/scuro/automatico. */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5; --border: #dfe3e8; --border-strong: #c5ccd6;
  --text: #151b26; --text-2: #4a5566; --text-3: #6b7585;
  --accent: #3b5bdb; --accent-hover: #3049b8; --accent-soft: #e8edff; --on-accent: #ffffff;
  --alta: #b42318; --alta-bg: #fee4e2; --media: #9a5b00; --media-bg: #fef0c7; --bassa: #475467; --bassa-bg: #eaecf0;
  --ok: #067647; --ok-bg: #dcfae6; --warn: #9a5b00; --warn-bg: #fef0c7; --err: #b42318; --err-bg: #fee4e2;
  --focus: #3b5bdb; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --radius: 12px; --radius-sm: 8px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1219; --surface: #161b24; --surface-2: #1d2430; --border: #2a3240; --border-strong: #3a4454;
  --text: #e8ebf0; --text-2: #b3bcc9; --text-3: #8b95a5;
  --accent: #7c9bff; --accent-hover: #9bb2ff; --accent-soft: #1f2a4a; --on-accent: #0b1020;
  --alta: #ff9c93; --alta-bg: #3d1d1b; --media: #fdc56b; --media-bg: #3a2c12; --bassa: #c3cad5; --bassa-bg: #262d38;
  --ok: #6ce9a6; --ok-bg: #123524; --warn: #fdc56b; --warn-bg: #3a2c12; --err: #ff9c93; --err-bg: #3d1d1b;
  --focus: #9bb2ff; --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1219; --surface: #161b24; --surface-2: #1d2430; --border: #2a3240; --border-strong: #3a4454;
    --text: #e8ebf0; --text-2: #b3bcc9; --text-3: #8b95a5;
    --accent: #7c9bff; --accent-hover: #9bb2ff; --accent-soft: #1f2a4a; --on-accent: #0b1020;
    --alta: #ff9c93; --alta-bg: #3d1d1b; --media: #fdc56b; --media-bg: #3a2c12; --bassa: #c3cad5; --bassa-bg: #262d38;
    --ok: #6ce9a6; --ok-bg: #123524; --warn: #fdc56b; --warn-bg: #3a2c12; --err: #ff9c93; --err-bg: #3d1d1b;
    --focus: #9bb2ff; --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
.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; }
.skip { position: absolute; left: 12px; top: -48px; background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: var(--radius-sm); z-index: 100; font-weight: 600; }
.skip:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }

/* ---- pulsanti ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; color: var(--err); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 40px; padding: 0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-sm svg { width: 16px; height: 16px; }

/* ---- form ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 600; font-size: 14px; }
.hint { color: var(--text-3); font-size: 13px; }
.input, select.input {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit;
}
.input:hover { border-color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-3); }
.error-text { color: var(--err); font-size: 14px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; min-height: 32px; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; flex: none; margin: 0; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

/* ---- card e layout ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }

/* ---- badge ---- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; line-height: 20px; }
.badge-ALTA { color: var(--alta); background: var(--alta-bg); }
.badge-MEDIA { color: var(--media); background: var(--media-bg); }
.badge-BASSA { color: var(--bassa); background: var(--bassa-bg); }
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.badge-err { color: var(--err); background: var(--err-bg); }
.badge-neutral { color: var(--text-2); background: var(--surface-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

/* ---- dialog ---- */
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(10, 14, 22, .55); }
dialog .card-head { border-bottom: 1px solid var(--border); }
dialog .dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ---- toast ---- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 14px; max-width: 420px; }
.toast.err { background: var(--err); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
