:root {
  --bg: #f4f6fb;
  --surface: #fff;
  --surface-2: #f7f9fc;
  --text: #19243a;
  --muted: #748198;
  --border: #e6ebf3;
  --accent: #315efb;
  --accent-2: #527bff;
  --accent-soft: rgba(49, 94, 251, .1);
  --sidebar-1: #101b32;
  --sidebar-2: #101b32;
  --sh-1: 0 3px 14px rgba(28, 43, 74, .04);
  --sh-2: 0 12px 30px rgba(28, 43, 74, .08);
  --radius: 14px;
}

:root[data-theme="dark"] {
  --bg: #0e1626;
  --surface: #172338;
  --surface-2: #1c2a42;
  --text: #e8eef9;
  --muted: #a0aec4;
  --border: #293a52;
  --accent: #80a0ff;
  --accent-2: #6f8efc;
  --accent-soft: rgba(128, 160, 255, .16);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1626;
    --surface: #172338;
    --surface-2: #1c2a42;
    --text: #e8eef9;
    --muted: #a0aec4;
    --border: #293a52;
    --accent: #80a0ff;
    --accent-2: #6f8efc;
    --accent-soft: rgba(128, 160, 255, .16);
  }
}

body { background: var(--bg); color: var(--text); font-family: "Segoe UI", system-ui, sans-serif; }
a { color: var(--accent); }
.shell { background: var(--bg); }
.sidebar { width: 256px; background: #101b32; color: #b6c1d5; }
.brand { display: flex; align-items: center; gap: 12px; padding: 27px 22px 24px; font-size: 17px; line-height: 1.2; }
.brand img { width: 44px; height: 44px; object-fit: contain; }
.brand span { margin-top: 5px; font-size: 9px; color: #8290a9; letter-spacing: .14em; }
.sidebar nav { padding: 24px 12px; gap: 5px; }
.nav-caption { padding: 0 14px 12px; color: #77869f; font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.sidebar nav a, .sidebar nav .nav-toggle { color: #b6c1d5; border-radius: 9px; font-size: 14px; }
.sidebar nav a.active, .sidebar nav .nav-toggle.active { background: #315efb; box-shadow: 0 6px 16px rgba(49, 94, 251, .22); }
.sidebar nav a.active::before { display: none; }
.sidebar-footer { padding: 18px; }
.user-chip { padding: 2px 2px 5px; }
.user-chip strong { font-size: 14px; }
.content { max-width: 1800px; padding: 36px clamp(22px, 3.2vw, 48px) calc(48px + var(--sab)); }
.content h2 { font-size: clamp(24px, 2.4vw, 30px); letter-spacing: -.035em; }
.dashboard-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 28px; }
.dashboard-heading h2 { margin: 4px 0 5px; font-weight: 750; }
.dashboard-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.section-kicker { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.dashboard-context { padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--muted); font-size: 12px; white-space: nowrap; }
.flower-panel { padding: 0; overflow: hidden; }
.flower-frame { display: block; width: 100%; height: min(78vh, 980px); min-height: 620px; border: 0; background: #fff; }
.cards { gap: 16px; }
.stat-card { min-height: 136px; padding: 20px 22px; box-shadow: var(--sh-1); }
.stat-card::before { inset: auto 20px 0; width: auto; height: 3px; border-radius: 4px 4px 0 0; }
.stat-card .etichetta { margin: 0 0 14px; color: var(--muted); font-size: 12px; font-weight: 650; }
.stat-card .valore { font-size: 30px; letter-spacing: -.04em; }
.stat-note { margin-top: 6px; color: var(--muted); font-size: 12px; }
.panel { padding: 22px; box-shadow: var(--sh-1); }
.panel h3 { font-size: 15px; font-weight: 700; }
.panel .card-table { margin-bottom: 0; }
.pv-card { background: var(--surface-2); }
select.search {
  padding-left: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238a98ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-position: right 13px center;
}
.card-table { box-shadow: none; }
th { padding: 13px 15px; font-size: 10px; letter-spacing: .08em; }
td { padding: 12px 15px; font-size: 13px; }
.badge { font-weight: 650; line-height: 1.4; }
.btn { border-radius: 9px; }
.btn.primary { background: #315efb; box-shadow: 0 5px 12px rgba(49, 94, 251, .18); }
.btn.primary:hover { background: #244fe5; }
.modal { position: relative; inset: auto; height: auto; margin: 0; }
.toast { opacity: 1; width: auto; max-width: min(420px, 92vw); }

.login-wrap { background: #edf2fb; background-image: none; animation: none; }
.login-wrap::before, .login-wrap::after { display: none; }
.login-surface { min-height: 580px; overflow: hidden; border-radius: 20px; background: var(--surface); box-shadow: 0 28px 80px rgba(24, 43, 78, .16); }
.login-intro { display: flex; flex-direction: column; justify-content: space-between; padding: 42px; color: #fff; background: radial-gradient(circle at 85% 20%, #3155a0 0, transparent 40%), linear-gradient(145deg, #101b32, #1a3261); }
.login-brand { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 750; }
.login-brand img { width: 46px; height: 46px; }
.login-brand small { display: block; margin-top: 3px; color: #a5b6d2; font-size: 9px; letter-spacing: .15em; }
.login-intro-copy h1 { margin: 16px 0; color: white; font-size: clamp(30px, 3vw, 42px); line-height: 1.13; letter-spacing: -.04em; }
.login-intro-copy p { max-width: 340px; color: #c1cde0; font-size: 15px; line-height: 1.7; }
.login-eyebrow { color: #83a4ff; font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.login-intro-footer { color: #9eafca; font-size: 12px; }
.login-intro-footer span { margin: 0 5px; }
.login-card { width: 100%; justify-content: center; padding: 56px; gap: 18px; border: 0; border-radius: 0; box-shadow: none; animation: none; }
.login-form-heading { margin-bottom: 14px; }
.login-form-heading h2 { margin: 9px 0; font-size: 27px; letter-spacing: -.035em; }
.login-form-heading .muted { margin: 0; text-align: left; font-size: 14px; }
.login-card label { color: var(--text); }
.login-card input { width: 100%; }
.login-card .btn { margin-top: 4px; min-height: 46px; }
.table-loading { display: flex; align-items: center; gap: 9px; margin: -4px 0 14px; color: var(--muted); font-size: 13px; }
.table-loading .spinner { width: 16px; height: 16px; }
.table-loading[hidden] { display: none; }
textarea.testo-bilancia {
  width: 100%; min-height: 0; padding: 10px 12px;
  line-height: 1.5; overflow-y: auto; resize: none;
}
textarea.testo-bilancia[rows="2"] { height: calc(3em + 22px); }
textarea.testo-bilancia[rows="4"] { height: calc(6em + 22px); }

@media (max-width: 1100px) {
  .sidebar { width: 224px; }
}
@media (max-width: 900px) {
  .sidebar { width: min(300px, 86vw); }
  .content { padding-top: calc(76px + var(--sat)); }
}
@media (max-width: 991px) {
  .login-surface { min-height: 0; max-width: 510px; margin: auto; }
  .login-intro { gap: 26px; padding: 28px; }
  .login-intro-copy h1 { font-size: 28px; }
  .login-intro-copy p, .login-intro-footer { display: none; }
  .login-card { padding: 32px 28px; }
}
@media (max-width: 640px) {
  .dashboard-heading { align-items: flex-start; }
  .dashboard-context { display: none; }
  .flower-frame { height: 76vh; min-height: 520px; }
  .page-head .search, .page-head select.search { flex: 0 0 auto; }
  .stat-card { min-height: 118px; padding: 16px; }
  .stat-card .etichetta { margin-bottom: 10px; }
  .content td { padding: 9px 0; }
}
.indicatori-negozi {
  margin-block: 1rem 1.5rem;
}
.indicatori-griglia {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 1rem;
}
.grafico-giornaliero { min-width: 0; }
.modal-body > .grafico-giornaliero { margin-bottom: 1rem; }
.grafico-giorni, .grafico-legenda {
  list-style: none;
  margin: 0;
  padding: 0;
  font-variant-numeric: tabular-nums;
}
.grafico-giorni li {
  display: grid;
  grid-template-columns: 2.9rem minmax(1.5rem, 1fr) auto;
  align-items: center;
  gap: .5rem;
  min-height: 1.55rem;
  font-size: .82rem;
}
.grafico-traccia {
  display: flex;
  overflow: hidden;
  height: .5rem;
  border-radius: .5rem;
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.grafico-traccia span, .grafico-legenda li::before { background: var(--colore-grafico); }
.grafico-importo { --colore-grafico: #2583e6; }
.grafico-ok { --colore-grafico: #22a86a; }
.grafico-attesa { --colore-grafico: #cf850f; }
.grafico-negativo { --colore-grafico: #e25450; }
.grafico-conflitto { --colore-grafico: #9667e8; }
.grafico-legenda:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .8rem;
  margin-bottom: .5rem;
  font-size: .8rem;
}
.grafico-legenda li::before {
  content: "";
  display: inline-block;
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
  margin-right: .3rem;
}
.pv-importo { font-weight: 650; }
@media (max-width: 640px) {
  .grafico-giorni { max-height: 12rem; overflow-y: auto; }
}
