/* ── Variables & Reset ─────────────────────────────────── */

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

:root {
  --ink:          #18180f;
  --paper:        #f4f1ea;
  --card:         #faf8f3;
  --border:       #ddd8cc;
  --border-light: #e8e4da;
  --muted:        #8c8779;
  --muted-light:  #b5b0a5;
  --hover-bg:     #eeebe3;
  --accent:       #c44a08;
  --accent-bg:    #fff4ef;
  --green:        #1e5c35;
  --green-bg:     #eaf3ee;
  --gold:         #a07c10;
  --gold-bg:      #fdf6e3;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 14px rgba(0,0,0,.09), 0 2px 4px rgba(0,0,0,.05);
  --mono:         'IBM Plex Mono', monospace;
  --sans:         'Inter', sans-serif;
}

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ────────────────────────────────────────────── */

.header {
  height: 50px;
  padding: 0 20px;
  background: var(--ink);
  border-bottom: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.main {
  display: flex;
  height: calc(100vh - 50px);
}

.sidebar {
  width: 290px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Header ────────────────────────────────────────────── */

.logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: #f5f2eb;
  letter-spacing: -.5px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.logo span { color: #d4500a; }

.logo-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg { width: 13px; height: 13px; color: white; }

.header-right { display: flex; align-items: center; gap: 8px; }

.header-badge {
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(255,255,255,.45);
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  padding: 4px 11px;
  border-radius: 20px;
  letter-spacing: .3px;
}

.header-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3dab6a;
  box-shadow: 0 0 0 3px rgba(61,171,106,.2);
}

/* ── Sidebar: upload section ───────────────────────────── */

.sb-upload {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  background: white;
}

/* Shared uppercase section label */
.section-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--muted);
  margin-bottom: 10px;
}

/* Dropzone */
.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  background: var(--paper);
  position: relative;
  overflow: hidden;
  transition: border-color .2s, background .2s, box-shadow .2s;
}

.dropzone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(196,74,8,.05) 0%, transparent 60%);
  opacity: 0;
  transition: opacity .2s;
}

.dropzone:hover { border-color: var(--accent); background: white; box-shadow: var(--shadow-sm); }
.dropzone:hover::before { opacity: 1; }

.dropzone-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
  box-shadow: var(--shadow-sm);
}

.dropzone-icon svg { width: 15px; height: 15px; color: var(--muted); }

.dz-title { font-weight: 600; font-size: 12px; color: var(--ink); margin-bottom: 2px; }
.dz-sub   { font-size: 10.5px; color: var(--muted); line-height: 1.5; }

.dz-formats { display: flex; gap: 4px; justify-content: center; margin-top: 8px; }

/* Chip badge — used for format tags, tariffa code, unit of measure */
.dz-fmt, .tbadge, .um-b {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  background: white;
  border: 1px solid var(--border-light);
  border-radius: 5px;
  padding: 2px 7px;
  letter-spacing: .3px;
}

.dz-fmt { border-radius: 4px; padding: 2px 6px; }
.tbadge { background: var(--paper); color: var(--ink); }
.um-b   { color: var(--ink); }

/* File loaded card */
.file-loaded {
  display: none;
  background: var(--green-bg);
  border: 1px solid #b6d9c4;
  border-radius: 10px;
  padding: 10px 12px;
}

.file-loaded-top { display: flex; align-items: flex-start; gap: 8px; }

.file-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-icon svg { width: 14px; height: 14px; color: white; }

.file-name {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 10.5px;
  color: var(--green);
  line-height: 1.3;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.file-meta { font-size: 10px; color: var(--ink); opacity: .65; }

.file-action {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #c8e0d2;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.file-status {
  font-size: 10px;
  color: var(--green);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.file-status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

.file-clear {
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color .15s;
}

.file-clear:hover { color: var(--accent); }

/* ── Sidebar: stats ────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
}

.stat {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 8px 10px;
  transition: box-shadow .15s;
}

.stat:hover { box-shadow: var(--shadow-sm); }

.stat-label { font-size: 9px; text-transform: uppercase; letter-spacing: .9px; color: var(--muted); margin-bottom: 3px; font-weight: 700; }
.stat-value { font-family: var(--mono); font-weight: 500; font-size: 18px; line-height: 1; }

.sv-g    { color: var(--green); }
.sv-o    { color: var(--accent); }
.sv-gold { color: var(--gold); }

/* ── Sidebar: suggestions panel ────────────────────────── */

.panel { flex: 1; overflow-y: auto; padding: 12px 14px; }

.panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  gap: 10px;
  padding: 24px;
}

.panel-empty-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--paper);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .6;
}

.panel-empty-icon svg { width: 20px; height: 20px; color: var(--muted); }
.panel-empty p { font-size: 11px; line-height: 1.7; color: var(--muted); }

/* Panel content (JS-generated) */
.ptitle { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.6px; color: var(--muted); margin-bottom: 10px; }
.voce-desc { font-size: 11px; color: var(--ink); line-height: 1.6; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border-light); }

.scard {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 11px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}

.scard:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.scard.sel   { border-color: var(--green); background: var(--green-bg); box-shadow: 0 0 0 3px rgba(30,92,53,.08); }
.scard.nota  { cursor: default; background: var(--paper); }
.scard.nota:hover { border-color: var(--border-light); box-shadow: none; transform: none; }

.src { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; margin-bottom: 4px; }
.src.t { color: var(--green); }
.src.s { color: var(--accent); }
.src.m { color: var(--gold); }

.codice { font-family: var(--mono); font-size: 9px; color: var(--muted); margin-bottom: 4px; }
.prezzo { font-family: var(--mono); font-weight: 500; font-size: 18px; color: var(--ink); margin-bottom: 4px; letter-spacing: -.5px; }
.prezzo.muted-sm { color: var(--muted); font-size: 13px; }
.snote  { font-size: 10.5px; color: var(--ink); line-height: 1.5; margin-bottom: 8px; opacity: .75; }

.cbar { height: 3px; background: var(--border-light); border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.cfill { height: 100%; border-radius: 3px; }
.ch .cfill { background: var(--green); }
.cm .cfill { background: var(--gold); }
.cl .cfill { background: var(--accent); }

.clabel { font-size: 9px; color: var(--muted); display: flex; justify-content: space-between; font-weight: 600; }
.clabel strong { color: var(--ink); }

.btn-acc {
  width: 100%;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 7px;
  padding: 8px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 11px;
  cursor: pointer;
  margin-top: 8px;
  transition: all .15s;
  box-shadow: 0 2px 8px rgba(30,92,53,.2);
}

.btn-acc:hover { opacity: .88; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(30,92,53,.3); }

.manual-wrap  { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.manual-label { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; color: var(--ink); margin-bottom: 5px; }

.manual-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 13px;
  background: white;
  outline: none;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}

.manual-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,74,8,.1); }

/* ── Content: upload state ─────────────────────────────── */

.upload-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
}

.upload-illustration { width: 400px; max-width: 90%; text-align: center; }

.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 32px;
}

.ug-cell { height: 40px; border-radius: 8px; border: 1px solid var(--border-light); background: white; }
.ug-cell:nth-child(1) { opacity: .20; }
.ug-cell:nth-child(2) { opacity: .60; background: #fde8e0; border-color: #f0c0ab; }
.ug-cell:nth-child(3) { opacity: .18; }
.ug-cell:nth-child(4) { opacity: .50; background: #ddeee5; border-color: #b6d9c4; }
.ug-cell:nth-child(5) { opacity: .12; }
.ug-cell:nth-child(6) { opacity: .55; background: #fdf0cc; border-color: #e8d48a; }
.ug-cell:nth-child(7) { opacity: .18; }
.ug-cell:nth-child(8) { opacity: .45; background: #fde8e0; border-color: #f0c0ab; }
.ug-cell:nth-child(9) { opacity: .20; }

.upload-icon {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: white;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  box-shadow: var(--shadow-md);
}

.upload-icon svg { width: 26px; height: 26px; color: var(--muted); }

.upload-state h2 { font-size: 27px; font-weight: 300; letter-spacing: -.5px; color: var(--ink); margin-bottom: 8px; }
.upload-state p  { font-size: 13px; color: var(--muted); line-height: 1.9; margin-bottom: 24px; }
.upload-state p strong { color: var(--ink); }

.upload-formats { display: flex; gap: 6px; justify-content: center; margin-top: 14px; }
/* .upload-formats reuses .dz-fmt chips */

.upload-cta {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 11px 26px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all .2s;
  box-shadow: 0 2px 14px rgba(196,74,8,.3);
}

.upload-cta:hover { opacity: .9; box-shadow: 0 6px 20px rgba(196,74,8,.35); transform: translateY(-2px); }

/* ── Content: active state ─────────────────────────────── */

.active-state {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
  animation: fadeUp .25s ease;
}

.content-head {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-light);
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ctitle { font-weight: 600; font-size: 13px; letter-spacing: -.2px; }
.csub   { font-size: 11px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px; }

.btn-grp { display: flex; gap: 6px; }

.btn {
  padding: 6px 14px;
  border-radius: 7px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 11px;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .15s;
}

.btn.bs { background: white; color: var(--ink); border: 1px solid var(--border); }
.btn.bs:hover { border-color: var(--muted); box-shadow: var(--shadow-sm); }
.btn.bp { background: var(--accent); color: white; box-shadow: 0 2px 8px rgba(196,74,8,.2); }
.btn.bp:hover { opacity: .88; box-shadow: 0 4px 14px rgba(196,74,8,.3); transform: translateY(-1px); }

.filters {
  padding: 8px 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--card);
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.fb {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  transition: all .15s;
}

.fb.act { background: var(--ink); color: var(--paper); border-color: var(--ink); box-shadow: var(--shadow-sm); }
.fb:not(.act):hover { background: white; border-color: var(--border-light); }

/* ── Table ─────────────────────────────────────────────── */

.tbl-wrap { flex: 1; overflow: auto; }

table { width: 100%; border-collapse: collapse; }

thead tr { background: var(--ink); position: sticky; top: 0; z-index: 10; }

thead th {
  padding: 10px 12px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: white;
  white-space: nowrap;
}

thead th.tar { text-align: right; }
thead th.tac { text-align: center; }
thead th:nth-child(2) { text-align: center; }
tbody td:nth-child(2) { text-align: center; }

tbody tr {
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background .1s;
}

tbody tr:hover { background: var(--hover-bg); }
tbody tr.sel   { background: var(--green-bg); }

tbody tr.sec {
  background: #eeeae0;
  cursor: default;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--muted-light);
}

tbody tr.sec:hover { background: #eeeae0; }

td { padding: 9px 12px; font-size: 12px; vertical-align: middle; }

.nord      { font-family: var(--mono); font-size: 10px; color: var(--ink); opacity: .75; }
.desc-short { font-weight: 500; color: var(--ink); font-size: 12px; line-height: 1.4; }
.qty       { font-family: var(--mono); font-size: 11px; text-align: right; white-space: nowrap; color: var(--ink); }
.pcell     { font-family: var(--mono); font-size: 11px; text-align: right; white-space: nowrap; }
.pfill     { color: var(--ink); }
.pmiss     { color: var(--ink); opacity: .55; font-style: italic; font-family: var(--sans); font-size: 10px; }
.tcell     { font-family: var(--mono); font-size: 11px; text-align: right; font-weight: 500; color: var(--ink); }
.tac       { text-align: center; }
.muted     { color: var(--muted-light); }

.sec-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }

/* Status tags */
.tag {
  display: inline-block;
  font-size: 9px;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.th   { background: var(--green-bg);  color: var(--green); }
.tm   { background: var(--gold-bg);   color: var(--gold); }
.tl   { background: var(--accent-bg); color: var(--accent); }
.tman { background: var(--paper); color: var(--muted); border: 1px solid var(--border-light); }

/* ── Footer ────────────────────────────────────────────── */

.footer {
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.footer-right { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }

.tot-label { font-size: 10px; text-transform: uppercase; letter-spacing: .9px; color: var(--muted); font-weight: 700; }
.tot-label small { opacity: .75; font-size: 9px; margin-left: 4px; }
.tot-val { font-family: var(--mono); font-weight: 500; font-size: 22px; letter-spacing: -.5px; }

.progress-wrap  { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.progress-label { font-size: 9px; color: var(--muted); letter-spacing: .3px; }
.progress-bar   { height: 3px; background: var(--border-light); border-radius: 3px; width: 160px; overflow: hidden; }
.progress-fill  { height: 100%; background: var(--green); border-radius: 3px; transition: width .4s ease; }

/* ── Toast ─────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(60px);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
  z-index: 999;
  box-shadow: var(--shadow-md);
}

.toast.show { transform: translateY(0); opacity: 1; }

/* ── Scrollbar ─────────────────────────────────────────── */

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-light); }

/* ── Animations ────────────────────────────────────────── */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
