/* ==========================================================================
   Contabilità HiTech — stile del pannello
   Filament compila solo le utility che usa: queste classi sono nostre e
   vengono servite da /css/contabilita.css, quindi non dipendono da Tailwind.
   ========================================================================== */

.cb-wrap { display: flex; flex-direction: column; gap: 1.5rem; }

/* --- barra comandi --- */
.cb-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.cb-toolbar label { font-size: .875rem; font-weight: 500; color: #4b5563; }
.cb-select {
  border-radius: .5rem; border: 1px solid #d1d5db; background: #fff;
  padding: .4rem .7rem; font-size: .875rem; font-weight: 500; color: #111827;
}
.dark .cb-select { background: #1f2937; border-color: #374151; color: #f9fafb; }
.dark .cb-toolbar label { color: #9ca3af; }

/* --- griglia KPI --- */
.cb-kpis { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px)  { .cb-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1280px) { .cb-kpis { grid-template-columns: repeat(4, 1fr); } }

.cb-kpi {
  position: relative; overflow: hidden; border-radius: 1rem;
  padding: 1.25rem; color: #fff;
  box-shadow: 0 10px 20px -8px rgba(0,0,0,.28);
}
.cb-kpi--green  { background: linear-gradient(135deg, #10b981, #059669); }
.cb-kpi--red    { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.cb-kpi--teal   { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.cb-kpi--amber  { background: linear-gradient(135deg, #f59e0b, #d97706); }
.cb-kpi--sky    { background: linear-gradient(135deg, #0ea5e9, #0284c7); }
.cb-kpi--indigo { background: linear-gradient(135deg, #6366f1, #4f46e5); }

.cb-kpi__icon {
  position: absolute; right: -1.1rem; top: -1.1rem;
  width: 6.5rem; height: 6.5rem; opacity: .18; pointer-events: none;
}
.cb-kpi__icon svg { width: 100%; height: 100%; stroke-width: 1.2; }
.cb-kpi__label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; opacity: .92;
}
.cb-kpi__value { margin-top: .45rem; font-size: 1.7rem; font-weight: 800; line-height: 1.15; }
.cb-kpi__sub   { margin-top: .3rem; font-size: .72rem; opacity: .85; }

/* --- card generica --- */
.cb-card {
  background: #fff; border-radius: 1rem; padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  border: 1px solid rgba(17,24,39,.06);
}
.dark .cb-card { background: #111827; border-color: rgba(255,255,255,.08); }

.cb-card__head {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: .6rem; margin-bottom: 1.1rem;
}
.cb-card__title { font-size: 1rem; font-weight: 600; color: #111827; margin: 0; }
.dark .cb-card__title { color: #f9fafb; }
.cb-card__hint { font-size: .75rem; color: #6b7280; }

.cb-legend { display: flex; align-items: center; gap: 1rem; font-size: .75rem; color: #4b5563; }
.dark .cb-legend { color: #9ca3af; }
.cb-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 2px; margin-right: .35rem; }
.cb-dot--green { background: #10b981; }
.cb-dot--red   { background: #f43f5e; }

/* --- grafico a barre (CSS puro) --- */
.cb-chart { display: flex; align-items: flex-end; gap: .35rem; height: 15rem; }
@media (min-width: 640px) { .cb-chart { gap: .75rem; } }
.cb-chart__col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.cb-chart__bars { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 100%; height: 12.5rem; }
.cb-chart__bar { width: 100%; max-width: 16px; border-radius: 3px 3px 0 0; transition: opacity .15s; }
.cb-chart__bar:hover { opacity: .78; }
.cb-chart__bar--in  { background: linear-gradient(to top, #059669, #34d399); }
.cb-chart__bar--out { background: linear-gradient(to top, #e11d48, #fb7185); }
.cb-chart__label { font-size: .65rem; font-weight: 600; color: #6b7280; }
.dark .cb-chart__label { color: #9ca3af; }

/* --- barre orizzontali (categorie / fornitori) --- */
.cb-bars { display: flex; flex-direction: column; gap: .8rem; }
.cb-bars__row { display: flex; flex-direction: column; gap: .25rem; }
.cb-bars__top { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.cb-bars__name {
  font-size: .8rem; font-weight: 500; color: #1f2937;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dark .cb-bars__name { color: #e5e7eb; }
.cb-bars__val { flex-shrink: 0; font-size: .8rem; font-weight: 700; color: #111827; font-variant-numeric: tabular-nums; }
.dark .cb-bars__val { color: #f9fafb; }
.cb-bars__track { height: .5rem; border-radius: 999px; background: #f1f5f9; overflow: hidden; }
.dark .cb-bars__track { background: #1f2937; }
.cb-bars__fill { height: 100%; border-radius: 999px; }
.cb-bars__note { font-size: .65rem; color: #9ca3af; }

.cb-fill--blue   { background: linear-gradient(90deg,#3b82f6,#60a5fa); }
.cb-fill--green  { background: linear-gradient(90deg,#10b981,#34d399); }
.cb-fill--amber  { background: linear-gradient(90deg,#f59e0b,#fbbf24); }
.cb-fill--rose   { background: linear-gradient(90deg,#f43f5e,#fb7185); }
.cb-fill--violet { background: linear-gradient(90deg,#8b5cf6,#a78bfa); }
.cb-fill--pink   { background: linear-gradient(90deg,#ec4899,#f472b6); }
.cb-fill--teal   { background: linear-gradient(90deg,#14b8a6,#2dd4bf); }
.cb-fill--orange { background: linear-gradient(90deg,#f97316,#fb923c); }
.cb-fill--indigo { background: linear-gradient(90deg,#6366f1,#818cf8); }

/* --- due colonne --- */
.cb-cols { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 1280px) {
  .cb-cols--3 { grid-template-columns: 1fr 2fr; }
  .cb-cols--2 { grid-template-columns: repeat(2, 1fr); }
}

/* --- tabella --- */
.cb-table { width: 100%; font-size: .85rem; border-collapse: collapse; }
.cb-table thead th {
  background: rgba(249,250,251,.9); padding: .7rem 1rem; text-align: left;
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #6b7280; white-space: nowrap;
}
.dark .cb-table thead th { background: rgba(31,41,55,.6); color: #9ca3af; }
.cb-table thead th.num, .cb-table td.num { text-align: right; }
.cb-table tbody td { padding: .6rem 1rem; border-top: 1px solid #f1f5f9; color: #374151; }
.dark .cb-table tbody td { border-color: #1f2937; color: #d1d5db; }
.cb-table tbody tr:hover { background: rgba(249,250,251,.7); }
.dark .cb-table tbody tr:hover { background: rgba(31,41,55,.4); }
.cb-table tbody tr.is-empty { opacity: .38; }
.cb-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cb-table td.mese { font-weight: 600; color: #111827; }
.dark .cb-table td.mese { color: #f9fafb; }
.cb-table tfoot td {
  padding: .8rem 1rem; border-top: 2px solid #e5e7eb; font-weight: 700;
  background: rgba(249,250,251,.9); color: #111827;
}
.dark .cb-table tfoot td { border-color: #374151; background: rgba(31,41,55,.6); color: #f9fafb; }
.cb-pos { color: #059669; }
.cb-neg { color: #e11d48; }
.dark .cb-pos { color: #34d399; }
.dark .cb-neg { color: #fb7185; }
.cb-muted { color: #9ca3af; }
.cb-table-scroll { overflow-x: auto; }

/* --- liste (crediti / debiti / spese) --- */
.cb-list { max-height: 20rem; overflow-y: auto; }
.cb-list__row {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .7rem 1.5rem; border-top: 1px solid #f1f5f9;
}
.dark .cb-list__row { border-color: #1f2937; }
.cb-list__row:first-child { border-top: 0; }
.cb-list__main { min-width: 0; }
.cb-list__name {
  font-size: .85rem; font-weight: 500; color: #111827;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dark .cb-list__name { color: #f3f4f6; }
.cb-list__meta { font-size: .72rem; color: #6b7280; }
.cb-list__val { flex-shrink: 0; font-size: .85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cb-list__empty { padding: 2.5rem 1rem; text-align: center; font-size: .85rem; color: #9ca3af; }

.cb-card__headicon { display: flex; align-items: center; gap: .5rem; }
.cb-card__headicon svg { width: 1.15rem; height: 1.15rem; }

/* --- errore --- */
.cb-error {
  border-radius: .75rem; background: #fef2f2; padding: 1rem;
  font-size: .85rem; color: #b91c1c; border: 1px solid #fecaca;
}
.dark .cb-error { background: rgba(244,63,94,.12); color: #fda4af; border-color: rgba(244,63,94,.3); }

/* --- tasse --- */
.cb-total {
  border-radius: 1rem; padding: 1.5rem;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 1px solid #a7f3d0;
}
.dark .cb-total { background: linear-gradient(135deg, rgba(16,185,129,.14), rgba(16,185,129,.06)); border-color: rgba(16,185,129,.3); }
.cb-total__grid { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.cb-total__label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: #047857; }
.cb-total__value { margin-top: .25rem; font-size: 2rem; font-weight: 800; color: #047857; }
.cb-total__note { margin-top: 1rem; font-size: .72rem; color: #059669; }
.dark .cb-total__label, .dark .cb-total__value, .dark .cb-total__note { color: #6ee7b7; }

.cb-note { font-size: .75rem; color: #6b7280; }
.dark .cb-note { color: #9ca3af; }

/* ==========================================================================
   Pagina "Registra fatture"
   ========================================================================== */

.cb-banner {
  display: flex; align-items: flex-start; gap: .75rem;
  border-radius: .75rem; padding: 1rem 1.25rem;
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af;
  font-size: .85rem; line-height: 1.45;
}
.dark .cb-banner { background: rgba(59,130,246,.12); border-color: rgba(59,130,246,.3); color: #93c5fd; }
.cb-banner svg { width: 1.15rem; height: 1.15rem; flex-shrink: 0; margin-top: .1rem; }
.cb-banner strong { font-weight: 600; }

.cb-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; }

/* riquadri riassuntivi */
.cb-stats { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-top: 1.25rem; }
@media (min-width: 640px) { .cb-stats { grid-template-columns: repeat(3, 1fr); } }
.cb-stat {
  border-radius: .75rem; padding: 1rem 1.25rem;
  background: #f8fafc; border: 1px solid #e2e8f0;
}
.dark .cb-stat { background: #1f2937; border-color: #374151; }
.cb-stat__label {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #6b7280;
}
.dark .cb-stat__label { color: #9ca3af; }
.cb-stat__value {
  margin-top: .3rem; font-size: 1.5rem; font-weight: 700; color: #111827;
  font-variant-numeric: tabular-nums;
}
.dark .cb-stat__value { color: #f9fafb; }
.cb-stat--ok .cb-stat__value { color: #059669; }
.dark .cb-stat--ok .cb-stat__value { color: #34d399; }

/* badge di stato */
.cb-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  border-radius: 999px; padding: .15rem .55rem;
  font-size: .68rem; font-weight: 600; white-space: nowrap;
}
.cb-badge--ok   { background: #d1fae5; color: #047857; }
.cb-badge--wait { background: #fef3c7; color: #b45309; }
.dark .cb-badge--ok   { background: rgba(16,185,129,.2); color: #34d399; }
.dark .cb-badge--wait { background: rgba(245,158,11,.2); color: #fbbf24; }

/* pastiglia per l'esito dell'abbinamento fornitore */
.cb-pill {
  display: inline-block; border-radius: .35rem; padding: .05rem .4rem;
  font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  background: #e0e7ff; color: #4338ca;
}
.dark .cb-pill { background: rgba(99,102,241,.22); color: #a5b4fc; }

/* riga vuota / esito positivo */
.cb-empty {
  border-radius: 1rem; padding: 2.5rem 1.5rem; text-align: center;
  font-size: .9rem; font-weight: 500;
}
.cb-empty--ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.dark .cb-empty--ok { background: rgba(16,185,129,.12); color: #6ee7b7; border-color: rgba(16,185,129,.3); }
.cb-empty__icon { width: 2.5rem; height: 2.5rem; margin: 0 auto .6rem; }
.cb-empty__icon svg { width: 100%; height: 100%; }

.cb-table td.mono { font-variant-numeric: tabular-nums; color: #6b7280; white-space: nowrap; }
.cb-table td.nome { font-weight: 500; color: #111827; }
.dark .cb-table td.nome { color: #f9fafb; }
@media (min-width: 900px) { .cb-stats { grid-template-columns: repeat(4, 1fr); } }
