@font-face { font-family: "Archivo"; src: url("/static/fonts/archivo.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --lit: #F7B914;
  --lit-soft: #FFF4D2;
  --lit-ink: #7A5600;       /* giallo leggibile su bianco */
  --graphite: #1F1F1F;
  --graphite-2: #2C2C2C;
  --paper: #FFFFFF;
  --concrete: #F2F2EF;
  --line: #DCDCD7;
  --stone: #6E6E6A;
  --ok: #2F7D4F;
  --error: #B3261E;
  --r-s: 6px;
  --r-house: 14px 14px 14px 3px; /* angolo vivo come la base aperta del logo */
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 15px; line-height: 1.5; color: var(--graphite);
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--concrete); }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 30px; line-height: 1.15; font-weight: 680; }
h2 { font-size: 19px; font-weight: 640; }
h3 { font-size: 15px; font-weight: 620; }
p { margin: 0; }
code { font-size: 13px; background: var(--concrete); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 3px solid var(--lit); outline-offset: 2px; }
.muted { color: var(--stone); }
.small { font-size: 13px; }

/* ---------- house symbol ---------- */
.house-svg path { fill: none; stroke-width: 14; stroke-linejoin: round; }
.house-svg .h-open { stroke: var(--lit); }
.house-svg .h-close { stroke: var(--lit); stroke-dasharray: 260; stroke-dashoffset: 260; transition: stroke-dashoffset .6s cubic-bezier(.6,.1,.2,1); }
.is-filled .house-svg .h-close { stroke-dashoffset: 0; }
.is-error .house-svg .h-open, .is-error .house-svg .h-close { stroke: var(--error); }
@media (prefers-reduced-motion: reduce) { .house-svg .h-close { transition: none; } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 1.1fr) 1fr; }
.login-art { background: var(--graphite); color: #fff; padding: 48px; position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 56px; }
.login-logo { width: 84px; position: relative; z-index: 1; }
.login-house { position: absolute; right: -16%; bottom: -34%; width: 92%; }
.login-house path { fill: none; stroke: var(--lit); stroke-width: 14; stroke-linejoin: round; }
.login-art p { position: relative; z-index: 1; max-width: 22ch; font-size: 26px; line-height: 1.2; font-weight: 600; }
.login-form { align-self: center; justify-self: center; width: min(380px, 90vw); display: grid; gap: 16px; padding: 32px 0; }
.hint { font-size: 13px; color: var(--stone); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--graphite) 232px, transparent 232px); }
.rail { background: var(--graphite); color: #EDEDEA; display: flex; flex-direction: column; padding: 22px 14px; gap: 2px; position: sticky; top: 0; height: 100vh; }
.rail-logo { padding: 0 10px 26px; }
.rail-logo img { width: 58px; display: block; }
.rail a[data-route] { text-decoration: none; padding: 9px 12px; border-radius: var(--r-s); font-weight: 520; color: #CFCFCB; }
.rail a[data-route]:hover { color: #fff; background: var(--graphite-2); }
.rail a.active { color: var(--graphite); background: var(--lit); border-radius: var(--r-house); }
.rail-foot { margin-top: auto; padding: 12px; font-size: 13px; color: #A9A9A5; display: grid; gap: 6px; }
.rail-foot .who { color: #fff; word-break: break-all; }
.engine { display: flex; gap: 8px; align-items: center; }
.engine::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--stone); flex: none; }
.engine.ok::before { background: var(--lit); }
.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; justify-self: start; }

main { padding: 40px 48px 80px; max-width: 1180px; width: 100%; outline: none; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-head p { color: var(--stone); margin-top: 6px; max-width: 64ch; }

/* ---------- blocks ---------- */
.panel { background: var(--paper); border-radius: var(--r-s); padding: 24px; margin-bottom: 20px; }
.panel > header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.step { display: grid; grid-template-columns: 44px 1fr; gap: 0 16px; margin-bottom: 20px; }
.step-n { width: 34px; height: 34px; border-radius: var(--r-house); background: var(--graphite); color: #fff; display: grid; place-items: center; font-weight: 650; margin-top: 22px; }
.step.done .step-n { background: var(--lit); color: var(--graphite); }
.step.locked { opacity: .45; pointer-events: none; }

/* ---------- forms ---------- */
label { display: grid; gap: 5px; font-size: 13.5px; font-weight: 560; }
label .opt { font-weight: 400; color: var(--stone); }
input, select, textarea { font: inherit; font-size: 15px; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-s); background: #fff; color: var(--graphite); min-width: 0; }
input:focus, select:focus { border-color: var(--graphite); outline: none; box-shadow: 0 0 0 3px var(--lit-soft); }
input[aria-invalid="true"] { border-color: var(--error); }
.field-error { color: var(--error); font-size: 12.5px; font-weight: 500; min-height: 0; }
.form-error { color: var(--error); font-size: 14px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn { font: inherit; font-weight: 600; font-size: 14.5px; border: 1px solid var(--graphite); background: #fff; color: var(--graphite); padding: 9px 16px; border-radius: var(--r-s); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: var(--concrete); }
.btn.primary { background: var(--lit); border-color: var(--lit); border-radius: var(--r-house); }
.btn.primary:hover { background: #E9AC06; }
.btn.dark { background: var(--graphite); color: #fff; }
.btn.ghost { border-color: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { padding: 13px 22px; font-size: 16px; }

/* ---------- drop zones (casa lit) ---------- */
.drops { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.drop { position: relative; border-radius: var(--r-s); padding: 18px 18px 16px; background: var(--concrete); cursor: pointer; display: grid; grid-template-rows: auto 1fr auto; min-height: 236px; transition: background .15s; }
.drop:hover, .drop.over { background: var(--lit-soft); }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.house-wrap { position: relative; width: 104px; height: 104px; justify-self: center; margin: 10px 0 8px; }
.drop .house-svg { width: 104px; height: 104px; display: block; }
.drop .house-label { position: absolute; left: 0; right: 0; top: 54%; text-align: center; font-weight: 700; font-size: 13px; pointer-events: none; }
.drop h3 { display: flex; justify-content: space-between; gap: 8px; }
.drop .tag { font-size: 12px; font-weight: 500; color: var(--stone); }
.drop .file { font-size: 13px; word-break: break-all; }
.drop .file b { display: block; font-weight: 620; }
.drop.over .house-svg .h-close { stroke-dashoffset: 120; }
.drops.wide { grid-template-columns: 1fr; }
.drops.wide .drop { grid-template-columns: 120px 1fr; grid-template-rows: auto; min-height: 150px; align-items: center; gap: 20px; }
.drops.wide .house-wrap { margin: 0; justify-self: start; }

/* ---------- mapping ---------- */
.mapping { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px 18px; }
.mapping label { font-weight: 500; }
.mapping select.unset { color: var(--stone); }
.preview { overflow-x: auto; margin-top: 16px; border: 1px solid var(--line); border-radius: var(--r-s); }
.issues { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13.5px; }
.issues li { padding-left: 14px; border-left: 3px solid var(--lit); }
.issues li.err { border-color: var(--error); color: var(--error); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 13px; padding: 9px 10px; border-bottom: 2px solid var(--graphite); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.r, th.r { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #FAFAF8; }
.preview table { font-size: 12.5px; }
.preview th { border-bottom-width: 1px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 560; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--stone); }
.status.done::before { background: var(--ok); }
.status.running::before, .status.queued::before { background: var(--lit); }
.status.error::before { background: var(--error); }

/* ---------- progress ---------- */
.progress { height: 10px; background: var(--concrete); border-radius: 5px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--lit); width: 0; transition: width .4s; }
.result { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; }
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 2px solid var(--graphite); margin: 20px 0 4px; }
.figures div { padding: 12px 14px 4px 0; }
.figures div + div { padding-left: 14px; border-left: 1px solid var(--line); }
.figures b { display: block; font-size: 24px; font-weight: 660; letter-spacing: -0.01em; }
.figures span { font-size: 13px; color: var(--stone); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: var(--concrete); }
.outline-list { margin: 8px 0 0; padding-left: 20px; columns: 2; font-size: 14px; }

.empty { text-align: left; padding: 28px 0 8px; color: var(--stone); }
.empty strong { display: block; color: var(--graphite); font-size: 16px; margin-bottom: 4px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--graphite); color: #fff; padding: 11px 18px; border-radius: var(--r-house); opacity: 0; pointer-events: none; transition: .25s; max-width: 90vw; font-size: 14px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--error); }

details summary { cursor: pointer; font-weight: 560; }
pre.err { white-space: pre-wrap; font-size: 12px; background: var(--concrete); padding: 10px; border-radius: var(--r-s); max-height: 180px; overflow: auto; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .rail-logo { padding: 0 10px 0 0; } .rail-logo img { width: 40px; }
  .rail-foot { margin: 0 0 0 auto; padding: 0; grid-auto-flow: column; align-items: center; }
  .rail-foot .engine, .rail-foot .who { display: none; }
  main { padding: 24px 18px 60px; }
  .drops, .g3, .g4, .figures { grid-template-columns: 1fr 1fr; }
  .login { grid-template-columns: 1fr; } .login-art { min-height: 260px; }
}
@media (max-width: 600px) {
  .drops, .g2, .g3, .g4 { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  .step { grid-template-columns: 1fr; } .step-n { margin: 0 0 8px; }
  .result { grid-template-columns: 1fr; }
}
