/* ============================================================
   Scriba AI · Brand Kit v1.0
   Dark mode nativa. Accent: Scriba Orange, dosato sotto il 15%.
   Font: Sora (heading) · Inter Tight (body) · Instrument Serif
   (highlight editoriale) · IBM Plex Mono (codice, eyebrow).
   Motion: lento e deliberato — cubic-bezier(0.25, 0.1, 0.25, 1).
   ============================================================ */

:root {
  --primary: #FF6A1A;
  --primary-light: #FF8B4D;
  --primary-dark: #D94E00;

  --bg: #0D1017;
  --bg-2: #11141D;
  --bg-3: #191D2A;
  --bg-4: #252A32;

  --fg: #F8F9FA;
  --fg-muted: rgba(248, 249, 250, .55);
  --fg-faint: rgba(248, 249, 250, .35);
  --line: rgba(248, 249, 250, .09);
  --line-strong: rgba(248, 249, 250, .16);

  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #227EFF;

  --grad-glow: linear-gradient(135deg, #FF6A1A, #FF8B4D);
  --grad-surface: radial-gradient(ellipse at 30% 30%, rgba(255, 106, 26, .08), transparent 60%);

  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter Tight", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg) var(--grad-surface);
  background-attachment: fixed;
  color: var(--fg);
}

/* ---------- Header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.1rem 2rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.brandlock { display: flex; align-items: center; gap: .8rem; }
.logo { height: 40px; width: auto; display: block; }
.wordmark {
  font-family: "Inter Tight", sans-serif;
  font-weight: 400;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}
.wordmark span { font-weight: 600; color: var(--primary); }

.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--fg-muted);
}

/* ---------- Struttura ---------- */

.container { max-width: 980px; margin: 0 auto; padding: 2.5rem 1rem 3rem; }

.pagehead { margin-bottom: 2.25rem; }
.pagehead .eyebrow { color: var(--primary); margin-bottom: .9rem; }

h1 {
  font-family: "Sora", sans-serif;
  font-weight: 400;
  font-size: clamp(2rem, 4.5vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 .9rem;
}
.lede {
  font-size: 1.05rem;
  color: var(--fg-muted);
  max-width: 56ch;
  margin: 0;
}
.lede em {
  font-family: "Instrument Serif", serif;
  font-style: italic;
  font-size: 1.12em;
  color: var(--fg);
}

.card {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}
.card > .eyebrow { color: var(--primary); margin-bottom: .8rem; }

h2 {
  font-family: "Sora", sans-serif;
  font-weight: 400;
  font-size: 1.4rem;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 1.1rem;
  display: flex;
  align-items: center;
  gap: .7rem;
}
h3 {
  font-family: "Sora", sans-serif;
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  margin: .5rem 0 .5rem;
}

.stepnum {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  border: 1px solid var(--primary);
  color: var(--primary);
  background: transparent;
  font-family: "IBM Plex Mono", monospace;
  font-size: .9rem;
  font-weight: 500;
  flex: none;
}

.hint { color: var(--fg-muted); font-size: .92rem; margin: -.25rem 0 1.1rem; }
code {
  font-family: "IBM Plex Mono", monospace;
  font-size: .85em;
  background: var(--bg-4);
  border: 1px solid var(--line);
  padding: .05em .4em;
  border-radius: 4px;
}

/* ---------- Form ---------- */

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.25rem; }
.grid .wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }

label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; font-weight: 500; }
input, select, textarea {
  font: inherit;
  font-weight: 400;
  color: var(--fg);
  padding: .6rem .75rem;
  background: var(--bg-4);
  border: 1px solid var(--line);
  border-radius: 6px;
  transition: border-color .4s var(--ease), box-shadow .4s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--fg-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 106, 26, .18);
}
input.invalid, select.invalid, textarea.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .15);
}
select option { background: var(--bg-3); color: var(--fg); }

/* ---------- Dropzone ---------- */

.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  padding: 2.25rem;
  text-align: center;
  color: var(--fg-muted);
  transition: border-color .5s var(--ease), background .5s var(--ease);
}
.dropzone.drag {
  border-color: var(--primary);
  background: var(--grad-surface), var(--bg-2);
}
.dz-buttons { display: flex; gap: .75rem; justify-content: center; margin-top: .8rem; flex-wrap: wrap; }

.btn {
  font: inherit;
  font-weight: 600;
  padding: .65rem 1.4rem;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter .4s var(--ease), border-color .4s var(--ease), background .4s var(--ease);
}
.btn.primary {
  background: var(--grad-glow);
  color: #0D1017;
  border-color: transparent;
}
.btn.primary:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  color: var(--primary);
  border-color: rgba(255, 106, 26, .45);
}
.btn.ghost:hover { border-color: var(--primary); background: rgba(255, 106, 26, .08); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }

.filelist { margin-top: 1rem; font-size: .88rem; color: var(--fg-muted); }
.filelist ul { margin: .4rem 0 0; padding-left: 1.2rem; max-height: 180px; overflow: auto; }
.filelist em { font-style: normal; color: var(--fg-faint); font-family: "IBM Plex Mono", monospace; font-size: .82em; }

.altlink { margin-top: 1.1rem; font-size: .9rem; }
.altlink summary { cursor: pointer; color: var(--primary); font-weight: 500; }
.altlink label { margin-top: .7rem; }

.actions { display: flex; gap: .75rem; margin-top: 1.4rem; flex-wrap: wrap; }
.hidden { display: none !important; }

/* ---------- Feedback A · righe ---------- */

.loc-summary { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.loc-kpi {
  flex: 1 1 150px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .9rem 1.1rem;
}
.loc-kpi .n {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.55rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--primary-light);
}
.loc-kpi .t { font-size: .8rem; color: var(--fg-muted); margin-top: .15rem; }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td {
  text-align: left;
  padding: .5rem .65rem;
  border-bottom: 1px solid var(--line);
}
th {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  border-bottom-color: var(--line-strong);
}
td.num, th.num {
  text-align: right;
  font-family: "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
}
td { color: rgba(248, 249, 250, .85); }

.ignored { margin-top: 1.1rem; }
.ignored summary { cursor: pointer; font-weight: 500; color: var(--primary); margin-bottom: .5rem; }

/* ---------- Feedback B · checklist ---------- */

.scorebar {
  position: relative;
  background: var(--bg-4);
  border: 1px solid var(--line);
  border-radius: 999px;
  height: 1.7rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.score-fill {
  height: 100%;
  width: 0;
  background: var(--grad-glow);
  transition: width 1s var(--ease), background 1s var(--ease);
}
.scorebar span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .05em;
}

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li {
  display: flex;
  gap: .8rem;
  padding: .8rem .2rem;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}
.checklist .icon {
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: .1rem;
}
.checklist .icon svg { width: 15px; height: 15px; }
.icon.ok { background: rgba(34, 197, 94, .15); color: var(--success); border: 1px solid rgba(34, 197, 94, .5); }
.icon.warn { background: rgba(245, 158, 11, .12); color: var(--warning); border: 1px solid rgba(245, 158, 11, .5); }
.icon.err { background: rgba(239, 68, 68, .12); color: var(--danger); border: 1px solid rgba(239, 68, 68, .5); }

.checklist .body { flex: 1; }
.checklist .title { font-weight: 600; }
.checklist .title .badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .2em .5em;
  border-radius: 4px;
  margin-left: .55rem;
  vertical-align: middle;
}
.badge.req { background: rgba(239, 68, 68, .12); color: var(--danger); border: 1px solid rgba(239, 68, 68, .4); }
.badge.rec { background: rgba(245, 158, 11, .1); color: var(--warning); border: 1px solid rgba(245, 158, 11, .35); }
.checklist .detail { font-size: .88rem; color: var(--fg-muted); margin-top: .2rem; }
.checklist .fix { font-size: .88rem; margin-top: .3rem; }
.checklist .fix::before { content: "→ "; color: var(--primary); font-weight: 700; }

.ai-review {
  margin-top: 1.4rem;
  background: var(--bg-2);
  border: 1px solid rgba(255, 106, 26, .3);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
}
.ai-review ul { margin: .3rem 0 0; padding-left: 1.2rem; font-size: .9rem; color: rgba(248, 249, 250, .85); }
.ai-review li { margin-bottom: .35rem; }

.submit-status { margin-top: 1.1rem; font-size: .93rem; }
.submit-status.ok { color: var(--success); }
.submit-status.err { color: var(--danger); }

.footer {
  text-align: center;
  color: var(--fg-faint);
  font-size: .85rem;
  padding: 2rem 1rem 2.5rem;
  border-top: 1px solid var(--line);
}

/* ---------- Login ---------- */

.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-wrap { width: 100%; max-width: 430px; padding: 1rem; }
.login-card { padding: 2.25rem; }
.login-brand .logo { height: 48px; }
.login-brand .wordmark { font-size: 1.5rem; }
.login-title { font-size: 1.8rem; margin-bottom: .6rem; }

/* ---------- Barra utente ---------- */

.usernav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.userchip {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .05em;
  color: var(--fg-muted);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: .35rem .8rem;
}
.navlink { color: var(--primary); text-decoration: none; font-weight: 500; font-size: .92rem; }
.navlink:hover { color: var(--primary-light); }

.btn.small { padding: .4rem .9rem; font-size: .85rem; }

/* ---------- Admin ---------- */

.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.cardhead h2 { margin: 0; }

.mono { font-family: "IBM Plex Mono", monospace; font-size: .85em; }

.empty { color: var(--fg-muted); padding: 1.2rem .65rem; }

.status-pill {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .05em;
  padding: .25em .7em;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--fg-muted);
  white-space: nowrap;
}
.status-pill.st-inviata { color: var(--info); border-color: rgba(34, 126, 255, .5); }
.status-pill.st-in_analisi { color: var(--warning); border-color: rgba(245, 158, 11, .5); }
.status-pill.st-offerta_inviata { color: var(--primary-light); border-color: rgba(255, 106, 26, .5); }
.status-pill.st-in_migrazione { color: var(--primary); border-color: rgba(255, 106, 26, .6); }
.status-pill.st-consegnata { color: var(--success); border-color: rgba(34, 197, 94, .5); }
.status-pill.st-chiusa { color: var(--fg-faint); }

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem 2rem;
  margin-bottom: 1.25rem;
  font-size: .92rem;
}
@media (max-width: 640px) { .detail-meta { grid-template-columns: 1fr; } }
.detail-meta div { display: flex; flex-direction: column; gap: .1rem; }
.detail-meta div > span:first-child {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.statusrow { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.statusrow label { min-width: 260px; }

.reportbox summary { cursor: pointer; color: var(--primary); font-weight: 500; }
.reportbox pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  max-height: 420px;
  overflow: auto;
  font-size: .8rem;
  color: rgba(248, 249, 250, .8);
}

.userform { margin-bottom: 1.5rem; }
.userform .formactions { display: flex; align-items: flex-end; gap: 1rem; }
.rowactions { white-space: nowrap; }
.rowactions .btn { margin-right: .4rem; }

/* ---------- Guida ---------- */

.guide .serif {
  font-family: "Instrument Serif", serif;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
}
.guide p { max-width: 70ch; }
.guide .toc ol { margin: .5rem 0 0; padding-left: 1.4rem; }
.guide .toc li { margin-bottom: .4rem; }
.guide .toc a { color: var(--fg); text-decoration: none; border-bottom: 1px solid rgba(255,106,26,.4); }
.guide .toc a:hover { color: var(--primary-light); }

.guide .card p { color: rgba(248, 249, 250, .85); }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.25rem 0; }
@media (max-width: 760px) { .compare { grid-template-columns: 1fr; } }
.box { border-radius: 10px; padding: 1.1rem 1.2rem; border: 1px solid var(--line); }
.box.bad { background: rgba(239, 68, 68, .06); border-color: rgba(239, 68, 68, .35); }
.box.good { background: rgba(34, 197, 94, .06); border-color: rgba(34, 197, 94, .35); }
.boxhead {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
  margin-bottom: .7rem;
}
.box.bad .boxhead { color: var(--danger); }
.box.good .boxhead { color: var(--success); }
.box p { font-size: .9rem; margin: .8rem 0 0; color: var(--fg-muted); }

.codeblock, .box pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .9rem 1rem;
  overflow-x: auto;
  font-size: .82rem;
  line-height: 1.55;
  color: rgba(248, 249, 250, .85);
  white-space: pre;
}

.section-block { border-top: 1px solid var(--line); padding: 1.1rem 0 .4rem; }
.section-block h3 { margin: 0 0 .5rem; }
.section-block p { font-size: .93rem; }

ul.plain { padding-left: 1.3rem; }
ul.plain li { margin-bottom: .5rem; color: rgba(248, 249, 250, .85); }

.checklist-plain { list-style: none; padding: 0; margin: 0 0 1rem; }
.checklist-plain li {
  padding: .55rem 0 .55rem 1.9rem;
  position: relative;
  border-bottom: 1px solid var(--line);
  color: rgba(248, 249, 250, .85);
  font-size: .93rem;
}
.checklist-plain li::before {
  content: "";
  position: absolute;
  left: 0; top: .72rem;
  width: .9rem; height: .9rem;
  border: 1.5px solid var(--primary);
  border-radius: 3px;
}

.guide-linkbox {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid rgba(255, 106, 26, .3);
  border-radius: 10px;
  padding: .9rem 1.2rem;
  margin-bottom: 1.25rem;
  font-size: .92rem;
}
.guide-linkbox .eyebrow { color: var(--primary); }
