/* =====================================================================
   Ledger Console — design system del pannello whitelabel (frontend separato)
   Direzione: console operativa "ledger". Ink navy per la struttura, verde
   smeraldo per stato attivo/denaro, oro per i ricavi (usato con parsimonia),
   argilla/ambra per sospeso/scaduto. Money in mono tabellare. La firma:
   la "rail" colorata a sinistra di ogni riga licenza codifica lo stato reale.
   ===================================================================== */

:root {
  --ink:        #14202B;
  --ink-2:      #1B2C3A;
  --ink-3:      #263A4C;
  --paper:      #EEF1F4;
  --surface:    #FFFFFF;
  --emerald:    #0C7A5B;
  --emerald-d:  #0A6650;
  --emerald-soft:#E3F1EB;
  --gold:       #A9781F;
  --gold-soft:  #F5ECD8;
  --clay:       #B23B2E;
  --clay-soft:  #F6E3E0;
  --amber:      #B67A15;
  --amber-soft: #F6EBD3;
  --slate:      #5E7183;
  --slate-2:    #7E8FA0;
  --hair:       #DCE2E8;
  --hair-ink:   #2C3E4F;

  --r-sm: 7px;
  --r:    11px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20,32,43,.06), 0 1px 3px rgba(20,32,43,.05);
  --shadow:    0 2px 6px rgba(20,32,43,.07), 0 8px 24px rgba(20,32,43,.06);
  --sidebar-w: 244px;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'Space Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--emerald); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- App layout ---------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--ink);
  color: #C9D6E0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  padding: 22px 22px 18px;
  display: flex; align-items: baseline; gap: 8px;
  border-bottom: 1px solid var(--hair-ink);
}
.brand .mark {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.15rem; letter-spacing: -.02em; color: #fff;
}
.brand .mark em { color: var(--emerald); font-style: normal; }
.brand .kicker {
  font-size: .62rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--slate-2); font-weight: 600;
}

.scope-box { padding: 14px 16px; border-bottom: 1px solid var(--hair-ink); }
.scope-box .lbl {
  font-size: .6rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--slate-2); font-weight: 600; margin-bottom: 6px;
}
.scope-select {
  width: 100%; background: var(--ink-2); color: #E4ECF2;
  border: 1px solid var(--hair-ink); border-radius: var(--r-sm);
  padding: 7px 9px; font-family: var(--font-body); font-size: .82rem;
}
.scope-select:focus { outline: 2px solid var(--emerald); outline-offset: 1px; }

.nav { padding: 12px 12px; flex: 1 1 auto; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: #B4C4D0; font-weight: 500; font-size: .9rem;
  text-decoration: none; margin-bottom: 2px;
}
.nav a .ico { width: 18px; text-align: center; opacity: .85; font-size: 1rem; }
.nav a:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.nav a.active {
  background: var(--ink-2); color: #fff;
  box-shadow: inset 3px 0 0 var(--emerald);
}
.nav a.ext::after { content: '↗'; margin-left: auto; opacity: .4; font-size: .8rem; }

.side-foot {
  border-top: 1px solid var(--hair-ink); padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
}
.side-foot .who { min-width: 0; flex: 1; }
.side-foot .who .nm { color: #E4ECF2; font-weight: 600; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who .rl { color: var(--slate-2); font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; }
.lang-switch { display: flex; gap: 6px; padding: 0 16px 14px; }
.lang-switch a { font-size: .74rem; color: var(--slate-2); font-weight: 600; }
.lang-switch a.on { color: var(--emerald); }

/* ---- Main ---------------------------------------------------------- */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--ink); color: #fff;
  position: sticky; top: 0; z-index: 30;
}
.topbar .mark { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.topbar .mark em { color: var(--emerald); font-style: normal; }
.hamburger {
  background: var(--ink-2); border: 1px solid var(--hair-ink); color: #fff;
  width: 38px; height: 38px; border-radius: var(--r-sm); font-size: 1.1rem; cursor: pointer;
}
.content { padding: 26px 30px 60px; width: 100%; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em;
  font-size: 1.55rem; margin: 0; line-height: 1.1;
}
.page-head .sub { color: var(--slate); font-weight: 500; }
.page-head .sub b { color: var(--ink); font-weight: 600; }

/* ---- Stat rail ----------------------------------------------------- */
.stat-rail {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px;
}
.stat {
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.stat .num {
  font-family: var(--font-display); font-weight: 700; font-size: 1.9rem;
  line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.stat .lbl {
  margin-top: 7px; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--slate); font-weight: 600;
}
.stat.is-revenue .num { font-family: var(--font-mono); font-size: 1.5rem; color: var(--gold); }
.stat.is-active .num { color: var(--emerald); }

/* ---- Ledger (table on desktop, cards on mobile) -------------------- */
.panel { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }

.ledger { width: 100%; overflow-x: auto; }
.ledger table { width: 100%; border-collapse: collapse; table-layout: auto; }
.ledger thead th {
  text-align: left; font-size: .66rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--slate); font-weight: 600; padding: 12px 10px;
  border-bottom: 1px solid var(--hair); background: #F7F9FB; white-space: nowrap;
}
.ledger thead th.r, .ledger td.r { text-align: right; }
.ledger thead th.c, .ledger td.c { text-align: center; }
.ledger tbody td { padding: 11px 10px; border-bottom: 1px solid var(--hair); vertical-align: middle; }
.ledger tbody tr:last-child td { border-bottom: 0; }
.ledger tbody tr { position: relative; }
.ledger tbody tr:hover { background: #FAFBFC; }
/* signature: state rail on the first cell */
.ledger td.rail { position: relative; padding-left: 20px; }
.ledger td.rail::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 3px;
  background: var(--slate-2);
}
tr.s-active   td.rail::before { background: var(--emerald); }
tr.s-pending  td.rail::before { background: var(--amber); }
tr.s-expired  td.rail::before,
tr.s-overdue  td.rail::before { background: var(--clay); }
tr.s-inactive td.rail::before { background: var(--slate-2); }
tr.s-queued   td.rail::before { background: #3B6EA5; }

/* Coda licenze: pallino conteggio sul pulsante ⧉ e riga accodata */
.act-queue { position: relative; }
.q-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 15px; height: 15px; padding: 0 3px; margin-left: 3px;
  font-size: 9px; font-weight: 700; line-height: 1; border-radius: 8px;
  background: #3B6EA5; color: #fff; vertical-align: top;
}

.cust { font-weight: 600; }
.muted { color: var(--slate); }
.small { font-size: .82rem; }
.money { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.money .cur { color: var(--slate); }
.money.rev { color: var(--gold); border-bottom: 1px solid var(--gold-soft); }
.license-key { font-family: var(--font-mono); font-size: .78rem; color: var(--slate); white-space: nowrap; }

/* ---- Pills / badges ------------------------------------------------ */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 600;
  letter-spacing: .02em; white-space: nowrap;
}
.pill.ok   { background: var(--emerald-soft); color: var(--emerald-d); }
.pill.warn { background: var(--amber-soft);  color: var(--amber); }
.pill.bad  { background: var(--clay-soft);   color: var(--clay); }
.pill.mut  { background: #EDF1F4; color: var(--slate); }
.pill.gold { background: var(--gold-soft); color: var(--gold); }

.pay-chip {
  border: 1px solid var(--hair); background: #fff; border-radius: 999px;
  padding: 2px 8px; font-family: var(--font-mono); font-size: .72rem; color: var(--slate);
  cursor: pointer; margin-left: 6px;
}
.pay-chip:hover { border-color: var(--emerald); color: var(--emerald-d); }

/* ---- Buttons ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  font-family: var(--font-body); font-weight: 600; font-size: .86rem;
  border-radius: var(--r-sm); padding: 9px 16px; border: 1px solid transparent;
  cursor: pointer; transition: filter .12s, background .12s; line-height: 1;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--emerald); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--emerald-d); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--hair); }
.btn-ghost:hover { background: #F5F7F9; text-decoration: none; }
.btn-sm { padding: 6px 10px; font-size: .8rem; }
.icon-btn {
  width: 32px; height: 32px; padding: 0; border-radius: var(--r-sm);
  border: 1px solid var(--hair); background: #fff; color: var(--slate);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem;
}
.icon-btn:hover { color: var(--ink); border-color: var(--slate-2); }
.icon-btn.go:hover { color: var(--emerald-d); border-color: var(--emerald); }
.icon-btn.stop:hover { color: var(--amber); border-color: var(--amber); }
.icon-btn.danger:hover { color: var(--clay); border-color: var(--clay); }
.actions-cell { white-space: nowrap; }
.actions-cell .icon-btn + .icon-btn { margin-left: 5px; }

/* ---- Empty / states ------------------------------------------------ */
.empty { text-align: center; color: var(--slate); padding: 46px 20px; }
.empty .big { font-family: var(--font-display); font-size: 1.05rem; color: var(--ink); margin-bottom: 4px; }
.chooser { display: grid; gap: 10px; }
.chooser a {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r);
  padding: 15px 18px; color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm);
}
.chooser a:hover { border-color: var(--emerald); text-decoration: none; box-shadow: var(--shadow); }
.chooser a::after { content: '→'; color: var(--emerald); }

/* ---- Modal --------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(20,32,43,.5); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px;
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity .16s;
  overflow-y: auto;
}
.overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
  width: 100%; max-width: 720px; transform: translateY(-8px); transition: transform .16s;
}
.modal.sm { max-width: 480px; }
.overlay.open .modal { transform: translateY(0); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--hair);
}
.modal-head h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; margin: 0; }
.modal-x { background: none; border: 0; font-size: 1.4rem; color: var(--slate); cursor: pointer; line-height: 1; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--hair); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Forms --------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.f { display: flex; flex-direction: column; gap: 5px; }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; } .col-12 { grid-column: span 12; }
.f label { font-size: .74rem; font-weight: 600; color: var(--slate); letter-spacing: .04em; }
.f label .req { color: var(--clay); }
.f input, .f select {
  font-family: var(--font-body); font-size: .9rem; color: var(--ink);
  border: 1px solid var(--hair); border-radius: var(--r-sm); padding: 9px 11px; background: #fff;
}
.f input:focus, .f select:focus { outline: 2px solid var(--emerald); outline-offset: 0; border-color: var(--emerald); }
.f .hint { font-size: .74rem; color: var(--slate); }
.f input:disabled { background: #F2F5F7; color: var(--slate); }
.f input[type=color] { padding: 3px; height: 42px; width: 100%; cursor: pointer; }
.font-preview { margin-top: 8px; font-size: 1.15rem; color: var(--ink); min-height: 1.4em; }
.prof-sec { padding: 20px; margin-bottom: 16px; }
.prof-sec .panel-title { margin-bottom: 14px; }
.logo-preview { max-width: 100%; height: auto; margin-top: 8px; border: 1px solid var(--hair); border-radius: 6px; background: #fff; padding: 3px; display: block; object-fit: contain; }
.f input[type=file] { font-size: .82rem; color: var(--slate); }
.f input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.f input[type=color]::-webkit-color-swatch { border: 1px solid var(--hair); border-radius: 5px; }
.form-divider { grid-column: span 12; border: 0; border-top: 1px solid var(--hair); margin: 4px 0; }
.form-err { color: var(--clay); font-size: .84rem; margin-top: 12px; min-height: 1em; }

/* ---- Payment schedule inside modal --------------------------------- */
.pay-summary { background: #F7F9FB; border: 1px solid var(--hair); border-radius: var(--r); padding: 13px 15px; margin-bottom: 14px; }
.pay-summary .row { display: flex; justify-content: space-between; gap: 12px; }
.pay-summary .row + .row { margin-top: 5px; }
.validity-note { font-size: .8rem; color: var(--slate); margin-top: 8px; }
.validity-note b { color: var(--ink); font-family: var(--font-mono); }

/* ---- Toast --------------------------------------------------------- */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--r-sm);
  box-shadow: var(--shadow); font-size: .86rem; max-width: 340px;
  animation: toast-in .2s ease; border-left: 3px solid var(--emerald);
}
.toast.err { border-left-color: var(--clay); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- Loader -------------------------------------------------------- */
.loader { display: flex; align-items: center; justify-content: center; padding: 60px; color: var(--slate); gap: 10px; }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--hair); border-top-color: var(--emerald);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Scrim for mobile drawer -------------------------------------- */
.scrim { display: none; }

/* ---- Responsive ---------------------------------------------------- */
@media (max-width: 900px) {
  .stat-rail { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 20px 16px 60px; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; height: 100vh;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow);
  }
  .app.drawer-open .sidebar { transform: translateX(0); }
  .app.drawer-open .scrim {
    display: block; position: fixed; inset: 0; background: rgba(20,32,43,.45); z-index: 55;
  }

  /* table -> ledger cards */
  .ledger { overflow-x: visible; }
  .ledger thead { display: none; }
  .ledger table, .ledger tbody, .ledger tr, .ledger td { display: block; width: 100%; min-width: 0; }
  .ledger tbody tr {
    border: 1px solid var(--hair); border-radius: var(--r); margin: 12px; padding: 6px 6px 6px 14px;
    position: relative; box-shadow: var(--shadow-sm);
  }
  .panel { border: 0; box-shadow: none; background: transparent; border-radius: 0; overflow: visible; }
  .ledger tbody tr::before {
    content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 3px; background: var(--slate-2);
  }
  tr.s-active::before  { background: var(--emerald); }
  tr.s-pending::before { background: var(--amber); }
  tr.s-expired::before, tr.s-overdue::before { background: var(--clay); }
  tr.s-inactive::before{ background: var(--slate-2); }
  .ledger td { border: 0 !important; padding: 5px 10px !important; text-align: left !important; }
  .ledger td.rail { padding-left: 10px; }
  .ledger td.rail::before { display: none; }
  .ledger td[data-l]::before {
    content: attr(data-l); display: inline-block; min-width: 96px;
    font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; color: var(--slate); font-weight: 600;
  }
  .ledger td.actions-cell { padding-top: 10px !important; }
}
@media (max-width: 520px) {
  .stat-rail { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat .num { font-size: 1.5rem; }
  .stat.is-revenue .num { font-size: 1.15rem; }
  .grid > [class^='col-'] { grid-column: span 12; }
  .page-head h1 { font-size: 1.3rem; }
}

/* ---- Extra view components ----------------------------------------- */
.back-link { font-size: .85rem; color: var(--slate); font-weight: 600; }
.panel-title { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; margin: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; }
.avatar-ph { background: var(--paper); color: var(--slate-2); border: 1px solid var(--hair); font-size: 1.2rem; }
.ledger tfoot td { font-weight: 600; border-top: 2px solid var(--hair); background: #F7F9FB; padding: 12px 14px; }
tr.subtotal td { background: #F7F9FB; }
.det-title { font-family: var(--font-display); font-size: 1.15rem; }
.det-h { font-family: var(--font-display); font-weight: 600; font-size: .95rem; margin: 20px 0 8px; }
.modal .ledger { overflow-x: auto; margin-bottom: 6px; }
.modal .ledger table { min-width: 0; }

.ledger-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.search-input {
  flex: 1; max-width: 420px; font-family: var(--font-body); font-size: .9rem; color: var(--ink);
  border: 1px solid var(--hair); border-radius: var(--r-sm); padding: 9px 13px; background: #fff;
}
.search-input:focus { outline: 2px solid var(--emerald); outline-offset: 0; border-color: var(--emerald); }
.search-count { font-family: var(--font-mono); font-size: .78rem; color: var(--slate); }

.team-grid { display: grid; grid-template-columns: 1fr; gap: 28px; }
.team-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }

.pkg-top { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 22px; }
.pkg-add-body, .pkg-stats-body { padding: 18px 20px; }
.pkg-add-body .panel-title { margin-bottom: 14px; }
.kv { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; }
.kv-num { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.assign-group { display: flex; gap: 6px; align-items: center; }
.assign-group select { border: 1px solid var(--hair); border-radius: var(--r-sm); padding: 6px 8px; font-size: .82rem; min-width: 120px; background: #fff; }

.step-card { margin-bottom: 14px; }
.step-body { display: flex; gap: 16px; padding: 18px 20px; }
.stepnum { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; background: var(--emerald); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; }
.step-main { flex: 1; min-width: 0; }
.step-main h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 4px; font-size: 1.05rem; }
.step-main p { margin: 0 0 10px; }
.rec-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.rec-lbl { width: 120px; color: var(--slate); font-size: .8rem; }
.rec { font-family: var(--font-mono); font-size: .82rem; background: var(--paper); border: 1px solid var(--hair); padding: 5px 9px; border-radius: var(--r-sm); word-break: break-all; }
.stepstat { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; margin-top: 4px; }
.stepstat.go { color: var(--emerald); }

@media (max-width: 900px) {
  .team-grid, .pkg-top { grid-template-columns: 1fr; }
}

/* ---- Moduli (listino / pricing ledger) ----------------------------- */
.mod-head-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mod-policy {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font-size: .78rem; font-weight: 600; color: var(--slate);
  background: #fff; border: 1px solid var(--hair); border-radius: 999px; padding: 7px 13px;
}
.mod-policy:hover { border-color: var(--slate-2); }
.mod-policy input { width: auto; accent-color: var(--emerald); }
.mod-policy:has(input:checked) { border-color: var(--emerald); color: var(--emerald-d); background: var(--emerald-soft); }

.mod-scope { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: 22px; }
.mod-scope .lbl {
  font-size: .6rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--slate); font-weight: 600;
}
.mod-scope select {
  font-family: var(--font-body); font-size: .86rem; font-weight: 600; color: var(--ink);
  border: 1px solid var(--hair); border-radius: var(--r-sm); padding: 8px 12px; background: #fff;
}
.mod-scope select:focus { outline: 2px solid var(--emerald); outline-offset: 0; border-color: var(--emerald); }

.mod-rollup { grid-template-columns: repeat(4, 1fr); }
.mod-rollup .stat .num.money { font-family: var(--font-mono); font-size: 1.4rem; }
.mod-rollup .stat .num.pos { color: var(--emerald); }
.mod-rollup .stat .num.under { color: var(--clay); }

/* group eyebrow */
.ledger tr.mod-grp td {
  background: #fff; border-bottom: 1px solid var(--hair);
  font-family: var(--font-display); font-weight: 600; font-size: .68rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--slate);
  padding: 18px 14px 8px;
}
.ledger tbody tr.mod-grp:first-child td { padding-top: 10px; }
.ledger tbody tr.mod-grp:hover { background: #fff; }

/* module identity cell */
.mod-name { font-family: var(--font-display); font-weight: 600; font-size: .98rem; letter-spacing: -.01em; color: var(--ink); }
.mod-key { font-family: var(--font-mono); font-size: .72rem; color: var(--slate-2); margin-top: 2px; }
.mod-dep { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.dep-chip {
  display: inline-flex; align-items: center; font-size: .68rem; font-weight: 600;
  background: var(--paper); color: var(--slate); border: 1px solid var(--hair);
  padding: 2px 8px; border-radius: 999px;
}

/* numeric inputs (money) */
.mod-num {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: .86rem; color: var(--ink);
  border: 1px solid var(--hair); border-radius: var(--r-sm); padding: 7px 9px; background: #fff;
  width: 86px; text-align: right;
}
.mod-num:focus { outline: 2px solid var(--emerald); outline-offset: 0; border-color: var(--emerald); }
.mod-cur { font-family: var(--font-mono); color: var(--slate); font-size: .8rem; margin-left: 5px; }
.mod-base-ro { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); }

/* offered toggle switch */
.mod-switch { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; vertical-align: middle; }
.mod-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.mod-switch .track { position: absolute; inset: 0; background: var(--slate-2); border-radius: 999px; transition: background .15s; }
.mod-switch .thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: var(--shadow-sm); transition: transform .15s; }
.mod-switch input:checked + .track { background: var(--emerald); }
.mod-switch input:checked + .track + .thumb { transform: translateX(18px); }
.mod-switch input:focus-visible + .track { outline: 2px solid var(--emerald); outline-offset: 2px; }

/* margin readout */
.mod-margin { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; line-height: 1.3; }
.mod-margin.pos   { color: var(--gold); }
.mod-margin.free  { color: var(--emerald-d); }
.mod-margin.under { color: var(--clay); }
.mod-margin.zero  { color: var(--slate-2); }
.mod-tag { display: block; margin-top: 2px; font-size: .58rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
.mod-tag.free  { color: var(--emerald-d); }
.mod-tag.under { color: var(--clay); }

@media (max-width: 900px) {
  .mod-rollup { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .mod-rollup { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .mod-head-actions { width: 100%; }
  .mod-head-actions .btn-primary { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Righe di raggruppamento per business nella vista Import: separano i blocchi
   senza sembrare righe di dati. */
.ledger tr.grp td {
  background: var(--surface);
  border-top: 2px solid var(--hair-ink);
  padding-top: 10px;
  padding-bottom: 10px;
}
.ledger tr.grp + tr td { border-top: 0; }
