:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #18201d;
  --muted: #647067;
  --line: #ded8ce;
  --line-strong: #c9c0b5;
  --teal: #0f766e;
  --teal-strong: #0b5f59;
  --aqua: #43a4b2;
  --purple: #155e9f;
  --purple-strong: #0b4f86;
  --mint: #dff3ec;
  --coral: #d95f48;
  --amber: #d99a22;
  --amber-strong: #b07a14;
  --amber-soft: rgba(217, 154, 34, 0.12);
  --amber-soft-strong: rgba(217, 154, 34, 0.22);
  --violet: #2f80ed;
  --danger: #ba2f2f;
  --shadow: 0 18px 50px rgba(41, 35, 26, 0.11);
  --radius: 8px;
  --sidebar: 280px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 32%),
    linear-gradient(315deg, rgba(217, 95, 72, 0.08), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, calc(100vw - var(--sidebar)));
  grid-template-rows: auto 1fr;
  align-items: start;
}

.app-shell.is-locked {
  display: none;
}

.sync-banner {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 44px;
  padding: 7px 18px;
  background: var(--aqua);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
}

.sync-banner-button {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 0 12px;
  font-weight: 800;
}

.auth-screen {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(0, 720px);
  align-items: center;
  justify-content: center;
  gap: 28px;
  min-height: 100vh;
  padding: 32px;
}

.auth-screen.is-hidden {
  display: none;
}

.auth-card {
  display: grid;
  gap: 22px;
  width: min(100%, 460px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.auth-subtitle {
  margin: 8px 0 0;
  font-size: 0.92rem;
  color: var(--ink);
  opacity: 0.78;
  line-height: 1.5;
}

/* Avviso "non forfettario" nel profilo fiscale */
.non-forfettario-warning {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-top: 8px;
  border: 1px solid var(--amber);
  border-left: 4px solid var(--amber);
  border-radius: 10px;
  background: var(--amber-soft, rgba(217, 154, 34, 0.10));
  color: var(--ink);
}

.non-forfettario-warning > span {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--amber);
  color: #fff;
}

.non-forfettario-warning > span svg {
  width: 16px;
  height: 16px;
}

.non-forfettario-warning > div {
  flex: 1;
  min-width: 0;
}

.non-forfettario-warning strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.non-forfettario-warning small {
  display: block;
  font-size: 0.82rem;
  line-height: 1.45;
  opacity: 0.86;
}

/* Sezione INPS GS rivalsa nel form fattura */
.invoice-section-inps {
  border-left: 4px solid var(--amber, #d99a22) !important;
}

.invoice-inverse-grid {
  align-items: end;
}

.invoice-inverse-primary input {
  border-color: #b45309 !important;
  background: #fffbeb !important;
  font-weight: 800;
}

.invoice-inverse-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #b45309;
  color: #fff;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.invoice-inverse-calculator {
  margin-top: 12px;
  padding: 14px;
  border: 1px dashed var(--line-strong, var(--line));
  border-radius: 10px;
  background: var(--amber-soft, rgba(217, 154, 34, 0.10));
}

.invoice-inverse-calculator .eyebrow {
  margin: 0 0 4px;
  font-size: 0.8rem;
}

.invoice-inverse-calculator > .muted-copy {
  margin: 0 0 10px;
  font-size: 0.84rem;
}

.invoice-inverse-hint {
  margin: 8px 0 0 !important;
  font-size: 0.8rem !important;
  font-style: italic;
}

.invoice-inverse-calculator button {
  align-self: flex-end;
}

/* Box risultato scorporo */
.invoice-inverse-result {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--amber, #d99a22);
  border-radius: 8px;
  background: var(--surface, #fff);
}

.invoice-inverse-result > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.92rem;
  padding: 4px 0;
}

.invoice-inverse-result > div span {
  opacity: 0.78;
}

.invoice-inverse-result > div strong {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.invoice-inverse-result-total {
  padding-top: 8px !important;
  margin-top: 4px;
  border-top: 1px dashed var(--line, #ddd);
  font-size: 1.02rem !important;
}

.invoice-inverse-result-total strong {
  color: var(--amber-strong, #b07a14);
  font-size: 1.05rem;
}

body.dark .invoice-inverse-result-total strong {
  color: var(--amber-strong, #ffd06a);
}

.auth-preview {
  display: grid;
  gap: 18px;
  min-height: 430px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-preview-hero {
  display: grid;
  align-content: end;
  gap: 10px;
  min-height: 150px;
  padding: 24px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(10, 29, 51, 0.88), rgba(15, 118, 110, 0.74)),
    linear-gradient(45deg, rgba(217, 154, 34, 0.62), transparent 58%),
    #0a1d33;
  color: #fffdf8;
  overflow: hidden;
}

.auth-preview-pill {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.16);
  color: #fff8e0;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-preview-hero strong {
  max-width: 520px;
  font-size: clamp(1.45rem, 2.4vw, 2.2rem);
  line-height: 1.08;
}

.auth-preview-hero small {
  max-width: 430px;
  color: rgba(255, 253, 248, 0.84);
  font-size: 0.92rem;
  line-height: 1.45;
}

.auth-preview-top {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.7fr;
  gap: 12px;
  align-items: start;
}

.auth-preview-top span,
.auth-preview-grid div,
.auth-preview-chart {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.auth-preview-top span {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 92px;
  padding: 14px;
}

.auth-preview-top span:nth-child(1) {
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.16), transparent 58%),
    var(--surface-strong);
}

.auth-preview-top span:nth-child(2) {
  background:
    linear-gradient(135deg, rgba(217, 95, 72, 0.16), transparent 58%),
    var(--surface-strong);
}

.auth-preview-top span:nth-child(3) {
  background:
    linear-gradient(135deg, rgba(217, 154, 34, 0.18), transparent 58%),
    var(--surface-strong);
}

.auth-preview-top strong {
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.2;
}

.auth-preview-top small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.auth-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.auth-preview-grid div {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.auth-preview-grid strong {
  font-size: 0.98rem;
}

.auth-preview-chart {
  display: flex;
  align-items: end;
  gap: 12px;
  min-height: 170px;
  padding: 18px;
}

.auth-preview-chart span {
  flex: 1;
  min-height: 38px;
  border-radius: 6px 6px 0 0;
  background: var(--teal);
}

.auth-preview-chart span:nth-child(even) {
  background: var(--coral);
}

.auth-brand {
  padding: 0;
}

.auth-copy {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-weight: 750;
}

.text-action {
  width: fit-content;
  border: 0;
  background: transparent;
  color: var(--teal-strong);
  padding: 0;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.forgot-password-form,
.password-reset-form {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7faf9;
}

.auth-reset-result {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(15, 118, 110, 0.26);
  border-radius: var(--radius);
  background: var(--mint);
  color: var(--teal-strong);
  line-height: 1.45;
}

.auth-reset-result.is-loading {
  border-color: rgba(21, 101, 192, 0.24);
  background: #eff6ff;
  color: #1d4ed8;
}

.auth-reset-result.is-error {
  border-color: rgba(220, 84, 67, 0.28);
  background: #fff1ed;
  color: var(--danger);
}

.auth-reset-result.is-success {
  border-color: rgba(15, 118, 110, 0.34);
  background: var(--mint);
  color: var(--teal-strong);
  font-weight: 750;
}

.auth-global-result {
  border-width: 2px;
  font-size: 0.96rem;
}

.auth-reset-result strong {
  display: inline-block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.02rem;
}

.demo-access {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: var(--radius);
  background: var(--mint);
  color: var(--teal-strong);
  font-size: 0.86rem;
}

.sidebar {
  grid-column: 1;
  grid-row: 2;
  width: var(--sidebar);
  max-width: var(--sidebar);
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 18px;
  min-height: calc(100vh - 44px);
  height: calc(100vh - 44px);
  padding: 24px 18px;
  border-right: 1px solid #a76608;
  border-bottom: 0;
  background: #d99a22;
  color: #2b1a03;
  backdrop-filter: none;
  overflow-y: auto;
}

.brand,
.advisor-mini,
.nav-item,
.topbar,
.topbar-actions,
.search-box,
.alert-band,
.panel-header,
.table-toolbar,
.toolbar-actions,
.metric-card,
.account-chip,
.timeline-item,
.task-item,
.activity-item,
.doc-card,
.chat-form,
.payment-card,
.profile-pill {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  padding: 4px 2px 12px;
  min-width: 0;
  border-bottom: 1px solid rgba(43, 26, 3, 0.22);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--purple);
  color: #fffdf8;
  font-weight: 800;
}

.brand-logo {
  display: block;
  flex: 0 0 auto;
  width: 58px;
  height: 46px;
  object-fit: contain;
  border: 1px solid rgba(43, 26, 3, 0.18);
  border-radius: var(--radius);
  background: #fff;
  padding: 4px;
}

.auth-brand .brand-logo {
  width: 78px;
  height: 58px;
}

.brand strong,
.advisor-mini strong {
  display: block;
  line-height: 1.1;
}

.brand span,
.advisor-mini span,
small {
  color: var(--muted);
}

.sidebar .brand strong,
.sidebar .brand span {
  color: #2b1a03;
}

.main-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 5px;
  min-width: 0;
  flex: 0 0 auto;
  overflow: visible;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid rgba(43, 26, 3, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 248, 224, 0.22);
  color: #3b2505;
  text-align: left;
  font-size: 0.94rem;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.nav-item [data-icon] {
  display: grid;
  place-items: center;
  width: 22px;
  min-width: 22px;
}

.nav-item > span:not([data-icon]):not(.nav-badge):not(.plan-lock-badge) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:hover {
  border-color: rgba(76, 44, 2, 0.28);
  color: #fffdf8;
  background: #b8750f;
}

.nav-item.is-active {
  border-color: rgba(76, 44, 2, 0.34);
  background: #a76608;
  color: #fffdf8;
  font-weight: 700;
}

body.dark .nav-item.is-active {
  color: var(--amber-strong);
}

.nav-item.is-active [data-icon] {
  color: #fff4cf;
}

/* Voce di navigazione bloccata dal piano di abbonamento */
.nav-item.is-plan-locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.nav-item.is-plan-locked:hover {
  background: rgba(255, 248, 224, 0.22);
  color: #3b2505;
}

.plan-lock-badge {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff8e0;
  color: #6d4200;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-item:not(.is-plan-locked) .plan-lock-badge {
  display: none;
}

.nav-item.is-hidden,
[data-admin-only].is-hidden {
  display: none;
}

.nav-create-group {
  position: relative;
  width: 100%;
}

.nav-create-toggle {
  cursor: pointer;
}

.nav-create-toggle [data-icon="chevron-down"] {
  margin-left: auto;
  transition: transform 0.18s ease;
}

.nav-create-group.is-open .nav-create-toggle {
  border-color: rgba(76, 44, 2, 0.34);
  color: #fffdf8;
  background: #a76608;
}

.nav-create-group.is-open .nav-create-toggle [data-icon="chevron-down"] {
  transform: rotate(180deg);
}

.nav-create-submenu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  display: grid;
  width: 100%;
  min-width: 190px;
  gap: 4px;
  padding: 8px;
  border: 1px solid #a76608;
  border-radius: var(--radius);
  background: #d99a22;
  box-shadow: var(--shadow);
}

.nav-create-submenu[hidden] {
  display: none;
}

.nav-create-submenu button {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: rgba(255, 248, 224, 0.24);
  color: #3b2505;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.nav-create-submenu button:hover,
.nav-create-submenu button:focus-visible {
  background: #b8750f;
  color: #fffdf8;
  outline: none;
}

body:not(.portal-directory-active) [data-portal-client-field] {
  display: none;
}

#sportWorkerPanel,
[data-sport-limit-only],
#simSportCompensoField,
#simFiscalSportRow,
#simFiscalFreeRow,
#simFiscalSportTaxableRow,
#simContribSportRow,
#simContribFreeRow,
#simContribExcessRow {
  display: none !important;
}

[data-icon] {
  display: inline-flex;
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
}

[data-icon] svg {
  width: 100%;
  height: 100%;
  stroke-width: 2;
}

.advisor-mini {
  gap: 12px;
  margin-top: auto;
  margin-left: 0;
  flex: 0 0 auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.avatar-stack {
  display: flex;
  width: 60px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

.avatar-b {
  margin-left: -10px;
  background: var(--coral);
}

.avatar-a {
  background: var(--teal);
}

.workspace {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 26px 24px 40px;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar-actions {
  justify-content: flex-end;
  gap: 10px;
  min-width: min(660px, 58vw);
}

.account-chip {
  gap: 9px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.account-chip strong,
.account-chip span {
  display: block;
  line-height: 1.1;
}

.account-chip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.scope-return-action {
  min-height: 42px;
  border-color: rgba(217, 154, 34, 0.45);
  background: var(--amber-soft);
  color: var(--amber-strong);
}

.search-box {
  flex: 1 1 280px;
  min-width: 220px;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: 0;
}

.primary-action,
.secondary-action,
.ghost-button,
.text-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: var(--radius);
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.primary-action {
  border: 1px solid var(--purple-strong);
  background: var(--purple);
  color: white;
  padding: 0 15px;
}

.primary-action:hover {
  background: var(--purple-strong);
}

.secondary-action {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
}

.secondary-action:hover {
  border-color: var(--purple);
  color: var(--purple);
}

.ghost-button,
.text-button {
  border: 0;
  background: transparent;
  color: var(--teal-strong);
}

.ghost-button {
  padding: 0 12px;
}

.text-button {
  min-height: auto;
  padding: 4px 0;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.icon-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.full-width {
  width: 100%;
}

.alert-band {
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid rgba(217, 154, 34, 0.42);
  border-radius: var(--radius);
  background: rgba(255, 247, 224, 0.86);
}

.alert-band div {
  flex: 1;
  min-width: 0;
}

.alert-band strong,
.alert-band span {
  display: block;
}

.alert-band span {
  color: #725317;
}

.fiscal-updates-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.fiscal-updates-banner strong,
.fiscal-updates-banner span {
  display: block;
}

.fiscal-updates-banner strong {
  margin: 3px 0;
  font-size: 1.02rem;
}

.fiscal-updates-banner span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

.fiscal-updates-banner a {
  flex: 0 0 auto;
  text-decoration: none;
}

.client-work-action {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.6fr) repeat(3, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  justify-content: space-between;
  min-height: 146px;
  padding: 18px;
}

.metric-card strong {
  display: block;
  margin: 10px 0 6px;
  font-size: clamp(1.55rem, 2.2vw, 2.6rem);
  line-height: 1;
  letter-spacing: 0;
}

.metric-card.needs-attention {
  border-color: rgba(185, 28, 28, 0.35);
  background: rgba(185, 28, 28, 0.05);
}

.card-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.primary-metric {
  min-height: 168px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.13), transparent 52%),
    var(--surface-strong);
}

.primary-metric canvas {
  width: 122px;
  height: 122px;
}

.portal-plan-panel {
  display: grid;
  gap: 16px;
  margin-bottom: 14px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(217, 154, 34, 0.13), transparent 58%),
    var(--surface-strong);
}

.portal-plan-panel[hidden] {
  display: none !important;
}

.portal-plan-main,
.portal-plan-facts,
.portal-plan-features {
  display: grid;
  gap: 12px;
}

.portal-plan-main {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.portal-plan-main h2 {
  margin: 4px 0 6px;
}

.portal-plan-main p {
  margin: 0;
  color: var(--muted);
}

.portal-plan-facts {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.portal-plan-facts article {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.portal-plan-facts small,
.portal-plan-features li {
  color: var(--muted);
}

.portal-plan-facts strong {
  display: block;
  margin-top: 6px;
  font-size: 1.08rem;
}

.portal-plan-features {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

.portal-plan-features li {
  min-height: 54px;
  padding: 11px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.64);
  font-size: 0.9rem;
}

.sport-flow-panel {
  margin-bottom: 14px;
}

.sport-flow-main,
.sport-flow-actions,
.sport-flow-badges,
.sport-flow-grid {
  display: flex;
  gap: 10px;
}

.sport-flow-main {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sport-flow-main h2 {
  margin: 4px 0 8px;
}

.sport-flow-actions,
.sport-flow-badges {
  align-items: center;
  flex-wrap: wrap;
}

.sport-flow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sport-flow-grid article {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.sport-flow-grid small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.sport-flow-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
  line-height: 1.1;
}

.sport-progress {
  height: 10px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.signup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(8, 24, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.signup-overlay[hidden] {
  display: none !important;
}

.signup-dialog {
  background: #fff;
  border-radius: 14px;
  width: min(720px, 100%);
  max-height: 92vh;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(8, 24, 42, 0.28);
  overflow: hidden;
  box-sizing: border-box;
}

.signup-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.signup-head h2 {
  margin: 4px 0 6px;
  font-size: 1.35rem;
}

.signup-form {
  padding: 16px 22px 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
}

.signup-form fieldset.fpa-fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px 14px;
  margin: 0;
}

.signup-form legend {
  padding: 0 6px;
  font-weight: 800;
  color: #0f766e;
  font-size: 0.88rem;
}

.signup-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.signup-form .form-row.three-columns {
  grid-template-columns: 2fr 1fr 1fr;
}

@media (max-width: 600px) {
  .signup-overlay {
    padding: 0;
    align-items: stretch;
  }

  .signup-dialog {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .signup-head {
    padding: 14px 16px 10px;
  }

  .signup-head h2 {
    font-size: 1.18rem;
  }

  .signup-head .muted-copy {
    font-size: 0.85rem;
  }

  .signup-form {
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    gap: 12px;
  }

  .signup-form .form-row,
  .signup-form .form-row.three-columns {
    grid-template-columns: 1fr;
  }

  .signup-form fieldset.fpa-fieldset {
    padding: 12px 12px 14px;
  }

  .signup-form .checkbox-line {
    font-size: 0.92rem;
    padding: 8px 0;
    gap: 12px;
  }

  .signup-form .checkbox-line input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex-shrink: 0;
  }

  .signup-form .checkbox-line span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .signup-form .primary-action.full-width {
    position: sticky;
    bottom: 0;
    padding-block: 14px;
    box-shadow: 0 -6px 16px rgba(8, 24, 42, 0.10);
    z-index: 2;
  }

  .signup-form input,
  .signup-form select,
  .signup-form textarea {
    font-size: 16px;  /* evita zoom su iOS Safari quando si entra in un campo */
  }
}

.signup-form .checkbox-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.88rem;
  line-height: 1.4;
  margin-bottom: 6px;
}

.signup-form .checkbox-line input {
  margin-top: 3px;
}

.signup-form .text-action {
  background: none;
  border: none;
  color: #0f766e;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.anfis-contract-dialog {
  width: min(780px, 100%);
}

.anfis-contract-body {
  padding: 16px 22px;
  overflow-y: auto;
  flex: 1;
  font-size: 0.92rem;
  line-height: 1.55;
  color: #1f2a37;
  scroll-behavior: smooth;
}

.anfis-contract-body h3 {
  margin-top: 0;
}

.anfis-contract-body h4 {
  margin-top: 18px;
  margin-bottom: 4px;
  color: #0f766e;
}

.anfis-contract-body ul {
  margin: 6px 0 10px 20px;
}

.anfis-end-marker {
  margin-top: 18px;
  padding: 10px 12px;
  background: rgba(15, 118, 110, 0.08);
  border-left: 3px solid #0f766e;
  border-radius: 6px;
}

.anfis-contract-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px 16px;
  border-top: 1px solid var(--line);
  background: #f9fafb;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .anfis-contract-dialog {
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .anfis-contract-body {
    padding: 14px 16px;
    font-size: 0.95rem;
  }
  .anfis-contract-footer {
    flex-direction: column-reverse;
    align-items: stretch;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }
  .anfis-contract-footer .primary-action,
  .anfis-contract-footer .secondary-action {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
}

.icon-button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #475569;
}

.icon-button:hover {
  border-color: #0f766e;
  color: #0f766e;
}

.sport-threshold-card {
  margin-top: 16px;
}

.plan-faq {
  margin-top: 36px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.plan-faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.plan-faq-card {
  padding: 18px 20px;
  background: var(--surface, #fff);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.plan-faq-card:hover {
  border-color: rgba(0, 158, 145, 0.40);
  box-shadow: 0 4px 12px rgba(0, 158, 145, 0.08);
}

.plan-faq-card h4 {
  margin: 0 0 8px;
  font-size: 1rem;
  line-height: 1.25;
  color: var(--ink, #0f172a);
}

.plan-faq-card p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted, #5a6471);
}

.billing-callout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 24px;
  margin: 18px 0 26px;
  background: linear-gradient(135deg, #fff4e0 0%, #fde8d4 100%);
  border: 2px solid #f59e0b;
  border-radius: 18px;
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.15);
  position: relative;
  overflow: hidden;
}

.billing-callout::before {
  content: "🎁";
  position: absolute;
  font-size: 5rem;
  opacity: 0.08;
  right: -10px;
  top: -10px;
  transform: rotate(15deg);
  pointer-events: none;
}

.billing-callout-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 280px;
  min-width: 240px;
}

.billing-callout-eyebrow {
  display: inline-block;
  width: max-content;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #b45309;
  background: rgba(245, 158, 11, 0.18);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.billing-callout-body strong {
  font-size: 1.2rem;
  line-height: 1.25;
  color: #78350f;
}

.billing-callout-body small {
  color: #78350f;
  opacity: 0.85;
}

.billing-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  background: #fff;
  border-radius: 999px;
  border: 1px solid var(--line);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.billing-toggle-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border: 0;
  background: transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  color: var(--muted, #5a6471);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.billing-toggle-option:hover {
  color: var(--ink, #0f172a);
}

.billing-toggle-option.is-active {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 158, 145, 0.30);
}

.billing-save-badge {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

.billing-toggle-option.is-active .billing-save-badge {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.plan-savings-ribbon {
  position: absolute;
  top: 14px;
  right: -38px;
  transform: rotate(35deg);
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  padding: 6px 44px;
  box-shadow: 0 4px 10px rgba(220, 38, 38, 0.30);
  z-index: 3;
  display: none;
  pointer-events: none;
}

.portal-plan-grid {
  position: relative;
}

.portal-plan-grid .plan-choice-card {
  position: relative;
  overflow: hidden;
}

.portal-plan-grid[data-billing-mode="annual"] .plan-savings-ribbon {
  display: block;
}

.portal-plan-grid[data-billing-mode="annual"] .plan-choice-card {
  border-color: rgba(245, 158, 11, 0.40);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.10);
}

.billing-callout.is-annual-mode {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border-color: #059669;
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.15);
}

.billing-callout.is-annual-mode::before {
  content: "✓";
  font-size: 4.5rem;
  opacity: 0.10;
  color: #065f46;
  top: 0;
  right: 6px;
  transform: none;
}

.billing-callout.is-annual-mode .billing-callout-eyebrow {
  color: #065f46;
  background: rgba(5, 150, 105, 0.18);
}

.billing-callout.is-annual-mode .billing-callout-body strong,
.billing-callout.is-annual-mode .billing-callout-body small {
  color: #065f46;
}

.onboarding-strip {
  padding: 18px 22px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(0, 158, 145, 0.06));
  border: 1px solid rgba(99, 102, 241, 0.20);
  border-radius: 16px;
}

.onboarding-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.onboarding-head h2 {
  margin: 4px 0 4px;
  font-size: 1.2rem;
}

.onboarding-head .eyebrow,
.onboarding-head .muted-copy {
  margin: 0;
}

.onboarding-chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.onboarding-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.onboarding-chip:hover {
  border-color: var(--teal);
  box-shadow: 0 4px 12px rgba(0, 158, 145, 0.10);
}

.onboarding-chip:active {
  transform: translateY(1px);
}

.onboarding-chip-step {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  color: #4f46e5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
}

.onboarding-chip-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.onboarding-chip-body strong {
  font-size: 0.95rem;
  line-height: 1.2;
}

.onboarding-chip-body small {
  color: var(--muted, #5a6471);
  font-size: 0.78rem;
}

.onboarding-chip.is-done {
  background: rgba(0, 158, 145, 0.06);
  border-color: rgba(0, 158, 145, 0.35);
}

.onboarding-chip.is-done .onboarding-chip-step {
  background: var(--teal);
  color: #fff;
}

.onboarding-chip.is-done .onboarding-chip-body strong {
  text-decoration: line-through;
  color: var(--muted, #5a6471);
}

.dashboard-greeting {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(0, 158, 145, 0.10), rgba(0, 158, 145, 0.02));
  border: 1px solid rgba(0, 158, 145, 0.18);
  border-radius: 16px;
}

.dashboard-greeting h2 {
  margin: 4px 0 6px;
  font-size: 1.45rem;
  line-height: 1.2;
}

.dashboard-greeting .eyebrow {
  margin: 0;
}

.dashboard-greeting .muted-copy {
  margin: 0;
}

.dashboard-greeting-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.dashboard-quick-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.quick-info-card {
  padding: 16px 18px;
  background: var(--surface, #fff);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quick-info-card strong {
  font-size: 1.15rem;
  line-height: 1.2;
}

.codice-destinatario-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 2px;
}

.codice-destinatario-row strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.4rem;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  background: rgba(0, 158, 145, 0.08);
  border-radius: 8px;
  color: var(--teal);
}

.quick-info-actions {
  margin-top: 8px;
}

.sport-threshold-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sport-threshold-status {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 158, 145, 0.12);
  color: var(--teal);
  white-space: nowrap;
}

.sport-threshold-status[data-tone="warn"] {
  background: rgba(217, 147, 0, 0.15);
  color: #a36c00;
}

.sport-threshold-status[data-tone="alert"] {
  background: rgba(192, 57, 43, 0.15);
  color: #a8281c;
}

.sport-progress span {
  display: block;
  width: var(--sport-progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.sport-simulator {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.sport-simulator-head,
.sport-simulator-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.sport-simulator-head h3 {
  margin: 3px 0 0;
  font-size: 1.1rem;
}

.sport-simulator-head label {
  flex: 0 1 280px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.sport-simulator-head input {
  width: 100%;
  min-height: 42px;
  margin-top: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
}

.sport-simulator-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.sport-simulator-grid article {
  min-height: 82px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
}

.sport-simulator-grid small,
.sport-simulator-foot {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.sport-simulator-grid strong {
  display: block;
  margin-top: 7px;
  font-size: 1.25rem;
  line-height: 1.1;
}

.sport-simulator-warning {
  padding: 10px 12px;
  border: 1px solid rgba(179, 82, 18, 0.28);
  border-radius: 8px;
  background: #fff3df;
  color: #7a3d0d;
  font-size: 0.86rem;
  font-weight: 800;
}

.content-layout,
.split-layout,
.advisor-layout {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.content-layout {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.42fr);
}

.split-layout {
  grid-template-columns: minmax(280px, 0.38fr) minmax(0, 1fr);
}

.advisor-layout {
  grid-template-columns: minmax(250px, 0.35fr) minmax(0, 1fr);
}

.panel {
  min-width: 0;
  padding: 18px;
}

.market-breadcrumb {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.muted-copy {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.market-breadcrumb a {
  color: var(--purple);
  text-decoration: none;
  font-weight: 700;
}

.market-page-title {
  margin: 0 0 18px;
  font-size: clamp(1.6rem, 2.4vw, 2rem);
  font-weight: 700;
  letter-spacing: 0;
}

.market-hero {
  display: grid;
  gap: 14px;
  margin: 0 -18px 26px;
  padding: 36px 28px;
  background: #e9ebf8;
  text-align: center;
}

.market-hero p {
  width: min(100%, 1040px);
  margin: 0 auto;
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.35;
}

.market-hero p.market-hero-sub {
  font-size: 1.05rem;
  font-weight: 500;
  color: #2a2a3a;
}

.portal-plans-store {
  display: grid;
  gap: 16px;
  margin-bottom: 30px;
}

.section-mini-head {
  display: grid;
  gap: 6px;
}

.section-mini-head h3 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.75rem);
}

.section-mini-head p {
  max-width: 780px;
  margin: 0;
  color: var(--muted);
}

.service-grid.portal-plan-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.plan-choice-card {
  border: 1px solid var(--line);
}

.plan-choice-card.is-recommended {
  border: 2px solid var(--amber);
  box-shadow: 0 18px 44px rgba(217, 154, 34, 0.18);
}

.plan-choice-card.is-current-plan {
  border-color: var(--teal);
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.09), var(--surface-strong));
}

.plan-choice-card.is-current-plan [data-service-add] {
  opacity: 0.72;
  cursor: default;
}

.plan-choice-badge {
  width: fit-content;
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--amber-strong);
  background: var(--amber-soft);
  font-size: 0.78rem;
  font-weight: 850;
}

.plan-trial-note {
  display: block;
  color: var(--teal);
  font-weight: 800;
}

.plan-comparison {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: 0 10px 34px rgba(30, 24, 60, 0.08);
}

.plan-comparison-head {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.plan-comparison-head h3 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
}

.comparison-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.comparison-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.comparison-table th,
.comparison-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.comparison-table thead th {
  color: var(--ink);
  background: rgba(15, 118, 110, 0.08);
  font-weight: 850;
}

.comparison-table thead small {
  color: var(--muted);
  font-weight: 700;
}

.comparison-table tbody th {
  color: var(--ink);
  font-weight: 850;
}

.comparison-table tbody tr:last-child th,
.comparison-table tbody tr:last-child td {
  border-bottom: 0;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.service-card {
  display: grid;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: 0 10px 34px rgba(30, 24, 60, 0.08);
}

.service-card.is-expanded {
  outline: 2px solid rgba(15, 118, 110, 0.2);
}

.service-image {
  min-height: 130px;
  background:
    linear-gradient(135deg, rgba(67, 164, 178, 0.24), rgba(81, 64, 139, 0.12)),
    var(--bg);
}

.service-image-a {
  background:
    linear-gradient(135deg, rgba(81, 64, 139, 0.2), rgba(255, 255, 255, 0.36)),
    url("https://images.unsplash.com/photo-1554224155-6726b3ff858f?auto=format&fit=crop&w=1200&q=80") center/cover;
}

.service-image-b {
  background:
    linear-gradient(135deg, rgba(67, 164, 178, 0.22), rgba(255, 255, 255, 0.28)),
    url("https://images.unsplash.com/photo-1450101499163-c8848c66ca85?auto=format&fit=crop&w=1200&q=80") center/cover;
}

.service-image-c {
  background:
    linear-gradient(135deg, rgba(81, 64, 139, 0.24), rgba(255, 255, 255, 0.24)),
    url("https://images.unsplash.com/photo-1454165804606-c3d57bc86b40?auto=format&fit=crop&w=1200&q=80") center/cover;
}

.service-image-d {
  background:
    linear-gradient(135deg, rgba(67, 164, 178, 0.24), rgba(255, 255, 255, 0.24)),
    url("https://images.unsplash.com/photo-1554224154-26032ffc0d07?auto=format&fit=crop&w=1200&q=80") center/cover;
}

.service-image-e {
  background:
    linear-gradient(135deg, rgba(217, 95, 72, 0.18), rgba(255, 255, 255, 0.24)),
    url("https://images.unsplash.com/photo-1554224155-1696413565d3?auto=format&fit=crop&w=1200&q=80") center/cover;
}

.service-image-f {
  background:
    linear-gradient(135deg, rgba(81, 64, 139, 0.18), rgba(255, 255, 255, 0.24)),
    url("https://images.unsplash.com/photo-1518186285589-2f7649de83e0?auto=format&fit=crop&w=1200&q=80") center/cover;
}

.service-image-g {
  background:
    linear-gradient(135deg, rgba(67, 164, 178, 0.22), rgba(255, 255, 255, 0.24)),
    url("https://images.unsplash.com/photo-1450101499163-c8848c66ca85?auto=format&fit=crop&w=1200&q=80") center/cover;
}

.service-image-h {
  background:
    linear-gradient(135deg, rgba(217, 154, 34, 0.2), rgba(255, 255, 255, 0.22)),
    url("https://images.unsplash.com/photo-1560518883-ce09059eeffa?auto=format&fit=crop&w=1200&q=80") center/cover;
}

.service-image-i {
  background:
    linear-gradient(135deg, rgba(81, 64, 139, 0.2), rgba(255, 255, 255, 0.22)),
    url("https://images.unsplash.com/photo-1450101499163-c8848c66ca85?auto=format&fit=crop&w=1200&q=80") center/cover;
}

.service-body {
  display: grid;
  gap: 12px;
  padding: 24px;
}

.service-body h3 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.3;
}

.service-body p {
  margin: 0;
  min-height: 48px;
  line-height: 1.45;
}

.service-price {
  display: block;
  margin-top: 8px;
  font-size: 1.35rem;
}

.service-price del {
  font-size: 0.85rem;
  color: #94a3b8;
  font-weight: 600;
  margin-right: 6px;
  text-decoration: line-through;
}

.service-price .launch-now {
  display: inline-block;
  color: #b45309;
  font-weight: 800;
}

.service-price .launch-now > span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.service-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
}

.service-detail {
  display: grid;
  gap: 14px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.service-detail[hidden] {
  display: none !important;
}

.service-detail-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--teal);
  background: rgba(240, 253, 250, 0.72);
  color: var(--ink);
}

.service-detail-summary span {
  line-height: 1.4;
}

.service-detail-summary strong {
  flex: 0 0 auto;
  color: var(--teal-dark);
  font-size: 0.88rem;
}

.service-detail-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.service-detail h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.service-detail ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.4;
}

.service-detail-result {
  min-height: 0 !important;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.nav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 800;
}

.cart-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.42fr);
  gap: 14px;
  margin-bottom: 14px;
}

@media (max-width: 1180px) {
  .cart-layout {
    grid-template-columns: 1fr;
  }
}

.cart-list-panel {
  min-height: 240px;
}

.cart-empty {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 36px 12px;
  color: var(--muted);
  text-align: center;
}

.cart-empty[hidden] {
  display: none;
}

.cart-empty [data-icon] {
  width: 36px;
  height: 36px;
  color: var(--purple);
}

.cart-empty strong {
  color: var(--ink);
  font-size: 1.1rem;
}

.cart-empty a {
  color: var(--purple);
  font-weight: 700;
}

.cart-items {
  list-style: none;
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.cart-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.cart-item-info {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.cart-item-info strong {
  font-size: 0.98rem;
  line-height: 1.3;
}

.cart-item-info span {
  color: var(--muted);
  font-size: 0.84rem;
}

.cart-item-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cart-qty {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
}

.cart-item-total {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cart-summary {
  align-self: start;
  display: grid;
  gap: 14px;
}

.cart-totals {
  margin: 0;
  display: grid;
  gap: 10px;
}

.cart-totals div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}

.cart-totals dt {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.cart-totals dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cart-totals .cart-grand {
  border-bottom: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--mint);
  color: var(--teal-strong);
}

.cart-totals .cart-grand dt,
.cart-totals .cart-grand dd {
  color: inherit;
}

.cart-totals .cart-grand dd {
  font-size: 1.25rem;
}

.cart-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

@media (max-width: 620px) {
  .cart-item {
    grid-template-columns: 1fr;
  }
  .cart-item-total {
    text-align: right;
  }
}

.wide-panel {
  min-width: 0;
}

.panel-header,
.table-toolbar {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.segmented button {
  min-width: 58px;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segmented button.is-selected {
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(28, 25, 21, 0.08);
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

.timeline,
.task-list,
.activity-list,
.doc-grid,
.payment-grid,
.profile-summary {
  display: grid;
  gap: 10px;
}

.timeline-item {
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.timeline-date {
  display: grid;
  place-items: center;
  flex: 0 0 58px;
  min-height: 56px;
  border-radius: var(--radius);
  background: var(--mint);
  color: var(--teal-strong);
  font-weight: 800;
}

.timeline-date small {
  font-size: 0.7rem;
  font-weight: 800;
}

.timeline-item p,
.task-item p,
.activity-item p,
.doc-card p {
  margin-bottom: 3px;
}

.task-item {
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.task-item label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.task-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.status-pill,
.amount-pill,
.profile-pill {
  min-height: 28px;
  width: fit-content;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.status-paid {
  background: var(--mint);
  color: var(--teal-strong);
}

.status-open {
  background: #fff0d3;
  color: #8a5a08;
}

.status-draft {
  background: #ece9ff;
  color: #4f3bab;
}

.status-error {
  background: #ffe1dd;
  color: #9d2d20;
}

.sdi-metrics {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
}

.sdi-metrics .metric-card strong {
  font-size: 1.28rem;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.compact-empty {
  min-height: 90px;
  box-shadow: none;
}

.empty-state-rich {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 36px 24px;
  background: linear-gradient(180deg, rgba(0, 158, 145, 0.05), transparent);
  border: 1px dashed rgba(0, 158, 145, 0.35);
  border-radius: 16px;
  min-height: 220px;
}

.empty-state-rich .empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 158, 145, 0.12);
  color: var(--teal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.empty-state-rich .empty-icon [data-icon] {
  width: 28px;
  height: 28px;
}

.empty-state-rich strong {
  font-size: 1.18rem;
  line-height: 1.25;
}

.empty-state-rich small {
  max-width: 480px;
  color: var(--muted, #5a6471);
}

.empty-state-rich .empty-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}

.import-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  margin-top: 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(0, 158, 145, 0.06));
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: 14px;
}

.import-banner .import-banner-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.import-banner strong {
  font-size: 1.05rem;
}

.import-banner small {
  color: var(--muted, #5a6471);
  max-width: 560px;
}

.import-modal-grid {
  display: grid;
  gap: 12px;
}

.import-modal-grid label {
  font-size: 0.85rem;
  font-weight: 600;
}

.import-format-hint {
  font-size: 0.78rem;
  background: rgba(0, 158, 145, 0.06);
  padding: 12px;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.import-preview-table {
  font-size: 0.85rem;
  width: 100%;
  border-collapse: collapse;
}

.import-preview-table th, .import-preview-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.import-summary-pill {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 158, 145, 0.12);
  color: var(--teal);
  font-weight: 700;
  font-size: 0.85rem;
}

.activity-item {
  justify-content: space-between;
  gap: 14px;
  min-height: 62px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.activity-item:last-child {
  border-bottom: 0;
}

.amount-pill {
  background: var(--bg);
  color: var(--ink);
  white-space: nowrap;
}

.table-toolbar {
  margin-bottom: 14px;
}

.table-toolbar.compact {
  margin-bottom: 16px;
}

.toolbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

select,
input {
  box-sizing: border-box;
  max-width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
}

select {
  padding: 0 12px;
}

input {
  padding: 0 12px;
}

.stacked-form,
.settings-grid {
  display: grid;
  gap: 13px;
}

.stacked-form label,
.settings-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-row.three-columns {
  grid-template-columns: 0.7fr 1.5fr 0.6fr;
}

.client-management-layout {
  grid-template-columns: 1fr;
  align-items: start;
  gap: 16px;
}

.client-rubric-toolbar {
  margin: 16px 0;
}

.client-archive-panel {
  order: 1;
}

.client-form-panel {
  order: 2;
}

.client-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  z-index: 80;
  display: grid;
  gap: 16px;
  width: min(1120px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  transform: translate(-50%, -50%);
  box-shadow: 0 28px 80px rgba(20, 28, 38, 0.28);
}

.client-modal::before {
  content: "";
  position: fixed;
  inset: -100vmax;
  z-index: -1;
  background: rgba(10, 24, 38, 0.42);
}

.client-modal.is-hidden {
  display: none;
}

body.client-modal-open {
  overflow: hidden;
}

.client-modal .panel-header {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: -20px -20px 0;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}

.client-edit-form {
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 12px;
}

.client-edit-form > button {
  align-self: end;
}

.client-main-box,
.client-fiscal-box {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: var(--radius);
  background: rgba(248, 251, 252, 0.92);
}

.client-fiscal-box {
  border-color: rgba(81, 64, 139, 0.22);
  background: rgba(247, 244, 255, 0.74);
}

.client-main-box legend,
.client-fiscal-box legend {
  padding: 0 6px;
  color: var(--teal-strong);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.client-fiscal-box legend {
  color: var(--purple);
}

.client-main-box > label,
.client-main-box > .form-row,
.client-fiscal-box > .form-row {
  min-width: 0;
}

.client-main-box > .form-row,
.client-fiscal-box > .form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-column: span 2;
  gap: 10px;
}

.client-main-box > label:nth-of-type(2),
.client-fiscal-box > label {
  grid-column: span 2;
}

.client-main-box > label:nth-of-type(3) {
  grid-column: span 1;
}

.client-main-box > .portal-plan-preview {
  grid-column: 1 / -1;
}

.client-row-actions {
  display: grid;
  grid-template-columns: repeat(2, 38px);
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

body.portal-directory-active .client-row-actions {
  grid-template-columns: minmax(70px, auto) repeat(3, 38px) minmax(96px, auto) minmax(96px, auto) 38px;
}

.client-table {
  min-width: 920px;
  table-layout: fixed;
}

body.portal-directory-active .client-table {
  min-width: 1280px;
}

.client-table th,
.client-table td {
  padding: 14px 12px;
}

.client-col-name {
  width: 25%;
}

.client-col-email {
  width: 22%;
}

.client-col-fiscal {
  width: 22%;
}

.client-col-delivery {
  width: 22%;
}

.client-col-plan {
  width: 15%;
}

.client-col-fee {
  width: 12%;
}

.client-col-status {
  width: 14%;
}

.client-col-access {
  width: 10%;
}

.client-col-actions {
  width: 110px;
}

body.portal-directory-active .client-col-actions {
  width: 350px;
}

.client-name-cell,
.client-fee-cell,
.client-email-cell,
.client-plan-cell,
.client-access-cell {
  min-width: 0;
}

.client-name-cell strong,
.client-name-cell small,
.client-name-cell em,
.client-email-cell span,
.client-email-cell small,
.client-plan-cell small,
.client-fee-cell strong,
.client-fee-cell small,
.client-access-cell strong,
.client-access-cell small {
  display: block;
}

.client-name-cell strong,
.client-email-cell span,
.client-fee-cell strong,
.client-access-cell strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-name-cell small {
  margin-top: 3px;
  color: var(--muted);
}

.client-name-cell em {
  margin-top: 5px;
  color: var(--teal-strong);
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.client-plan-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(81, 64, 139, 0.2);
  border-radius: 999px;
  background: #f1ecff;
  color: var(--purple);
  font-size: 0.78rem;
  font-weight: 850;
}

.client-plan-pill.is-configured {
  border-color: rgba(217, 154, 34, 0.3);
  background: var(--amber-soft);
  color: var(--amber-strong);
}

.client-plan-pill.is-missing {
  border-color: rgba(186, 47, 47, 0.22);
  background: rgba(186, 47, 47, 0.08);
  color: var(--danger);
}

.client-fee-cell small,
.client-access-cell small,
.client-email-cell small,
.client-plan-cell small {
  color: var(--muted);
  font-weight: 750;
}

.portal-plan-preview {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid rgba(217, 154, 34, 0.3);
  border-radius: var(--radius);
  background: var(--amber-soft);
}

.portal-plan-preview strong {
  color: var(--ink);
}

.portal-plan-preview span,
.portal-plan-preview small {
  color: var(--muted);
  line-height: 1.35;
}

.client-table tr:hover td {
  background: rgba(15, 118, 110, 0.045);
}

.client-management-row td {
  padding-top: 0;
  background: rgba(20, 159, 207, 0.035);
}

.client-management-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.client-management-strip article {
  min-width: 0;
}

.client-management-strip small,
.client-management-strip strong,
.client-management-strip span,
.client-management-strip em {
  display: block;
}

.client-management-strip small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.client-management-strip strong {
  margin-top: 4px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-management-strip article > span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.client-feature-strip > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.feature-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 850;
}

.feature-chip.is-included {
  border-color: rgba(15, 118, 110, 0.22);
  background: rgba(15, 118, 110, 0.08);
  color: var(--teal-strong);
}

.feature-chip.is-locked {
  border-color: rgba(186, 47, 47, 0.22);
  background: rgba(186, 47, 47, 0.08);
  color: var(--danger);
}

.client-detail-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.client-detail-panel[hidden] {
  display: none;
}

.client-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.client-detail-head h2 {
  margin: 0;
}

.client-detail-actions,
.admin-ops-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.client-detail-grid,
.admin-ops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.client-detail-grid article,
.admin-ops-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
}

.client-detail-grid article.needs-attention,
.admin-ops-card:not(.is-quiet) {
  border-color: rgba(244, 184, 81, 0.48);
  background: #fff9ed;
}

.client-detail-grid small,
.client-detail-grid strong,
.client-detail-grid span {
  display: block;
}

.client-detail-grid small,
.admin-ops-card small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.client-detail-grid strong,
.admin-ops-card strong {
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.05rem;
}

.client-detail-grid span,
.admin-ops-card em {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 750;
}

.client-detail-lower {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.8fr);
  gap: 14px;
}

.client-detail-lower h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.client-detail-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
}

.client-detail-facts div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
}

.client-detail-facts dt {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.client-detail-facts dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-weight: 900;
}

.client-metrics .metric-card {
  border-color: rgba(15, 118, 110, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 251, 252, 0.92)),
    var(--surface);
}

.client-archive-panel {
  border: 1px solid rgba(15, 118, 110, 0.14);
  background: linear-gradient(180deg, #fff 0%, #fbfaf6 100%);
}

.client-archive-panel .panel-header {
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(15, 118, 110, 0.1);
}

.client-database-controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  margin: -2px 0 14px;
}

.client-db-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--muted);
}

.client-db-search [data-icon] {
  width: 18px;
  height: 18px;
}

.client-db-search input {
  width: 100%;
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  outline: none;
}

.client-filter-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.client-filter-tabs button {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 850;
  cursor: pointer;
}

.client-filter-tabs button.is-selected {
  background: var(--teal);
  color: #fff;
}

.client-visible-count {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
  text-align: right;
  white-space: nowrap;
}

body.portal-directory-active .client-table {
  min-width: 1180px;
  border-collapse: separate;
  border-spacing: 0 8px;
}

body.portal-directory-active .client-table th {
  padding: 8px 12px;
  border-bottom: 0;
  color: #526579;
  font-size: 0.7rem;
}

body.portal-directory-active .client-main-row td {
  border-top: 1px solid rgba(15, 118, 110, 0.11);
  border-bottom: 1px solid rgba(15, 118, 110, 0.11);
  background: #fff;
}

body.portal-directory-active .client-main-row td:first-child {
  border-left: 1px solid rgba(15, 118, 110, 0.11);
  border-radius: 8px 0 0 8px;
}

body.portal-directory-active .client-main-row td:last-child {
  border-right: 1px solid rgba(15, 118, 110, 0.11);
  border-radius: 0 8px 8px 0;
}

body.portal-directory-active .client-main-row:hover td {
  background: #f8fcfb;
}

body.portal-directory-active .client-main-row.is-selected-row td {
  border-color: rgba(15, 118, 110, 0.34);
  background: #f0fdfa;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

body.portal-directory-active .client-main-row.is-attention-client td:first-child {
  box-shadow: inset 4px 0 0 #d99a22;
}

body.portal-directory-active .client-main-row.is-blocked-client td:first-child {
  box-shadow: inset 4px 0 0 var(--danger);
}

body.portal-directory-active .client-row-actions {
  display: flex;
  flex-wrap: nowrap;
  grid-template-columns: none;
  justify-content: flex-end;
  gap: 6px;
}

.client-actions-cell {
  white-space: nowrap;
}

body.portal-directory-active .client-work-action {
  min-width: 64px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
}

body.portal-directory-active .client-access-action {
  width: 38px;
  min-width: 38px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  font-size: 0;
}

body.portal-directory-active .client-access-action [data-icon] {
  width: 16px;
  height: 16px;
}

.client-mini-features {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 7px;
}

.client-mini-features span {
  min-height: 20px;
  padding: 0 7px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.06);
  color: var(--teal-strong);
  font-size: 0.66rem;
  font-weight: 850;
  line-height: 18px;
}

.client-detail-panel {
  border-color: rgba(15, 118, 110, 0.16);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.06), rgba(217, 154, 34, 0.06)),
    #fff;
}

.client-detail-grid article {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.client-detail-lower {
  padding-top: 2px;
}

@media (max-width: 980px) {
  .client-database-controls {
    grid-template-columns: 1fr;
  }

  .client-filter-tabs {
    width: 100%;
    overflow-x: auto;
  }

  .client-visible-count {
    text-align: left;
  }
}

.admin-ops-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.admin-ops-panel[hidden] {
  display: none;
}

.admin-ops-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px 10px;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.admin-ops-card > span {
  display: inline-grid;
  grid-row: span 3;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(21, 94, 159, 0.1);
  color: var(--purple);
}

.admin-ops-card:hover,
.admin-ops-card:focus-visible {
  border-color: var(--purple);
  box-shadow: 0 8px 18px rgba(21, 94, 159, 0.12);
}

.danger-mini-button {
  color: var(--danger);
}

.draft-table table {
  table-layout: fixed;
}

.draft-table th:nth-child(1),
.draft-table td:nth-child(1) {
  width: 150px;
}

.draft-table th:nth-child(4),
.draft-table td:nth-child(4),
.draft-table th:nth-child(5),
.draft-table td:nth-child(5) {
  width: 128px;
}

.draft-table th:nth-child(6),
.draft-table td:nth-child(6) {
  width: 128px;
}

.draft-row-actions {
  justify-content: flex-end;
}

.danger-mini-button:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.notification-center-panel {
  display: grid;
  gap: 14px;
}

.notification-list {
  display: grid;
  gap: 10px;
}

.notification-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.notification-item > span {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(21, 94, 159, 0.1);
  color: var(--purple);
}

.notification-item strong,
.notification-item small,
.notification-item em {
  display: block;
}

.notification-item strong {
  color: var(--ink);
}

.notification-item small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.notification-item .notification-audience {
  color: var(--ink);
  font-weight: 750;
}

.notification-item em {
  margin-top: 4px;
  color: var(--teal-strong);
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 850;
}

.notification-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.notification-item.is-warning {
  border-color: rgba(244, 184, 81, 0.55);
  background: #fff9ed;
}

.notification-item.is-warning > span {
  background: rgba(244, 184, 81, 0.18);
  color: #8a5a00;
}

.notification-item.is-critical {
  border-color: rgba(211, 87, 70, 0.44);
  background: #fff3f0;
}

.notification-item.is-critical > span {
  background: rgba(211, 87, 70, 0.14);
  color: var(--danger);
}

button.is-hidden {
  display: none;
}

.checkbox-line {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: flex-start;
  gap: 9px !important;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  white-space: normal;
}

.checkbox-line input {
  flex: 0 0 18px;
  min-height: auto;
  min-width: 18px;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--teal);
}

.checkbox-line span,
.checkbox-line small {
  min-width: 0;
  max-width: 100%;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.table-panel {
  overflow: hidden;
}

.responsive-table {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

tr:last-child td {
  border-bottom: 0;
}

tr.is-selected-row td {
  background: rgba(15, 118, 110, 0.07);
}

.row-actions {
  display: inline-flex;
  gap: 6px;
}

.mini-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--muted);
}

.wide-mini-button {
  display: inline-flex;
  width: auto;
  min-width: 112px;
  padding: 0 10px;
  gap: 6px;
  color: var(--teal-strong);
  font-weight: 800;
}

.mini-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.invoice-sdi-mini-button {
  border-color: rgba(30, 99, 176, 0.28);
  background: rgba(30, 99, 176, 0.08);
  color: #1d4f91;
}

.invoice-sdi-mini-button:hover {
  border-color: rgba(30, 99, 176, 0.42);
  background: rgba(30, 99, 176, 0.14);
  color: #173f73;
}

.sdi-check-mini-button {
  border-color: rgba(16, 118, 112, 0.28);
  background: rgba(16, 118, 112, 0.08);
  color: var(--teal-strong);
}

.sdi-check-mini-button:hover {
  border-color: rgba(16, 118, 112, 0.44);
  background: rgba(16, 118, 112, 0.14);
  color: var(--teal-strong);
}

.sent-invoice-status-stack {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.sent-invoice-status-stack .status-pill {
  min-height: 24px;
  font-size: 0.72rem;
}

.sent-invoice-status-stack small {
  margin: 0;
  color: var(--muted);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.invoice-viewer {
  min-height: 220px;
}

.invoice-viewer-inline {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.mini-section-heading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--teal-strong);
}

.mini-section-heading svg {
  width: 18px;
  height: 18px;
}

.invoice-document {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.invoice-document-header,
.invoice-line,
.invoice-fiscal-note,
.invoice-viewer-actions {
  display: flex;
  align-items: center;
}

.invoice-document-header {
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.invoice-document h3 {
  margin: 0 0 8px;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
}

.invoice-total {
  display: grid;
  gap: 5px;
  min-width: 180px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--mint);
  color: var(--teal-strong);
  text-align: right;
}

.invoice-total strong {
  font-size: 1.35rem;
}

.invoice-parties {
  display: grid;
  grid-template-columns: 1.2fr 0.7fr 0.8fr;
  gap: 12px;
}

.invoice-parties div,
.invoice-summary-grid div {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.invoice-line {
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.invoice-line div {
  display: grid;
  gap: 6px;
}

.invoice-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.invoice-summary-grid span,
.invoice-parties small,
.invoice-line small,
.invoice-total small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-fiscal-note {
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: var(--radius);
  background: var(--mint);
  color: var(--teal-strong);
}

.invoice-fiscal-note svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.invoice-fiscal-note p {
  margin: 0;
  line-height: 1.45;
}

.invoice-viewer-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.tax-breakdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.tax-breakdown div,
.payment-card,
.profile-pill {
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.tax-breakdown div {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-radius: var(--radius);
}

.tax-breakdown span,
.profile-summary span,
.payment-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.tax-breakdown strong {
  font-size: 1.25rem;
}

.profile-summary {
  margin-bottom: 14px;
}

.profile-pill {
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  width: 100%;
  border-radius: var(--radius);
}

.payment-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.payment-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius);
}

.payment-card strong {
  font-size: 1.2rem;
}

.documents-layout {
  grid-template-columns: minmax(0, 520px);
  align-items: start;
}

.documents-upload-panel,
.documents-archive-panel {
  min-width: 0;
}

.documents-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.documents-metrics span {
  display: grid;
  gap: 1px;
  min-width: 74px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.documents-metrics strong {
  color: var(--ink);
  font-size: 1.04rem;
  line-height: 1;
}

.documents-metrics small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 176px;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.1), transparent),
    var(--surface-strong);
  color: var(--muted);
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.drop-zone:hover,
.drop-zone:focus-within {
  border-color: var(--teal);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.14), transparent),
    var(--surface-strong);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone [data-icon] {
  width: 34px;
  height: 34px;
  color: var(--teal);
}

.drop-zone strong {
  color: var(--ink);
}

.doc-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: stretch;
}

.doc-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: flex-start;
  gap: 12px;
  min-height: 126px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.doc-card.is-file {
  border-color: rgba(15, 118, 110, 0.22);
}

.doc-card-body {
  display: grid;
  gap: 7px;
  min-width: 0;
  flex: 1;
}

.doc-card-body p {
  margin: 0;
  line-height: 1.25;
}

.doc-card-topline,
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.doc-card-topline {
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.doc-category,
.doc-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--teal-strong);
  font-size: 0.72rem;
  font-weight: 800;
}

.doc-meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.doc-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.doc-card-body small,
.doc-card-body code {
  display: block;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.doc-card-body code {
  width: fit-content;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.74rem;
}

.doc-card .mini-button {
  flex: 0 0 auto;
}

.doc-card-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  min-width: 0;
}

.doc-card .doc-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  gap: 6px;
  text-decoration: none;
}

.doc-card .doc-action-button span:not([data-icon]) {
  font-size: 0.78rem;
  font-weight: 800;
}

.doc-card .doc-delete-button {
  flex: 0 0 34px;
}

.doc-icon {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--mint);
  color: var(--teal);
}

.advisor-profile {
  display: grid;
  align-content: start;
  gap: 14px;
}

.advisor-hero {
  display: grid;
  place-items: end start;
  min-height: 180px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 25% 15%, rgba(255, 255, 255, 0.7), transparent 28%),
    linear-gradient(135deg, #0f766e, #d95f48 62%, #d99a22);
  overflow: hidden;
}

.advisor-portrait {
  display: grid;
  place-items: center;
  width: 94px;
  height: 94px;
  margin: 0 0 16px 16px;
  border: 4px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  background: #fffdf8;
  color: var(--teal-strong);
  font-size: 1.5rem;
  font-weight: 900;
}

.advisor-profile p {
  color: var(--muted);
  line-height: 1.5;
}

.advisor-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.advisor-stats div {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.advisor-stats span {
  color: var(--muted);
  font-size: 0.8rem;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  min-height: 580px;
}

.chat-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.chat-toolbar h2 {
  margin: 2px 0 0;
  font-size: 1.1rem;
}

.chat-toolbar small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-top: 12px;
  padding-right: 6px;
}

.message {
  position: relative;
  max-width: min(680px, 82%);
  padding: 11px 13px;
  border-radius: var(--radius);
  line-height: 1.45;
}

.message p {
  margin: 0;
  padding-right: 30px;
}

.message-delete {
  position: absolute;
  top: 7px;
  right: 7px;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.72;
}

.message-delete:hover,
.message-delete:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  opacity: 1;
}

.message.consultant {
  align-self: flex-start;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.message.user {
  align-self: flex-end;
  background: var(--teal);
  color: #fff;
}

.message small {
  display: block;
  margin-top: 6px;
  color: inherit;
  opacity: 0.74;
}

.ticket-empty {
  margin: auto;
}

.chat-form {
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.chat-form input {
  flex: 1;
  min-width: 0;
}

.settings-panel {
  min-width: 0;
  width: 100%;
  max-width: none;
}

#settings {
  min-width: 0;
  width: 100%;
  max-width: none;
}

#settings.view.is-visible {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

#settings > .settings-panel {
  min-width: 0;
  width: 100%;
  max-width: none !important;
  box-sizing: border-box;
}

.settings-grid {
  min-width: 0;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  align-items: end;
}

.identity-profile-panel .settings-grid,
.fiscal-profile-panel .settings-grid {
  min-width: 0;
  width: 100%;
  max-width: none;
  grid-template-columns: minmax(0, 1fr) !important;
}

.identity-profile-panel .settings-grid > *,
.fiscal-profile-panel .settings-grid > * {
  min-width: 0;
  max-width: 100%;
}

.identity-profile-panel .settings-grid label,
.fiscal-profile-panel .settings-grid label {
  grid-column: 1 / -1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.fiscal-profile-panel .settings-grid label.checkbox-line {
  align-items: flex-start;
  justify-content: flex-start;
}

.identity-profile-panel .settings-grid input,
.identity-profile-panel .settings-grid select,
.fiscal-profile-panel .settings-grid input,
.fiscal-profile-panel .settings-grid select {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.identity-profile-panel .settings-grid button {
  width: 100%;
  justify-self: stretch;
}

[data-forfait-only][hidden],
[data-sport-limit-only][hidden] {
  display: none !important;
}

.forfait-limit-box,
.sport-limit-box {
  display: grid;
  grid-column: 1 / -1;
  gap: 6px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 8px;
  background: rgba(240, 253, 250, 0.84);
  color: var(--ink);
}

.sport-limit-box {
  border-color: rgba(37, 99, 235, 0.22);
  background: rgba(239, 246, 255, 0.9);
}

.forfait-limit-box strong,
.sport-limit-box strong {
  font-size: 0.9rem;
}

.forfait-limit-box small,
.sport-limit-box small {
  color: var(--muted);
  line-height: 1.45;
}

.fiscal-profile-panel .settings-grid label:nth-child(3) select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  height: 48px;
  padding: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-grid button {
  align-self: end;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

body.dark {
  color-scheme: dark;
  --bg: #151816;
  --surface: #1e241f;
  --surface-strong: #252b26;
  --ink: #f6f0e6;
  --muted: #aeb8ae;
  --line: #354037;
  --line-strong: #536056;
  --teal: #43b8a6;
  --teal-strong: #7bd6c8;
  --mint: #173a34;
  --amber: #f0b94a;
  --amber-strong: #ffd06a;
  --amber-soft: rgba(240, 185, 74, 0.14);
  --amber-soft-strong: rgba(240, 185, 74, 0.24);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

body.dark .alert-band {
  background: rgba(75, 55, 18, 0.75);
}

body.dark .alert-band span {
  color: #f4d48f;
}

body.dark .brand-mark {
  background: #fffdf8;
  color: #18201d;
}

body.dark .auth-card {
  background: rgba(30, 36, 31, 0.94);
}

body.dark .auth-preview {
  background: rgba(30, 36, 31, 0.72);
}

body.dark .auth-preview-top span,
body.dark .auth-preview-grid div,
body.dark .auth-preview-chart {
  background-color: #242c26;
}

body.dark .primary-action {
  color: #10201d;
}

@media (max-width: 1180px) {
  .auth-screen {
    grid-template-columns: 1fr;
  }

  .auth-card {
    justify-self: center;
  }

  .auth-preview {
    width: min(100%, 720px);
    min-height: 320px;
    justify-self: center;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .portal-plan-main,
  .portal-plan-facts,
  .portal-plan-features {
    grid-template-columns: 1fr;
  }

  .content-layout,
  .split-layout,
  .advisor-layout,
  .invoice-workbench {
    grid-template-columns: 1fr;
  }

  .client-management-layout {
    grid-template-columns: 1fr;
  }

  .client-edit-form,
  .client-main-box,
  .client-fiscal-box {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .service-grid {
    grid-template-columns: 1fr;
  }

  .service-grid.portal-plan-grid {
    grid-template-columns: 1fr;
  }

  .plan-comparison-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .invoice-archive-filters {
    grid-template-columns: 1fr 1fr;
  }

  .invoice-smart-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .invoice-builder {
    display: grid;
    grid-template-columns: 1fr;
    padding-right: 0;
  }

  .invoice-builder > .fpa-form,
  .invoice-live-summary {
    grid-column: 1;
  }

  .invoice-live-summary {
    position: static;
    width: 100%;
    right: auto;
    top: auto;
    max-height: none;
    overflow: visible;
  }

  .invoice-archive-workspace,
  .invoice-archive-controlbar {
    grid-template-columns: 1fr;
  }

  .invoice-archive-workspace {
    padding-right: 0;
  }

  .invoice-action-panel {
    position: static;
    width: 100%;
    max-height: none;
    overflow: visible;
  }

  .payment-grid,
  .tax-breakdown {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  .auth-screen {
    padding: 18px;
  }

  .auth-preview {
    display: none;
  }

  .app-shell {
    grid-template-columns: 76px minmax(0, calc(100vw - 76px));
  }

  .sidebar {
    position: sticky;
    top: 0;
    width: 76px;
    max-width: 76px;
    flex-wrap: nowrap;
    min-height: calc(100vh - 76px);
    height: calc(100vh - 76px);
    padding: 12px 8px;
    border-right: 1px solid #a76608;
    border-bottom: 0;
  }

  .brand {
    justify-content: center;
    padding-bottom: 10px;
  }

  .brand > div:not(.brand-mark) {
    display: none;
  }

  .main-nav {
    width: auto;
  }

  .nav-item {
    justify-content: center;
    width: 100%;
    min-width: 0;
    padding: 0 8px;
  }

  .nav-item > span:not([data-icon]):not(.nav-badge) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .nav-create-submenu {
    top: 0;
    left: calc(100% + 8px);
    width: 190px;
  }

  .advisor-mini {
    display: none;
  }

  .workspace {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .search-box {
    flex-basis: 100%;
  }

  .topbar-actions .primary-action {
    flex: 1 1 180px;
  }

  .account-chip {
    flex: 1 1 180px;
  }

  .fiscal-updates-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .fiscal-updates-banner a {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 620px) {
  .workspace {
    padding: 14px;
  }

  h1 {
    font-size: 2rem;
  }

  .dashboard-grid,
  .payment-grid,
  .tax-breakdown,
  .invoice-parties,
  .invoice-summary-grid,
  .settings-grid,
  .client-edit-form,
  .client-main-box,
  .client-fiscal-box,
  .form-row {
    grid-template-columns: 1fr;
  }

  .client-edit-form > label,
  .client-edit-form > .form-row,
  .client-edit-form > .client-fiscal-box,
  .client-main-box > label,
  .client-main-box > .form-row,
  .client-fiscal-box > .form-row,
  .client-fiscal-box > label {
    grid-column: 1 / -1;
  }

  .fiscal-profile-panel .settings-grid label:nth-child(1),
  .fiscal-profile-panel .settings-grid label:nth-child(3),
  .fiscal-profile-panel .settings-grid label:nth-child(5) {
    grid-column: 1 / -1;
  }

  .invoice-document-header,
  .invoice-line {
    align-items: flex-start;
    flex-direction: column;
  }

  .invoice-total {
    width: 100%;
    text-align: left;
  }

  .main-nav {
    gap: 2px;
  }

  .sync-banner {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .market-hero {
    margin-left: -14px;
    margin-right: -14px;
    padding: 32px 14px;
  }

  .service-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .service-detail-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .service-detail-columns {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 132px;
  }

  .primary-metric canvas {
    display: none;
  }

  .panel-header,
  .table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: stretch;
    width: 100%;
  }

  .toolbar-actions > * {
    flex: 1 1 130px;
  }

  .alert-band {
    align-items: flex-start;
  }

  .message {
    max-width: 94%;
  }
}

.fpa-form {
  display: grid;
  gap: 14px;
}

.fpa-fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px 16px;
  margin: 0;
  display: grid;
  gap: 10px;
}

.vat-lookup-wrap {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.reuse-invoice-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-top: 4px;
  border: 1px solid var(--line-strong, var(--line));
  border-left: 4px solid var(--teal, #155e9f);
  border-radius: 10px;
  background: var(--surface, #ffffff);
  color: var(--ink, #1a1a1a);
}

.reuse-invoice-banner > span {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--teal, #155e9f);
  color: #fff;
}

.reuse-invoice-banner > span svg {
  width: 16px;
  height: 16px;
}

.reuse-invoice-text {
  flex: 1;
  min-width: 0;
}

.reuse-invoice-text strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink, #1a1a1a);
}

.reuse-invoice-text small {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--ink, #333);
  opacity: 0.78;
}

.reuse-invoice-banner button {
  flex-shrink: 0;
  white-space: nowrap;
}

.vat-lookup-wrap input {
  flex: 1;
  min-width: 0;
}

.vat-lookup-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface, #f5f5f7);
  color: var(--text, inherit);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.vat-lookup-btn:hover:not(:disabled) {
  background: var(--accent-soft, #e5e7eb);
}

.vat-lookup-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.vat-lookup-btn svg {
  width: 14px;
  height: 14px;
}

.vat-lookup-hint {
  margin: 0;
  font-size: 0.82rem;
  padding: 6px 10px;
  border-radius: 6px;
}

.vat-lookup-hint.is-success {
  background: #e8f5e9;
  color: #1b5e20;
}

.vat-lookup-hint.is-error {
  background: #fdecea;
  color: #b71c1c;
}

.vat-lookup-hint.is-info {
  background: #e3f2fd;
  color: #0d47a1;
}

.fpa-fieldset > legend {
  padding: 0 8px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-strong);
}

.invoice-customer-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 18px;
  background: #f8fbfc;
}

.invoice-customer-search-panel {
  border-color: rgba(18, 92, 184, 0.2);
}

/* Versione inline (dentro al form Crea fattura) — niente panel container, integrata */
.invoice-customer-search-inline {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  margin: 8px 0;
  border: 1px solid var(--line-strong, var(--line));
  border-left: 4px solid var(--teal, #155e9f);
  border-radius: 10px;
  background: var(--surface, #fff);
}

.invoice-customer-search-heading .eyebrow {
  margin: 0 0 2px;
  font-size: 0.78rem;
}

.invoice-customer-search-heading h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
}

.invoice-customer-search-heading .muted-copy {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
}

.invoice-customer-results {
  display: grid;
  gap: 8px;
}

.invoice-customer-result,
.invoice-customer-hint {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.invoice-customer-result {
  cursor: pointer;
}

.invoice-customer-result:hover {
  border-color: rgba(18, 92, 184, 0.38);
  background: rgba(18, 92, 184, 0.06);
}

.invoice-customer-result svg,
.invoice-customer-hint svg {
  color: var(--purple-strong);
}

.invoice-customer-result strong,
.invoice-customer-hint strong {
  display: block;
}

.invoice-customer-result small,
.invoice-customer-hint small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.invoice-workbench {
  grid-template-columns: minmax(400px, 0.75fr) minmax(620px, 1.65fr);
  align-items: start;
}

.invoice-archive-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  padding: 18px;
  background: var(--surface-strong);
}

.invoice-archive-heading {
  align-items: flex-start;
}

.invoice-archive-heading .muted-copy {
  margin: 4px 0 0;
}

.invoice-month-strip {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
  overflow: visible;
  padding: 0;
  border-bottom: 0;
  background: transparent;
}

.invoice-month-card {
  display: grid;
  gap: 6px;
  min-width: 0;
  min-height: 74px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-bottom: 4px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: #00406f;
  font: inherit;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.invoice-month-card:hover,
.invoice-month-card:focus-visible {
  border-color: var(--teal);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.13);
  transform: translateY(-1px);
}

.invoice-month-card span {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-month-card strong {
  font-size: 0.82rem;
  color: var(--ink);
}

.invoice-month-card small {
  color: var(--teal-strong);
  font-weight: 800;
  white-space: normal;
  line-height: 1.2;
}

.invoice-month-card.has-documents {
  border-bottom-color: #0b5f59;
  background: #eefaf6;
}

.invoice-month-card.is-selected {
  border-color: var(--purple);
  border-bottom-color: var(--purple);
  background: #f1ecff;
  box-shadow: 0 10px 24px rgba(81, 64, 139, 0.16);
}

.invoice-month-card.is-selected span,
.invoice-month-card.is-selected small {
  color: var(--purple);
}

.invoice-smart-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}

.invoice-smart-filter {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 66px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.invoice-smart-filter span {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(21, 94, 159, 0.1);
  color: var(--purple);
}

.invoice-smart-filter .invoice-smart-copy {
  display: grid;
  place-items: initial;
  gap: 2px;
  width: auto;
  height: auto;
  min-width: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
}

.invoice-smart-filter strong {
  min-width: 0;
  font-size: 0.82rem;
  line-height: 1.18;
  overflow-wrap: anywhere;
  white-space: normal;
}

.invoice-smart-filter em {
  color: var(--muted);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.invoice-smart-filter small {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 900;
}

.invoice-smart-filter:hover,
.invoice-smart-filter:focus-visible,
.invoice-smart-filter.is-selected {
  border-color: var(--purple);
  box-shadow: 0 8px 18px rgba(21, 94, 159, 0.12);
}

.invoice-month-card,
.invoice-document-tabs button {
  cursor: pointer;
  touch-action: manipulation;
}

.invoice-smart-filter.is-selected {
  background: #eef6ff;
}

.invoice-smart-filter.is-selected small {
  background: var(--purple);
  color: #fff;
}

.invoice-archive-insight {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
}

.invoice-archive-insight article {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 78px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.invoice-archive-insight article > span {
  display: inline-grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--teal-strong);
}

.invoice-archive-insight small,
.invoice-archive-insight strong {
  display: block;
}

.invoice-archive-insight small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.invoice-archive-insight strong {
  margin-top: 3px;
  color: var(--ink);
  line-height: 1.2;
}

.invoice-archive-insight article.needs-attention {
  border-color: rgba(244, 184, 81, 0.55);
  background: #fff7e8;
}

.invoice-archive-insight article.needs-attention > span {
  background: rgba(244, 184, 81, 0.2);
  color: #8a5a00;
}

.invoice-archive-insight article.is-critical {
  border-color: rgba(211, 87, 70, 0.48);
  background: #fff0ec;
}

.invoice-archive-insight article.is-critical > span {
  background: rgba(211, 87, 70, 0.14);
  color: var(--danger);
}

.invoice-document-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0;
  border-bottom: 0;
}

.invoice-document-tabs button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--surface);
  color: var(--muted);
  padding: 0 12px;
  font-weight: 800;
}

.invoice-document-tabs button:first-child {
  border-top-left-radius: var(--radius);
}

.invoice-document-tabs button:last-child {
  border-top-right-radius: var(--radius);
}

.invoice-document-tabs button.is-selected {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}

.invoice-archive-filters {
  display: grid;
  grid-template-columns: minmax(140px, 0.65fr) minmax(260px, 1fr) minmax(130px, 0.55fr);
  gap: 10px;
  align-items: center;
}

.invoice-archive-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
  padding-right: 0;
}

.invoice-archive-workspace.has-action-panel {
  grid-template-columns: minmax(0, 1fr) minmax(330px, 380px);
  gap: 22px;
}

.invoice-archive-main {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.invoice-archive-controlbar {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(360px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.invoice-archive-search {
  min-width: 0;
}

.invoice-ledger-table {
  overflow-x: auto;
}

.invoice-ledger-table table {
  width: 100%;
  min-width: 720px;
  table-layout: auto;
}

.proforma-table table,
#purchase-invoices .invoice-ledger-table table {
  min-width: 880px;
}

.invoice-ledger-table th:nth-child(n) {
  width: auto;
}

.ricevute-col-stato {
  width: 110px;
  white-space: nowrap;
}

.ricevute-col-total {
  width: 120px;
  text-align: right;
  white-space: nowrap;
}

.invoice-ledger-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-strong);
}

.invoice-ledger-table th:nth-child(1) {
  width: 52px;
}

.invoice-ledger-table th:nth-child(2) {
  width: 19%;
}

.invoice-ledger-table th:nth-child(3) {
  width: 36%;
}

.invoice-ledger-table th:nth-child(4) {
  width: 17%;
}

.invoice-ledger-table th:nth-child(5) {
  width: 28%;
}

.invoice-ledger-table tbody tr:hover td {
  background: rgba(20, 159, 207, 0.06);
}

.invoice-ledger-table tbody tr.is-selected-row td {
  background: #eef6ff;
  box-shadow: inset 0 1px 0 rgba(21, 94, 159, 0.18), inset 0 -1px 0 rgba(21, 94, 159, 0.18);
}

.invoice-ledger-table tbody tr.is-selected-row td:first-child {
  box-shadow: inset 4px 0 0 var(--purple), inset 0 1px 0 rgba(21, 94, 159, 0.18), inset 0 -1px 0 rgba(21, 94, 159, 0.18);
}

.invoice-ledger-table tbody tr.is-checked-row td {
  background: rgba(15, 118, 110, 0.06);
}

.invoice-ledger-table tbody tr.is-overdue-row td {
  background: rgba(211, 87, 70, 0.06);
}

.invoice-ledger-table td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.invoice-ledger-table td small.danger-text,
.danger-text {
  color: var(--danger);
  font-weight: 900;
}

.invoice-money-cell {
  text-align: right;
}

.invoice-doc-cell,
.invoice-client-cell,
.invoice-money-cell,
.invoice-state-cell {
  vertical-align: middle;
}

.invoice-doc-cell strong,
.invoice-client-cell strong,
.invoice-money-cell strong {
  display: block;
  line-height: 1.25;
}

.invoice-client-cell small {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.invoice-money-cell small {
  white-space: normal;
}

.invoice-status-stack {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.invoice-paid-toggle {
  display: inline-grid;
  grid-template-columns: 18px auto;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.invoice-paid-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.invoice-paid-toggle > span {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-strong);
  color: transparent;
}

.invoice-paid-toggle small {
  margin: 0;
  color: inherit;
  font-weight: 850;
  line-height: 1;
}

.invoice-paid-toggle.is-paid {
  border-color: rgba(15, 118, 110, 0.36);
  background: rgba(15, 118, 110, 0.1);
  color: var(--teal-strong);
}

.invoice-paid-toggle.is-paid > span {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.invoice-sdi-state,
.invoice-email-state {
  display: grid;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
}

.invoice-sdi-state small,
.invoice-email-state small {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 0;
  overflow-wrap: anywhere;
}

.whatsapp-mini-button {
  color: #128c7e;
  border-color: rgba(18, 140, 126, 0.28);
  background: rgba(18, 140, 126, 0.08);
}

.whatsapp-mini-button:hover {
  color: #fff;
  background: #128c7e;
  border-color: #128c7e;
}

.sport-invoice-hint {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.08);
}

.sport-invoice-hint[hidden] {
  display: none;
}

.sport-invoice-hint svg {
  width: 20px;
  height: 20px;
  color: var(--teal);
}

.sport-invoice-hint strong,
.sport-invoice-hint small {
  display: block;
}

.sport-invoice-hint small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 900px) {
  .client-management-strip,
  .notification-item,
  .client-detail-lower {
    grid-template-columns: 1fr;
  }

  .client-detail-head {
    flex-direction: column;
  }

  .client-detail-actions,
  .admin-ops-actions {
    justify-content: stretch;
  }

  .client-detail-actions > *,
  .admin-ops-actions > * {
    flex: 1 1 180px;
  }

  .notification-item > span {
    width: 34px;
    height: 34px;
  }

  .sport-flow-main {
    align-items: stretch;
    flex-direction: column;
  }

  .sport-flow-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .sport-flow-grid,
  .sport-simulator-grid {
    grid-template-columns: 1fr;
  }

  .sport-simulator-head {
    align-items: stretch;
    flex-direction: column;
  }

  .sport-simulator-head label {
    flex-basis: auto;
  }

  .invoice-archive-controlbar,
  .invoice-archive-filters {
    grid-template-columns: 1fr;
  }

  .invoice-document-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .invoice-document-tabs button,
  .invoice-document-tabs button:first-child,
  .invoice-document-tabs button:last-child {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .invoice-ledger-table {
    overflow-x: visible;
    min-width: 0;
  }

  .table-panel.clean-ledger-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .invoice-ledger-table table,
  #purchase-invoices .invoice-ledger-table table,
  .proforma-table table,
  .draft-table table {
    width: 100%;
    min-width: 0;
  }

  .invoice-ledger-table table,
  .invoice-ledger-table thead,
  .invoice-ledger-table tbody,
  .invoice-ledger-table tr,
  .invoice-ledger-table th,
  .invoice-ledger-table td {
    display: block;
  }

  .invoice-ledger-table thead {
    position: absolute;
    left: -10000px;
  }

  /* annulla il pattern globale "table > tbody { width: max-content }" che
     altrimenti dimensiona il corpo tabella sul contenuto e sfora il viewport */
  .invoice-ledger-table table {
    overflow-x: visible;
  }

  .invoice-ledger-table tbody {
    display: block;
    width: auto;
    min-width: 0;
  }

  .invoice-ledger-table tbody tr {
    margin-bottom: 12px;
    padding: 14px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--surface-strong);
    box-shadow: 0 1px 2px rgba(41, 35, 26, 0.06);
  }

  .invoice-ledger-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .invoice-ledger-table tbody td {
    min-width: 0;
    padding: 0;
    border: 0;
    font-size: 0.9rem;
  }

  .invoice-ledger-table tbody td + td {
    margin-top: 9px;
  }

  .invoice-ledger-table tbody td.invoice-doc-cell {
    margin-top: 0;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--line);
  }

  .invoice-ledger-table tbody td.invoice-doc-cell strong {
    font-size: 1.02rem;
    color: var(--ink);
  }

  .invoice-ledger-table tbody td[data-label] {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    text-align: right;
    overflow-wrap: anywhere;
  }

  .invoice-ledger-table tbody td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 auto;
    text-align: left;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .invoice-ledger-table tbody td.invoice-money-cell strong {
    font-size: 1.05rem;
    color: var(--teal-strong);
  }

  .invoice-ledger-table tbody td[data-label="Descrizione"],
  .invoice-ledger-table tbody td[data-label="Stato"],
  .invoice-ledger-table tbody td[data-label="Azioni"],
  .invoice-ledger-table tbody td.ledger-stack,
  .invoice-ledger-table tbody td.invoice-state-cell {
    display: block;
    text-align: left;
  }

  .invoice-ledger-table tbody td[data-label="Descrizione"]::before,
  .invoice-ledger-table tbody td[data-label="Stato"]::before,
  .invoice-ledger-table tbody td[data-label="Azioni"]::before,
  .invoice-ledger-table tbody td.ledger-stack::before,
  .invoice-ledger-table tbody td.invoice-state-cell::before {
    display: block;
    margin-bottom: 5px;
  }

  /* celle "stack" (fornitore, cliente+descr, importi compositi): valore sotto */
  .invoice-ledger-table tbody td.ledger-stack > strong {
    display: block;
  }
  .invoice-ledger-table tbody td.ledger-stack > small {
    display: block;
    color: var(--muted);
  }

  .invoice-ledger-table .sent-invoice-status-stack,
  .invoice-ledger-table .invoice-status-stack {
    gap: 6px;
  }

  .invoice-ledger-table .row-actions,
  .invoice-ledger-table .proforma-row-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .invoice-ledger-table .row-actions .mini-button {
    width: 40px;
    height: 40px;
  }

  .invoice-ledger-table tbody td[colspan] {
    margin-top: 0;
    border-bottom: 0;
    padding: 0;
  }

  .invoice-ledger-table .select-column {
    width: auto;
  }
}

.invoice-number-link {
  color: var(--teal-strong) !important;
  font-weight: 800;
}

.due-warning {
  color: var(--danger);
  font-weight: 900;
}

.invoice-archive-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 18px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #f7faf9;
  color: var(--muted);
}

.invoice-archive-footer > strong {
  margin-right: auto;
  color: var(--ink);
}

.selection-summary {
  color: var(--teal-strong);
  font-weight: 900;
}

.select-column {
  width: 42px;
  text-align: center;
}

.select-column small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.select-column input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.invoice-viewer-drawer {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.invoice-viewer-hidden {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 960px;
}

.status-dot,
.sdi-mini {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  vertical-align: middle;
}

.status-dot::after,
.sdi-mini::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.sdi-mini {
  background: #eaf2ff;
  color: #2762b0;
}

.invoice-action-panel {
  position: sticky;
  top: 92px;
  width: 100%;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
  z-index: 4;
  display: grid;
  gap: 14px;
  min-height: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.1);
}

.invoice-action-panel[hidden] {
  display: none;
}

body:not(.invoice-creator-active) .invoice-live-summary {
  display: none;
}

body.invoice-creator-active .invoice-action-panel {
  display: none;
}

.invoice-action-panel h3,
.invoice-action-panel h4 {
  margin: 0;
}

.invoice-action-panel h3 {
  font-size: 1.03rem;
  line-height: 1.2;
}

.invoice-panel-client {
  display: inline-block;
  margin-top: 5px;
  color: #0b5fbd;
  font-size: 0.82rem;
  font-weight: 800;
}

.invoice-panel-block {
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.invoice-payment-line {
  display: grid;
  grid-template-columns: 0.9fr 1fr 1fr;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  color: var(--muted);
  font-size: 0.85rem;
}

.invoice-payment-line strong {
  color: var(--ink);
  text-align: right;
}

.invoice-panel-facts {
  display: grid;
  gap: 8px;
  margin: 0;
}

.invoice-panel-facts div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.invoice-panel-facts dt {
  color: var(--muted);
  font-weight: 800;
}

.invoice-panel-facts dd {
  margin: 0;
  font-weight: 900;
  text-align: right;
}

.sdi-esito-box {
  padding: 12px;
  border: 1px solid #ffd2ca;
  border-radius: 8px;
  background: #fff7f5;
}

.sdi-esito-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sdi-esito-note {
  margin: 0;
  color: #7e2b22;
  font-size: 0.84rem;
  font-weight: 750;
  line-height: 1.45;
}

.muted-line {
  display: block;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.invoice-panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 1180px) {
  .invoice-archive-workspace,
  .invoice-archive-workspace.has-action-panel {
    grid-template-columns: 1fr;
  }

  .invoice-action-panel {
    position: relative;
    top: auto;
    max-height: none;
    overflow: visible;
    box-shadow: none;
  }
}

@media (max-width: 680px) {
  .invoice-panel-actions {
    grid-template-columns: 1fr;
  }
}

body.pdf-preview-active {
  overflow: hidden;
}

body.pdf-preview-active::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10, 19, 32, 0.5);
}

body.pdf-preview-active #invoiceViewer {
  position: fixed;
  left: 50%;
  top: 16px;
  bottom: 16px;
  z-index: 90;
  width: min(980px, calc(100vw - 28px));
  transform: translateX(-50%);
  overflow: auto;
  padding: 14px;
  border-radius: 12px;
  background: #f4f7fb;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

#pdfPreviewClose {
  position: fixed;
  top: 24px;
  right: 28px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #1a1a1a;
  font-size: 28px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  transition: background-color .15s, color .15s, transform .15s;
}
#pdfPreviewClose:hover {
  background: #b3261e;
  color: #fff;
  transform: scale(1.05);
}
@media (max-width: 680px) {
  #pdfPreviewClose {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    font-size: 24px;
  }
}

body.pdf-preview-active #invoiceViewer .invoice-document {
  margin: 0 auto;
  max-width: 860px;
}

body.pdf-preview-active #invoiceViewer .fpa-document {
  gap: 12px;
  padding: 18px;
  font-size: 0.84rem;
}

body.pdf-preview-active #invoiceViewer .fpa-header {
  padding-bottom: 12px;
}

body.pdf-preview-active #invoiceViewer .fpa-section,
body.pdf-preview-active #invoiceViewer .fpa-party {
  padding: 10px 12px;
}

body.pdf-preview-active #invoiceViewer .fpa-table th,
body.pdf-preview-active #invoiceViewer .fpa-table td {
  padding: 6px 8px;
}

body.pdf-preview-active #invoiceViewer .fpa-totals-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.invoice-panel-actions button {
  min-height: 44px;
}

.invoice-sdi-action {
  background: #f4b851;
  border-color: #f4b851;
  color: #24170a;
}

.danger-action {
  border-color: #ef7676;
  color: var(--danger);
}

.invoice-create-panel {
  max-width: none;
  display: grid;
  gap: 14px;
  padding: 20px;
  background: var(--surface-strong);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
  overflow: visible;
}

.invoice-create-panel.is-highlighted {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.16), var(--shadow);
}

.invoice-simulator-layout {
  display: block;
  max-width: 1180px;
  margin: 0 auto;
}

.invoice-preset-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 auto 16px;
  max-width: 980px;
  padding: 10px 14px;
  background: rgba(15, 118, 110, 0.06);
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 10px;
}

.invoice-preset-bar .invoice-preset-label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #0f766e;
  margin-right: 4px;
}

.invoice-preset-bar .mini-button {
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #d5e1ea;
  background: #fff;
  cursor: pointer;
  font-weight: 700;
  color: #0a1d33;
}

.invoice-preset-bar .mini-button:hover {
  border-color: #0f766e;
  color: #0f766e;
}

.invoice-simulator-form-panel {
  display: none !important;
}

.pdf-editable {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 3px 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-family: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  text-align: inherit;
  cursor: text;
}

.pdf-sheet.is-proforma .pdf-editable {
  border-color: transparent;
  background: transparent;
}

.pdf-editable-select,
.pdf-editable-toggle input,
.pdf-editable[type="checkbox"] {
  cursor: pointer;
}

.pdf-editable:hover {
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.05);
}

.pdf-editable:focus {
  outline: none;
  border-color: #0f766e;
  background: #ecfdf5;
}

.pdf-sheet.is-proforma .pdf-editable:hover {
  border-color: rgba(180, 83, 9, 0.4);
  background: rgba(180, 83, 9, 0.06);
}

.pdf-sheet.is-proforma .pdf-editable:focus {
  border-color: #b45309;
  background: #fffbeb;
}

.pdf-editable-block {
  display: block;
  min-height: 1.4em;
  resize: none;
  overflow: hidden;
}

.pdf-editable-strong {
  font-weight: 800;
}

.pdf-editable-h3 {
  width: auto !important;
  min-width: 140px;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.15;
}

.pdf-editable-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: none;
  padding-right: 6px;
  cursor: pointer;
}

.pdf-editable-select:hover,
.pdf-editable-select:focus {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) center, calc(100% - 9px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 22px;
}

.pdf-editable-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.pdf-editable-toggle input {
  width: 14px;
  height: 14px;
  accent-color: #0f766e;
}

.pdf-edit-hint {
  margin: 0 auto 10px;
  max-width: 1120px;
  padding: 8px 14px;
  border: 1px solid rgba(15, 118, 110, 0.25);
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.06);
  color: #0f766e;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.invoice-top-actionbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  max-width: 1120px;
  margin: 0 auto 14px;
  padding: 10px;
  border: 1px solid #dce6ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.invoice-top-functions,
.invoice-top-document-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.invoice-top-functions {
  flex: 1 1 520px;
}

.invoice-top-document-actions {
  flex: 0 1 auto;
  justify-content: flex-end;
}

.invoice-top-functions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d8e3ec;
  border-radius: 7px;
  background: #f8fbfd;
  color: #0a1d33;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.invoice-top-functions button:hover {
  border-color: #0f766e;
  background: #edf8f4;
  color: #0f766e;
}

.invoice-top-functions [data-icon],
.invoice-top-document-actions [data-icon] {
  width: 15px;
  height: 15px;
}

.pdf-logo-button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 190px;
  min-height: 96px;
  padding: 12px 14px;
  border: 2px dashed #d4a843;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff8df 0%, #ffffff 62%);
  color: #7a4f00;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 850;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 10px 22px rgba(212, 168, 67, 0.16);
}

.pdf-logo-button:hover {
  border-color: #b87900;
  background: linear-gradient(135deg, #fff1bf 0%, #ffffff 70%);
  color: #7a4f00;
  transform: translateY(-1px);
}

.pdf-logo-button.has-logo {
  width: 190px;
  min-height: 96px;
  max-width: 220px;
  padding: 8px;
  border: 1px solid #dce6ef;
  background: #fff;
  color: #526579;
  box-shadow: none;
}

.pdf-logo-button.has-logo:hover {
  border-color: #0f766e;
  background: rgba(15, 118, 110, 0.04);
  color: #0f766e;
}

.pdf-logo-button.has-logo img {
  max-width: 100%;
  max-height: 58px;
  object-fit: contain;
}

.pdf-logo-button.has-logo span {
  font-size: 0.68rem;
  font-weight: 900;
}

.pdf-logo-button [data-icon] {
  width: 24px;
  height: 24px;
}

.pdf-logo-placeholder {
  position: relative;
}

.pdf-logo-placeholder strong {
  font-size: 0.92rem;
  line-height: 1;
}

.pdf-logo-placeholder small {
  display: block;
  color: #8a6a24;
  font-size: 0.68rem;
  line-height: 1.25;
}

.pdf-logo-upload-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #d4a843;
  color: #0a1d33;
}

.pdf-field-label {
  display: block;
  margin: 6px 0 2px;
  color: #6b7d92;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.invoice-create-hero {
  display: none;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 20px 22px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #eef8f5 58%, #f7efe2 100%);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

.invoice-create-simulator-view > .table-toolbar {
  max-width: 1180px;
  margin: 0 auto 18px;
  align-items: center;
}

.invoice-create-hero h2 {
  margin: 0 0 6px;
  font-size: clamp(1.45rem, 2vw, 2rem);
}

.invoice-create-hero p:not(.eyebrow) {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
}

.invoice-create-status {
  display: grid;
  gap: 4px;
  min-width: 180px;
  padding: 14px 16px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background: #fff;
}

.invoice-create-status span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-create-status strong {
  color: var(--teal-strong);
  font-size: 1.35rem;
}

.invoice-simulator-form-panel {
  display: none !important;
}

.invoice-simulator-form-panel.is-highlighted {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.16), var(--shadow);
}

.invoice-simulator-form-panel input,
.invoice-simulator-form-panel select {
  min-height: 43px;
  border-radius: 7px;
  background: #fff;
}

.invoice-form-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 6px;
}

.invoice-form-progress span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 999px;
  background: #f2f4f7;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.invoice-form-progress span.is-ready {
  background: #e4f6f1;
  color: var(--teal-strong);
}

.invoice-pdf-stage {
  display: grid;
  gap: 14px;
}

.invoice-pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px 14px;
  border: 1px solid #dbe6ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.08);
}

.invoice-pdf-toolbar > span {
  color: var(--teal);
}

.invoice-pdf-toolbar .secondary-action {
  margin-left: auto;
}

.invoice-pdf-preview {
  min-height: 760px;
  padding: 0 0 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: auto;
}

.pdf-sheet {
  position: relative;
  width: min(100%, 1120px);
  min-height: 980px;
  margin: 0 auto;
  padding: 42px 46px;
  box-sizing: border-box;
  border: 1px solid #dfe7ef;
  border-radius: 8px;
  background:
    linear-gradient(90deg, #0f766e 0 32%, #d4a843 32% 48%, #0a1d33 48% 100%) top left / 100% 8px no-repeat,
    #fff;
  color: #0a1d33;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.14);
  overflow: hidden;
}

.pdf-sheet.is-proforma {
  border-color: #b45309;
}

.pdf-sheet.is-credit-note {
  border-color: #0f766e;
}

.pdf-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-28deg);
  font-size: 9rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: rgba(180, 83, 9, 0.09);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  z-index: 0;
}

.pdf-sheet > *:not(.pdf-watermark) {
  position: relative;
  z-index: 1;
}

.pdf-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 4px 0 24px;
  border-bottom: 2px solid #0f766e;
}

.pdf-sheet.is-proforma .pdf-sheet-header {
  border-bottom-color: #b45309;
}

.pdf-sheet.is-credit-note .pdf-sheet-header {
  border-bottom-color: #0f766e;
}

.pdf-sheet-header-side {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.pdf-proforma-badge {
  padding: 6px 14px;
  border: 2px solid #b45309;
  border-radius: 4px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.pdf-credit-badge {
  padding: 6px 14px;
  border: 2px solid #0f766e;
  border-radius: 4px;
  background: #ecfdf5;
  color: #0f766e;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.pdf-credit-watermark {
  color: rgba(15, 118, 110, 0.08);
  font-size: 6.8rem;
}

.pdf-credit-disclaimer {
  border-color: #99f6e4;
  border-left-color: #0f766e;
  background: #f0fdfa;
  color: #134e4a;
}

.pdf-credit-disclaimer strong {
  color: #115e59;
}

.pdf-line-note {
  display: block;
  margin-top: 4px;
  color: #6b7d92;
  font-size: 0.72rem;
}

.pdf-iban {
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.pdf-legal-disclaimer {
  margin: 24px 0 0;
  padding: 14px 16px;
  border: 1px solid #fcd34d;
  border-left: 4px solid #b45309;
  border-radius: 6px;
  background: #fffbeb;
  color: #78350f;
  font-size: 0.82rem;
  line-height: 1.5;
}

.pdf-legal-disclaimer strong {
  display: block;
  margin-bottom: 4px;
  color: #7c2d12;
}

.pdf-kicker,
.pdf-party-grid span,
.pdf-summary span {
  margin: 0 0 6px;
  color: #6b7d92;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.pdf-sheet h3 {
  margin: 0 0 8px;
  font-size: 1.7rem;
}

.pdf-doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: #526579;
  font-size: 0.82rem;
  font-weight: 800;
}

.pdf-doc-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 2px 8px;
  border: 1px solid #dce6ef;
  border-radius: 999px;
  background: #f8fbfd;
}

.pdf-doc-meta .pdf-editable {
  width: 138px !important;
}

.pdf-logo-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 2px solid #0f766e;
  border-radius: 50%;
  color: #0f766e;
  font-weight: 900;
}

.pdf-party-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.pdf-party-grid > div {
  display: grid;
  gap: 3px;
  padding: 14px 16px;
  border: 1px solid #dce6ef;
  border-radius: 6px;
  background: linear-gradient(180deg, #f8fbfd, #ffffff);
  font-size: 0.82rem;
  line-height: 1.3;
}

.pdf-party-grid > div span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7d90;
  margin-bottom: 2px;
}

.pdf-party-grid > div strong {
  font-size: 0.92rem !important;
}

.pdf-party-action {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  margin: 2px 0 6px;
  padding: 0 12px;
  border: 1px solid #d5e1ea;
  border-radius: 7px;
  background: #fff;
  color: #0a1d33;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.pdf-party-action:hover {
  border-color: #0f766e;
  color: #0f766e;
}

.pdf-party-action [data-icon] {
  width: 16px;
  height: 16px;
}

.pdf-party-grid strong,
.pdf-summary strong {
  font-size: 1rem;
}

.pdf-party-grid small,
.pdf-summary small,
.pdf-note {
  color: #526579;
  line-height: 1.45;
}

.pdf-payment-note {
  display: block;
  margin-top: 8px;
  font-weight: 700;
}

.pdf-due-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pdf-due-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e6fffb;
  color: #0f766e;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.pdf-line-description {
  min-height: 42px;
  resize: vertical;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.pdf-lines {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  margin: 20px 0 28px;
  border: 1px solid #dce6ef;
  border-radius: 8px;
  font-size: 0.78rem;
  overflow: hidden;
}

.pdf-lines th,
.pdf-lines td {
  padding: 10px 8px;
  border-bottom: 1px solid #dce6ef;
  text-align: right;
  overflow-wrap: anywhere;
}

.pdf-lines th:first-child,
.pdf-lines td:first-child {
  text-align: left;
}

.pdf-lines th:nth-child(1),
.pdf-lines td:nth-child(1) {
  width: 27%;
}

.pdf-lines th:nth-child(2),
.pdf-lines td:nth-child(2) {
  width: 10%;
}

.pdf-lines th:nth-child(3),
.pdf-lines td:nth-child(3) {
  width: 7%;
}

.pdf-lines th:nth-child(4),
.pdf-lines td:nth-child(4) {
  width: 7%;
}

.pdf-lines th:nth-child(5),
.pdf-lines td:nth-child(5) {
  width: 11%;
}

.pdf-lines th:nth-child(6),
.pdf-lines td:nth-child(6) {
  width: 8%;
}

.pdf-lines th:nth-child(7),
.pdf-lines td:nth-child(7) {
  width: 8%;
}

.pdf-lines th:nth-child(8),
.pdf-lines td:nth-child(8) {
  width: 8%;
}

.pdf-lines th:nth-child(9),
.pdf-lines td:nth-child(9) {
  width: 11%;
}

.pdf-lines th:nth-child(10),
.pdf-lines td:nth-child(10) {
  width: 3%;
}

.pdf-sheet:not(.has-line-codes) .pdf-col-code,
.pdf-sheet:not(.has-line-units) .pdf-col-unit,
.pdf-sheet:not(.has-line-discounts) .pdf-col-discount {
  display: none;
}

.pdf-lines thead th {
  color: #0a1d33;
  background: #eef8f5;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.pdf-lines tbody tr:nth-child(even) td {
  background: #fbfdfe;
}

.pdf-option-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -10px 0 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #dce6ef;
}

.pdf-option-chips button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid #d8e3ec;
  border-radius: 999px;
  background: #f7fafc;
  color: #0a1d33;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.pdf-option-chips button:hover {
  border-color: #0f766e;
  background: #edf8f4;
  color: #0f766e;
}

.pdf-option-chips [data-icon] {
  width: 14px;
  height: 14px;
}

.pdf-line-remove {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid #d8e3ec;
  border-radius: 7px;
  background: #fff;
  color: #b91c1c;
  cursor: pointer;
}

.pdf-line-remove:disabled {
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 0.55;
}

.pdf-line-remove [data-icon] {
  width: 15px;
  height: 15px;
}

.pdf-inps-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 29, 51, 0.45);
}

.pdf-inps-dialog {
  width: min(620px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 22px;
  border: 1px solid #d8e3ec;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(10, 29, 51, 0.26);
}

.pdf-inps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.pdf-inps-grid label {
  display: grid;
  gap: 6px;
  color: #526579;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.pdf-inps-grid input {
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #cfdbe7;
  border-radius: 6px;
  color: #0a1d33;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 800;
}

.pdf-inps-result {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #dce6ef;
  border-radius: 8px;
  background: #f7fafc;
}

.pdf-inps-result div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.pdf-inps-result span {
  color: #526579;
}

.pdf-inps-result strong {
  text-align: right;
  overflow-wrap: anywhere;
}

.pdf-inps-actions {
  margin-top: 18px;
}

/* === Modal Dati Fattura PA — layout dedicato (sostituisce pdf-inps-grid quando applicato) === */
.pdf-pa-dialog {
  width: min(760px, 100%);
}

.pdf-pa-intro {
  margin-top: 4px;
  text-transform: none;
  font-weight: 400;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #526579;
}

.pdf-pa-section {
  margin: 18px 0 8px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f7fafc;
}

.pdf-pa-section[hidden] {
  display: none;
}

.pdf-pa-section-title {
  margin: 0 0 12px;
  padding: 0;
  color: #0a1d33;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pdf-pa-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.pdf-pa-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.pdf-pa-field-wide {
  grid-column: 1 / -1;
}

.pdf-pa-label {
  display: block;
  color: #0a1d33;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

.pdf-pa-label em {
  color: #6b7c8e;
  font-style: normal;
  font-weight: 500;
  font-size: 0.78rem;
}

.pdf-pa-field input,
.pdf-pa-field select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #cfdbe7;
  border-radius: 6px;
  background: #fff;
  color: #0a1d33;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  text-transform: none;
}

.pdf-pa-field input:focus,
.pdf-pa-field select:focus {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
  border-color: #2563eb;
}

.pdf-pa-hint {
  display: block;
  margin: 2px 0 0;
  color: #6b7c8e;
  font-size: 0.78rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.4;
}

.pdf-pa-footnote {
  margin: 10px 2px 0;
}

.pdf-pa-footnote .muted-copy {
  text-transform: none;
  font-weight: 400;
}

@media (max-width: 600px) {
  .pdf-pa-grid {
    grid-template-columns: 1fr;
  }
}

.invoice-sdi-preflight-dialog {
  width: min(760px, 100%);
}

.invoice-sdi-preflight-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 850;
}

.invoice-sdi-preflight-summary span {
  color: inherit;
  font-size: 0.82rem;
  white-space: nowrap;
}

.invoice-sdi-preflight-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.invoice-sdi-preflight-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid #dce6ef;
  border-radius: 8px;
  background: #fff;
}

.invoice-sdi-preflight-item > [data-icon] {
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.invoice-sdi-preflight-item strong {
  display: block;
  margin-bottom: 3px;
}

.invoice-sdi-preflight-item small {
  display: block;
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.invoice-sdi-preflight-item.is-ok {
  border-color: rgba(16, 118, 112, 0.22);
  background: rgba(16, 118, 112, 0.05);
}

.invoice-sdi-preflight-item.is-ok > [data-icon] {
  color: var(--teal-strong);
}

.invoice-sdi-preflight-item.is-warning {
  border-color: rgba(188, 130, 18, 0.28);
  background: #fff8e8;
}

.invoice-sdi-preflight-item.is-warning > [data-icon] {
  color: #8a5a08;
}

.invoice-sdi-preflight-item.is-error {
  border-color: rgba(186, 47, 47, 0.28);
  background: #fff0ee;
}

.invoice-sdi-preflight-item.is-error > [data-icon] {
  color: var(--danger);
}

@media (max-width: 760px) {
  .invoice-sdi-preflight-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .invoice-sdi-preflight-summary span {
    white-space: normal;
  }

  .invoice-sdi-preflight-list {
    grid-template-columns: 1fr;
  }
}

.pdf-client-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 29, 51, 0.45);
}

.pdf-client-dialog {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 22px;
  border: 1px solid #d8e3ec;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(10, 29, 51, 0.26);
}

.pdf-client-search {
  margin: 18px 0 12px;
}

.pdf-client-results {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.pdf-client-result {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid #dce6ef;
  border-radius: 8px;
  background: #fff;
  color: #0a1d33;
  text-align: left;
  cursor: pointer;
}

.pdf-client-result:hover {
  border-color: #0f766e;
  background: #f2fbf8;
}

.pdf-client-result > [data-icon] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  color: #0f766e;
}

.pdf-client-result span:last-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.pdf-client-result strong,
.pdf-client-result small,
.pdf-client-result em {
  overflow-wrap: anywhere;
}

.pdf-client-result small {
  color: #526579;
}

.pdf-client-result em {
  color: #6b7d8f;
  font-style: normal;
  font-size: 0.82rem;
}

.pdf-client-actions {
  margin-top: 16px;
}

@media (max-width: 760px) {
  .pdf-inps-grid {
    grid-template-columns: 1fr;
  }
}

.pdf-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 0.58fr);
  gap: 20px;
  align-items: start;
  margin-top: 24px;
}

.pdf-exemption {
  display: grid;
  gap: 4px;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid #dce6ef;
  border-radius: 6px;
  background: #f8fbfd;
}

.pdf-summary dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.pdf-summary dl div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
  padding: 8px 0;
  border-bottom: 1px solid #dce6ef;
}

.pdf-summary dt {
  min-width: 0;
  color: #526579;
}

.pdf-summary dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
  overflow-wrap: anywhere;
}

.pdf-total {
  padding: 12px !important;
  border: 0 !important;
  border-radius: 6px;
  background: #0f766e;
  color: #fff;
}

.pdf-total dt {
  color: rgba(255, 255, 255, 0.82);
}

.pdf-note {
  margin-top: 38px;
  padding: 12px 14px;
  border: 1px solid #cde9e5;
  border-left: 4px solid #0f766e;
  border-radius: 6px;
  background: #f0fdfa;
  color: #0f4f4a;
  font-size: 0.82rem;
  font-weight: 700;
}

.invoice-list-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.filter-pill {
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.filter-pill.is-selected {
  background: #7184a3;
  color: #fff;
}

.filter-pill:hover,
.filter-pill:focus-visible {
  border-color: rgba(15, 118, 110, 0.26);
  background: #fff;
  color: var(--teal-strong);
  outline: none;
}

.filter-pill.is-selected:hover,
.filter-pill.is-selected:focus-visible {
  background: #5f728f;
  color: #fff;
}

.quick-filter-menu {
  position: fixed;
  z-index: 1300;
  display: grid;
  gap: 4px;
  width: min(250px, calc(100vw - 24px));
  max-height: 320px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
}

.quick-filter-menu button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
}

.quick-filter-menu button:hover,
.quick-filter-menu button.is-selected {
  background: rgba(15, 118, 110, 0.09);
  color: var(--teal-strong);
}

.clean-ledger-panel {
  display: grid;
  gap: 18px;
}

.sent-invoice-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.sent-invoice-summary article {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.sent-invoice-summary span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sent-invoice-summary strong {
  color: var(--ink);
  font-size: 1.25rem;
}

.invoice-row-actions {
  margin-top: 8px;
}

.danger-mini-button {
  color: var(--danger);
}

.invoice-page-search {
  max-width: 420px;
}

.proforma-table-panel {
  padding: 18px;
}

.proforma-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.proforma-table-toolbar .invoice-page-search {
  flex: 1;
  max-width: 480px;
  margin: 0;
}

.proforma-columns-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.proforma-columns-button [data-icon] {
  width: 16px;
  height: 16px;
}

.proforma-table table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.proforma-table thead th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  background: transparent;
  color: var(--muted, #6b7d92);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
}

.proforma-table tbody td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--line, #eef2f6);
  background: #fff;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.proforma-table tbody tr:hover td {
  background: #f8fafc;
}

.proforma-col-check {
  width: 38px;
}

.proforma-col-total {
  width: 128px;
  text-align: right;
  white-space: nowrap;
}

.proforma-col-actions {
  width: 146px;
  white-space: nowrap;
  text-align: right;
}

.proforma-table th:nth-child(2),
.proforma-table td:nth-child(2) {
  width: 110px;
}

.proforma-table th:nth-child(3),
.proforma-table td:nth-child(3) {
  width: 19%;
}

.proforma-table th:nth-child(4),
.proforma-table td:nth-child(4) {
  width: auto;
}

.proforma-table th:nth-child(5),
.proforma-table td:nth-child(5) {
  width: 116px;
}

.proforma-row-buttons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  width: 100%;
}

.proforma-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  background: #fff;
  color: var(--ink, #0a1d33);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.proforma-icon-button:hover {
  border-color: rgba(15, 118, 110, 0.45);
  background: rgba(15, 118, 110, 0.06);
  color: #0f766e;
}

.proforma-icon-button [data-icon] {
  width: 16px;
  height: 16px;
}

.proforma-menu-wrap {
  position: relative;
  display: inline-block;
}

.proforma-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.18);
}

.proforma-menu[hidden] {
  display: none;
}

.proforma-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink, #0a1d33);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.proforma-menu button:hover {
  background: #f1f5f9;
}

.proforma-menu button [data-icon] {
  width: 16px;
  height: 16px;
  color: var(--muted, #6b7d92);
}

.proforma-menu-danger {
  color: #b91c1c !important;
}

.proforma-menu-danger [data-icon] {
  color: #b91c1c !important;
}

.proforma-menu-danger:hover {
  background: #fef2f2 !important;
}

@media (max-width: 1100px) {
  .invoice-simulator-layout,
  .pdf-party-grid,
  .pdf-summary,
  .invoice-create-hero {
    grid-template-columns: 1fr;
  }

  .sent-invoice-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .sent-invoice-summary article {
    padding: 11px 12px;
  }

  .invoice-simulator-form-panel {
    position: static;
  }

  .invoice-pdf-preview {
    padding: 12px;
  }

  .invoice-top-actionbar {
    align-items: stretch;
  }

  .invoice-top-functions,
  .invoice-top-document-actions {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .pdf-sheet {
    min-height: 0;
    padding: 22px;
  }
}

@media (max-width: 720px) {
  #sent-invoices .table-toolbar,
  #invoices .table-toolbar {
    align-items: stretch;
    gap: 10px;
  }

  #sent-invoices .table-toolbar h2,
  #invoices .table-toolbar h2 {
    font-size: 1.22rem;
  }

  #sent-invoices .table-toolbar .muted-copy,
  #invoices .table-toolbar .muted-copy {
    display: none;
  }

  #sent-invoices .clean-ledger-panel,
  #invoices .invoice-archive-panel {
    gap: 12px;
    padding: 12px;
  }

  .invoice-list-filters {
    flex-wrap: nowrap;
    gap: 8px;
    margin: 0 -4px 12px;
    padding: 0 4px 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .filter-pill {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 0 11px;
    font-size: 0.78rem;
  }

  .sent-invoice-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .sent-invoice-summary article {
    padding: 8px 10px;
  }

  .sent-invoice-summary span {
    font-size: 0.65rem;
  }

  .sent-invoice-summary strong {
    font-size: 1rem;
  }

  #sent-invoices .invoice-page-search {
    max-width: none;
  }

  #sent-invoices .invoice-ledger-table tbody,
  #invoices .invoice-ledger-table tbody {
    gap: 8px;
  }

  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row,
  #invoices .invoice-ledger-table tbody tr.invoice-archive-row {
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 8px;
    box-shadow: none;
  }

  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 6px 10px;
  }

  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row td,
  #invoices .invoice-ledger-table tbody tr.invoice-archive-row td {
    min-width: 0;
    margin-top: 0;
  }

  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row td[data-label]::before,
  #invoices .invoice-ledger-table tbody tr.invoice-archive-row td[data-label]::before,
  #invoices .invoice-ledger-table tbody tr.invoice-archive-row .select-column::before {
    display: none;
  }

  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row .invoice-doc-cell {
    grid-column: 1;
    padding: 0;
    border: 0;
  }

  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row .invoice-doc-cell strong,
  #invoices .invoice-ledger-table tbody tr.invoice-archive-row .invoice-doc-cell strong {
    font-size: 0.94rem;
  }

  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row .invoice-doc-cell small,
  #invoices .invoice-ledger-table tbody tr.invoice-archive-row .invoice-doc-cell small,
  #invoices .invoice-ledger-table tbody tr.invoice-archive-row .invoice-client-cell small {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 2px;
    font-size: 0.72rem;
  }

  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row td[data-label="Importo"] {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
    white-space: nowrap;
  }

  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row td[data-label="Importo"] strong,
  #invoices .invoice-ledger-table tbody tr.invoice-archive-row .invoice-money-cell strong {
    font-size: 0.96rem;
  }

  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row td[data-label="Cliente"] {
    grid-column: 1 / -1;
    display: block;
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 800;
    text-align: left;
  }

  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row td[data-label="Descrizione"],
  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row td[data-label="Data"] {
    display: none;
  }

  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row .invoice-state-cell,
  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row td[data-label="Azioni"] {
    grid-column: 1 / -1;
    display: block;
    text-align: left;
  }

  #sent-invoices .invoice-ledger-table tbody tr.sent-invoice-row .invoice-state-cell {
    padding-top: 6px;
    border-top: 1px solid var(--line);
  }

  #sent-invoices .sent-invoice-status-stack {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
  }

  #sent-invoices .sent-invoice-status-stack small {
    flex: 1 1 100%;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.68rem;
  }

  #sent-invoices .sent-invoice-status-stack small + small {
    display: none;
  }

  #sent-invoices .row-actions {
    display: grid;
    grid-template-columns: repeat(6, 32px);
    justify-content: start;
    gap: 6px;
  }

  #sent-invoices .row-actions .mini-button,
  #invoices .invoice-row-actions .mini-button {
    width: 32px;
    height: 32px;
    border-radius: 7px;
  }

  #invoices .invoice-ledger-table tbody tr.invoice-archive-row {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    align-items: start;
    gap: 6px 8px;
  }

  #invoices .invoice-ledger-table tbody tr.invoice-archive-row .select-column {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 24px;
    padding-top: 2px;
  }

  #invoices .invoice-ledger-table tbody tr.invoice-archive-row .select-column input {
    width: 17px;
    height: 17px;
  }

  #invoices .invoice-ledger-table tbody tr.invoice-archive-row .invoice-doc-cell {
    grid-column: 2;
    grid-row: 1;
    padding: 0;
    border: 0;
  }

  #invoices .invoice-ledger-table tbody tr.invoice-archive-row .invoice-money-cell {
    grid-column: 3;
    grid-row: 1;
    text-align: right;
    white-space: nowrap;
  }

  #invoices .invoice-ledger-table tbody tr.invoice-archive-row .invoice-money-cell small {
    display: none;
  }

  #invoices .invoice-ledger-table tbody tr.invoice-archive-row .invoice-client-cell {
    grid-column: 2 / -1;
    grid-row: 2;
    display: block;
    text-align: left;
  }

  #invoices .invoice-ledger-table tbody tr.invoice-archive-row .invoice-client-cell strong {
    font-size: 0.84rem;
  }

  #invoices .invoice-ledger-table tbody tr.invoice-archive-row .invoice-state-cell {
    grid-column: 1 / -1;
    grid-row: 3;
    display: block;
    padding-top: 6px;
    border-top: 1px solid var(--line);
    text-align: left;
  }

  #invoices .invoice-status-stack {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
  }

  #invoices .invoice-paid-toggle {
    grid-template-columns: 16px auto;
    min-height: 28px;
    padding: 4px 7px;
  }

  #invoices .invoice-paid-toggle > span {
    width: 16px;
    height: 16px;
  }

  #invoices .invoice-paid-toggle small,
  #invoices .status-pill {
    font-size: 0.68rem;
  }

  #invoices .invoice-sdi-state,
  #invoices .invoice-email-state {
    display: flex;
    min-width: 0;
    gap: 4px;
  }

  #invoices .invoice-sdi-state small,
  #invoices .invoice-email-state small {
    display: none;
  }

  #invoices .invoice-row-actions {
    display: flex;
    gap: 5px;
    margin-top: 0;
    margin-left: auto;
  }
}

.invoice-step-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.invoice-step-strip button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7faf9;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.invoice-step-strip button.is-complete {
  border-color: rgba(15, 118, 110, 0.34);
  background: #eefaf6;
  color: var(--teal-strong);
}

.invoice-step-strip button.needs-work {
  border-color: rgba(244, 184, 81, 0.72);
  background: #fff7e8;
  color: #7a5208;
}

.invoice-step-strip strong {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  font-size: 0.78rem;
}

.invoice-helper-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border: 1px solid var(--line-strong, var(--line));
  border-left: 4px solid var(--teal, #155e9f);
  border-radius: var(--radius);
  background: var(--surface, #ffffff);
  color: var(--ink, #1a1a1a);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.invoice-helper-main {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.invoice-helper-main > span {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--teal, #155e9f);
  color: #fff;
}

.invoice-helper-main > span svg {
  width: 20px;
  height: 20px;
}

.invoice-helper-main strong,
.invoice-helper-main small {
  display: block;
}

.invoice-helper-main strong {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink, #1a1a1a);
  line-height: 1.3;
}

.invoice-helper-main small {
  margin-top: 5px;
  font-size: 0.86rem;
  color: var(--ink, #333);
  opacity: 0.82;
  line-height: 1.45;
}

.invoice-number-alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-left: 4px solid var(--teal);
  border-radius: 10px;
  background: rgba(15, 118, 110, 0.08);
}

.invoice-number-alert.is-warning {
  border-color: rgba(244, 184, 81, 0.75);
  border-left-color: var(--amber);
  background: #fff7e8;
}

.invoice-number-alert > span {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #fff;
  background: var(--teal);
}

.invoice-number-alert.is-warning > span {
  background: var(--amber);
  color: #24170a;
}

.invoice-number-alert strong,
.invoice-number-alert small {
  display: block;
}

.invoice-number-alert strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.invoice-number-alert small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.4;
}

.invoice-quick-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.invoice-quick-actions .mini-button {
  width: auto;
  height: auto;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong, var(--line));
  background: var(--surface, #f7f8fa);
  color: var(--ink, #1a1a1a);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.invoice-quick-actions .mini-button:hover {
  border-color: var(--teal, #155e9f);
  color: var(--teal, #155e9f);
  background: rgba(21, 94, 159, 0.08);
}

body.dark .invoice-quick-actions .mini-button:hover {
  border-color: var(--teal-strong, #7bd6c8);
  color: var(--teal-strong, #7bd6c8);
  background: rgba(123, 214, 200, 0.12);
}

.invoice-completeness {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: 8px;
}

.invoice-completeness span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(244, 184, 81, 0.55);
  background: rgba(244, 184, 81, 0.18);
  color: #b87a00;
  font-size: 0.78rem;
  font-weight: 800;
}

body.dark .invoice-completeness span {
  border-color: rgba(244, 184, 81, 0.45);
  background: rgba(244, 184, 81, 0.16);
  color: #f4b851;
}

.invoice-completeness span.is-complete {
  border: 1px solid rgba(15, 118, 110, 0.45);
  background: rgba(15, 118, 110, 0.14);
  color: #0d7a6b;
}

body.dark .invoice-completeness span.is-complete {
  border-color: rgba(67, 184, 166, 0.45);
  background: rgba(67, 184, 166, 0.18);
  color: var(--teal-strong, #7bd6c8);
}

.selected-invoice-customer {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 14px 18px;
  border: 1px solid var(--line-strong, var(--line));
  border-left: 4px solid var(--teal-strong, #43b8a6);
  border-radius: var(--radius);
  background: var(--surface, #ffffff);
  color: var(--ink, #1a1a1a);
}

.selected-invoice-customer > span {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--teal-strong, #43b8a6);
  color: #fff;
}

.selected-invoice-customer > span svg {
  width: 20px;
  height: 20px;
}

.selected-invoice-customer strong,
.selected-invoice-customer small {
  display: block;
}

.selected-invoice-customer strong {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink, #1a1a1a);
  line-height: 1.3;
}

.selected-invoice-customer small {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--ink, #333);
  opacity: 0.78;
  line-height: 1.4;
}

.invoice-fiscal-mode {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: var(--radius);
  background: #f7faf9;
  color: var(--teal-strong);
}

.invoice-fiscal-mode strong,
.invoice-fiscal-mode small {
  display: block;
}

.invoice-fiscal-mode small {
  margin-top: 3px;
  color: var(--muted);
}

.invoice-tax-profile-intro {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(75, 56, 156, 0.22);
  border-radius: var(--radius);
  background: rgba(75, 56, 156, 0.06);
}

.invoice-tax-profile-intro strong,
.invoice-tax-profile-intro small {
  display: block;
}

.invoice-tax-profile-intro small {
  margin-top: 3px;
  color: var(--muted);
}

.invoice-tax-grid {
  margin-top: 14px;
  grid-template-columns: minmax(280px, 2fr) repeat(4, minmax(110px, 1fr));
  align-items: end;
}

.invoice-tax-checkbox {
  min-height: 56px;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
}

.invoice-builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 360px);
  gap: 18px;
  align-items: start;
  padding-right: 0;
  width: 100%;
}

.invoice-builder > .fpa-form {
  grid-column: 1;
  min-width: 0;
  width: 100%;
}

.invoice-live-summary {
  grid-column: 2;
  position: sticky;
  top: 18px;
  width: 100%;
  min-width: 0;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  z-index: 6;
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7faf9;
  box-shadow: 0 14px 34px rgba(41, 35, 26, 0.08);
}

.invoice-live-summary h3 {
  margin: -8px 0 0;
  font-size: 1.05rem;
}

.invoice-live-summary dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.invoice-live-summary dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.invoice-live-summary dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.invoice-live-summary dd {
  margin: 0;
  max-width: 160px;
  text-align: right;
  font-weight: 800;
}

.invoice-live-summary .invoice-summary-total {
  align-items: flex-end;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.26);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.invoice-summary-total dd {
  color: var(--teal-strong);
  font-size: 1.18rem;
}

.invoice-guide-card {
  display: grid;
  gap: 12px;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(15, 118, 110, 0.06);
}

.invoice-guide-card h4 {
  margin: 0;
  font-size: 0.98rem;
}

.invoice-guide-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.invoice-guide-steps li {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-left: 4px solid rgba(244, 184, 81, 0.72);
  border-radius: 8px;
  background: var(--surface);
}

.invoice-guide-steps li.is-complete {
  border-left-color: var(--teal);
}

.invoice-guide-steps li.needs-work {
  background: #fff7e8;
}

.invoice-guide-steps strong {
  color: var(--ink);
  font-size: 0.86rem;
}

.invoice-guide-steps span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.invoice-smart-tips {
  display: grid;
  gap: 7px;
}

.invoice-tip {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-size: 0.8rem;
  line-height: 1.35;
}

.invoice-tip.is-ok {
  border-color: rgba(15, 118, 110, 0.36);
  background: rgba(15, 118, 110, 0.08);
}

.invoice-tip.is-warn {
  border-color: rgba(244, 184, 81, 0.62);
  background: rgba(244, 184, 81, 0.18);
}

.invoice-tip.is-info {
  border-color: rgba(81, 64, 139, 0.22);
  background: rgba(81, 64, 139, 0.08);
}

.invoice-create-panel .fpa-fieldset {
  padding: 16px;
  background: var(--surface);
  min-width: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.invoice-create-panel .fpa-fieldset > legend {
  color: var(--ink);
}

.invoice-create-panel .fpa-fieldset.is-complete {
  border-color: rgba(15, 118, 110, 0.32);
  background: #fbfffd;
}

.invoice-create-panel .fpa-fieldset.needs-work {
  border-color: rgba(244, 184, 81, 0.72);
  box-shadow: 0 0 0 3px rgba(244, 184, 81, 0.12);
}

.invoice-create-panel input,
.invoice-create-panel select {
  min-height: 46px;
}

@media (min-width: 1181px) {
  .invoice-create-panel .form-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .invoice-create-panel .invoice-tax-grid {
    grid-template-columns: minmax(280px, 2fr) repeat(4, minmax(110px, 1fr));
  }

  .invoice-section-customer .form-row:last-child {
    grid-template-columns: minmax(120px, 0.7fr) minmax(180px, 1fr) minmax(90px, 0.5fr);
  }
}

@media (max-width: 1180px) and (min-width: 721px) {
  .invoice-month-strip {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .invoice-builder {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .invoice-builder > .fpa-form,
  .invoice-live-summary {
    grid-column: 1;
  }

  .invoice-live-summary {
    position: static;
    width: 100%;
    max-height: none;
    overflow: visible;
  }
}

.purchase-inbox-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  background: var(--surface-strong);
}

.purchase-inbox-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}

.purchase-inbox-summary article {
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7faf9;
}

.purchase-inbox-summary span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.purchase-inbox-summary strong {
  color: var(--ink);
  font-size: 1.35rem;
}

.file-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.client-picker-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.client-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.client-search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.compact-customer-table {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: auto;
}

.compact-customer-table table {
  min-width: 840px;
}

.compact-customer-table th,
.compact-customer-table td {
  padding: 12px 14px;
}

.compact-customer-table tbody tr:hover {
  background: rgba(20, 159, 207, 0.07);
}

.fpa-lines {
  display: grid;
  gap: 10px;
}

.fpa-line-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface, #fff);
}

.fpa-line-grid {
  display: grid;
  /* Descrizione full-width sopra; sotto: Q.ta | Prezzo unit. | %IVA | Natura | (×) */
  grid-template-columns: 90px 140px 100px minmax(140px, 1fr) auto;
  gap: 10px;
  align-items: end;
  justify-content: start;
}

.fpa-line-grid > label {
  min-width: 0;
}

.fpa-line-grid label {
  font-size: 0.72rem;
  display: grid;
  gap: 4px;
}

/* Descrizione: occupa l'intera larghezza, su riga propria */
.fpa-line-desc-field {
  grid-column: 1 / -1;
}

.fpa-line-desc-field input {
  width: 100%;
  font-size: 0.95rem !important;
  padding: 9px 12px !important;
}

.fpa-line-grid input,
.fpa-line-grid select {
  font-size: 0.88rem;
  padding: 6px 8px;
}

.fpa-line-remove {
  align-self: end;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #b3261e;
  border: 1px solid #b3261e;
  background: #fff;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.fpa-line-remove:hover {
  background: #b3261e;
  color: #fff;
}
.fpa-line-remove .fpa-line-remove-label {
  font-size: .92rem;
  letter-spacing: .01em;
}
body.dark .fpa-line-remove {
  background: transparent;
  color: #ff7a73;
  border-color: #ff7a73;
}
body.dark .fpa-line-remove:hover {
  background: #ff7a73;
  color: #1a1a1a;
}

.fpa-row-total {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 800;
  text-align: right;
}

.fpa-row-total strong {
  color: var(--ink);
}

.fpa-line-total {
  margin: 0;
  text-align: right;
  font-size: 0.88rem;
}

.fpa-line-total strong {
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .invoice-create-panel {
    padding: 14px;
    gap: 12px;
  }

  .invoice-pdf-preview {
    min-height: 0;
    padding-bottom: 18px;
    overflow-x: hidden;
  }

  .invoice-top-actionbar {
    align-items: stretch;
    padding: 8px;
    gap: 10px;
  }

  .invoice-top-functions,
  .invoice-top-document-actions {
    flex: 1 1 100%;
    justify-content: stretch;
  }

  .invoice-top-functions button,
  .invoice-top-document-actions button {
    flex: 1 1 calc(50% - 8px);
    min-width: 132px;
    min-height: 42px;
    white-space: normal;
  }

  .pdf-sheet {
    width: 100%;
    min-height: 0;
    padding: 22px 16px;
    border-radius: 8px;
    overflow: visible;
  }

  .pdf-sheet-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .pdf-sheet-header-side {
    justify-items: stretch;
  }

  .pdf-logo-button,
  .pdf-logo-button.has-logo {
    width: 100%;
    max-width: 100%;
  }

  .pdf-editable-h3 {
    width: 100% !important;
    min-width: 0;
    margin-top: 6px;
    font-size: 1.25rem;
  }

  .pdf-doc-meta {
    align-items: stretch;
  }

  .pdf-doc-meta > span {
    width: 100%;
    justify-content: space-between;
    border-radius: 8px;
  }

  .pdf-doc-meta .pdf-editable {
    width: min(180px, 58vw) !important;
  }

  .pdf-party-grid,
  .pdf-summary {
    grid-template-columns: 1fr;
  }

  .pdf-party-grid > div,
  .pdf-summary > div,
  .pdf-summary dl {
    min-width: 0;
  }

  .pdf-party-grid small[style*="display:flex"],
  .pdf-summary small[style*="display:flex"],
  .pdf-due-row {
    display: grid !important;
    grid-template-columns: 1fr;
    align-items: stretch !important;
    gap: 5px !important;
  }

  .pdf-party-grid small .pdf-editable,
  .pdf-party-grid small .pdf-editable-select,
  .pdf-summary small .pdf-editable,
  .pdf-summary small .pdf-editable-select {
    width: 100% !important;
  }

  .pdf-editable-toggle {
    align-items: flex-start;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px dashed rgba(15, 118, 110, 0.35);
    border-radius: 8px;
    background: rgba(15, 118, 110, 0.06);
  }

  .pdf-editable-toggle input {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin-top: 1px;
  }

  .pdf-editable-toggle small {
    line-height: 1.35;
  }

  .pdf-payment-note,
  .fpa-bollo {
    padding: 12px;
    border: 1px dashed rgba(15, 118, 110, 0.35);
    border-radius: 8px;
    background: rgba(15, 118, 110, 0.06);
  }

  .fpa-bollo p {
    margin: 0;
    line-height: 1.45;
  }

  .pdf-summary dl {
    grid-template-columns: 1fr;
  }

  .pdf-summary dl div,
  .pdf-summary dl div:first-child {
    border-left-width: 4px;
  }

  .pdf-lines {
    display: block;
    overflow-x: auto;
    border-collapse: separate;
    -webkit-overflow-scrolling: touch;
  }

  .pdf-lines thead,
  .pdf-lines tbody {
    display: table;
    width: max-content;
    min-width: 100%;
  }

  .pdf-lines th,
  .pdf-lines td {
    min-width: 88px;
  }

  .pdf-lines th:first-child,
  .pdf-lines td:first-child {
    min-width: 210px;
  }

  .pdf-inps-backdrop,
  .pdf-client-backdrop {
    align-items: end;
    padding: 10px;
  }

  .pdf-inps-dialog,
  .pdf-client-dialog,
  .pdf-pa-dialog {
    width: 100%;
    max-height: calc(100dvh - 20px);
    padding: 16px;
  }

  .pdf-inps-grid {
    grid-template-columns: 1fr;
  }

  .client-picker-toolbar {
    grid-template-columns: 1fr;
  }

  .invoice-month-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .invoice-smart-strip {
    grid-template-columns: 1fr;
  }

  .invoice-archive-insight {
    grid-template-columns: 1fr;
  }

  .invoice-archive-filters {
    grid-template-columns: 1fr;
  }

  .invoice-step-strip {
    grid-template-columns: 1fr;
  }

  .invoice-helper-panel {
    grid-template-columns: 1fr;
  }

  .invoice-quick-actions {
    justify-content: stretch;
  }

  .invoice-quick-actions .mini-button {
    flex: 1 1 140px;
  }

  .invoice-panel-actions {
    grid-template-columns: 1fr;
  }

  .purchase-inbox-summary {
    grid-template-columns: 1fr;
  }

  .invoice-document-tabs {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .invoice-document-tabs button {
    white-space: nowrap;
  }

  .fpa-line-grid {
    grid-template-columns: 1fr 1fr;
  }
  .fpa-line-grid .fpa-line-desc-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 430px) {
  .invoice-top-functions button,
  .invoice-top-document-actions button {
    flex-basis: 100%;
  }

  .pdf-sheet {
    padding: 18px 12px;
  }
}

.fpa-document {
  position: relative;
  display: grid;
  gap: 18px;
  padding: 34px 38px;
  background:
    linear-gradient(90deg, #0f766e 0 33%, #d4a843 33% 49%, #0a1d33 49% 100%) top left / 100% 8px no-repeat,
    #fff;
  border: 1px solid #dfe7ef;
  border-radius: 8px;
  font-size: 0.92rem;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
}

.fpa-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 18px;
  border-bottom: 2px solid var(--teal);
}

.fpa-header-status {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.fpa-logo-box {
  display: grid;
  place-items: center;
  gap: 4px;
  width: 150px;
  min-height: 78px;
  padding: 10px;
  border: 2px dashed #d4a843;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff8df 0%, #ffffff 70%);
  color: #7a4f00;
  text-align: center;
}

.fpa-logo-box [data-icon] {
  width: 22px;
  height: 22px;
}

.fpa-logo-box strong {
  font-size: 0.85rem;
  line-height: 1;
}

.fpa-logo-box small {
  color: #8a6a24;
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1.2;
}

.fpa-logo-box.has-logo {
  border-style: solid;
  border-color: #dce6ef;
  background: #fff;
}

.fpa-logo-box.has-logo img {
  max-width: 100%;
  max-height: 60px;
  object-fit: contain;
}

.fpa-eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--teal-strong);
  font-weight: 700;
}

.fpa-title {
  margin: 0 0 4px;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
}

.fpa-subtitle {
  margin: 0;
  color: var(--text-muted, #6b7280);
  font-size: 0.85rem;
}

.fpa-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.fpa-party {
  border: 1px solid #dce6ef;
  border-radius: 8px;
  padding: 16px 18px;
  background: linear-gradient(180deg, #f8fbfd, #fff);
}

.fpa-party-title {
  margin: 0 0 6px;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-strong);
  font-weight: 700;
}

.fpa-party-name {
  margin: 0 0 10px;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.2;
}

.fpa-party-grid,
.fpa-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin: 0;
}

.fpa-party-grid > div,
.fpa-meta-grid > div {
  display: grid;
  gap: 2px;
  font-size: 0.85rem;
}

.fpa-party-grid dt,
.fpa-meta-grid dt {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #6b7280);
  font-weight: 600;
}

.fpa-party-grid dd,
.fpa-meta-grid dd {
  margin: 0;
  font-weight: 600;
  line-height: 1.35;
}

.fpa-party-address,
.fpa-wide {
  grid-column: 1 / -1;
}

.fpa-section-title {
  margin: 0 0 8px;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-strong);
  font-weight: 700;
}

.fpa-section {
  border: 1px solid #dce6ef;
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--surface, #fff);
}

.fpa-table-wrap {
  overflow-x: auto;
  border: 1px solid #dce6ef;
  border-radius: 8px;
}

.fpa-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.fpa-table th,
.fpa-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.fpa-table thead th {
  background: #eef8f5;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #0a1d33;
  font-weight: 700;
}

.fpa-table tbody tr:nth-child(even) td {
  background: #fbfdfe;
}

.fpa-table tbody tr:last-child td {
  border-bottom: none;
}

.fpa-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fpa-line-desc {
  min-width: 220px;
}

.fpa-mono {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.fpa-bollo {
  background: var(--surface-strong);
  border-style: dashed;
}

.fpa-totals {
  border-top: 2px solid var(--teal);
  padding-top: 14px;
}

.fpa-totals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.fpa-totals-grid > div {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface, #fff);
}

.fpa-totals-grid span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #6b7280);
}

.fpa-totals-grid strong {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.fpa-grand-total {
  background: var(--teal-strong, #0f766e) !important;
  color: #fff;
}

.fpa-grand-total span {
  color: rgba(255, 255, 255, 0.78);
}

.fpa-grand-total strong {
  font-size: 1.25rem;
  color: #fff;
}

@media (max-width: 720px) {
  .bolli-hero-panel,
  .f24-title {
    flex-direction: column;
  }

  .bolli-hero-meta {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

  .bolli-quarter-grid,
  .f24-grid {
    grid-template-columns: 1fr;
  }

  .fpa-parties {
    grid-template-columns: 1fr;
  }
  .fpa-party-grid,
  .fpa-meta-grid {
    grid-template-columns: 1fr;
  }
}

/* ========================================================================
   Mobile UX Tier 1 — fix per smartphone (480px e sotto)
   ======================================================================== */

@media (max-width: 540px) {
  /* 1. Tutti i form-row vanno in colonna (campi affiancati → uno sotto l'altro) */
  .form-row,
  .form-row.three-columns {
    grid-template-columns: 1fr !important;
  }

  /* 2. Toolbar/azioni vanno a capo e i bottoni occupano tutta la larghezza */
  .toolbar-actions,
  .chat-toolbar,
  .sport-flow-actions,
  .invoice-panel-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  .toolbar-actions > *,
  .chat-toolbar > *,
  .sport-flow-actions > *,
  .invoice-panel-actions > * {
    flex: 1 1 100%;
    min-width: 0;
    justify-content: center;
  }

  /* 3. Pulsanti grandi (primary/secondary) full-width, testo non si taglia */
  .primary-action,
  .secondary-action,
  .file-action {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    white-space: normal;
    text-align: center;
  }

  /* Eccezione: i pulsanti dentro vat-lookup-wrap e simili devono restare inline */
  .vat-lookup-wrap .vat-lookup-btn,
  .reuse-invoice-banner button,
  .invoice-helper-panel button,
  .panel-header button,
  .invoice-viewer-actions button {
    width: auto;
  }

  /* 4. Tabelle: scroll orizzontale invece di overflow brutto */
  table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  /* Mantieni layout tabella per il contenuto interno */
  table > thead,
  table > tbody,
  table > tfoot {
    display: table;
    width: max-content;
    min-width: 100%;
    table-layout: auto;
  }

  /* 5. Container che vanno sempre in colonna */
  .table-toolbar,
  .client-rubric-toolbar,
  .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .panel-header > div:first-child {
    min-width: 0;
  }

  .documents-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .documents-metrics span {
    min-width: 0;
  }

  .doc-grid {
    grid-template-columns: 1fr;
  }

  .doc-card {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .doc-card-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  /* 6. Servizi: immagini service-image larghe, vincolarle */
  .service-image,
  .service-body,
  .service-card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* 7. Cart / sidebar cards: niente width fissi */
  .panel,
  aside.panel,
  .panel.wide-panel {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* 8. Invoice line rows: la grid 1058px va lasciata scrollare */
  .fpa-lines,
  .fpa-line-row,
  .invoice-fiscal-mode {
    overflow-x: auto;
    max-width: 100%;
  }

  /* 9. Form labels e input: full width */
  .stacked-form label,
  .stacked-form input,
  .stacked-form select,
  .stacked-form textarea {
    width: 100%;
    box-sizing: border-box;
  }

  /* 10. Header titolo grande: dimensione font ridotta */
  .panel-header h2,
  .view-title,
  h1 {
    font-size: 1.4rem;
    line-height: 1.25;
    word-wrap: break-word;
  }

  /* 11. Sidebar mini quando 76px: assicurarsi che icone non escano */
  .sidebar {
    overflow-x: hidden;
  }

  /* 12. Settings: il form settings-grid in colonna */
  .settings-grid {
    min-width: 0;
    grid-template-columns: 1fr !important;
  }

  #settings,
  #settings > .settings-panel,
  .settings-panel,
  .fiscal-profile-panel,
  .identity-profile-panel,
  .fiscal-profile-panel .settings-grid,
  .identity-profile-panel .settings-grid,
  .fiscal-profile-panel .settings-grid > *,
  .identity-profile-panel .settings-grid > * {
    min-width: 0;
    max-width: 100%;
  }

  .settings-grid label,
  .settings-grid input,
  .settings-grid select,
  .settings-grid textarea {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .fiscal-profile-panel .checkbox-line {
    width: 100%;
  }

  .fiscal-profile-panel .checkbox-line span,
  .fiscal-profile-panel .checkbox-line small {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
  }

  /* 13. Stacked form: spaziature ridotte per non occupare troppo */
  .stacked-form {
    gap: 10px;
  }

  /* 14. Sezioni view: padding ridotto su mobile */
  .view {
    padding-left: 8px;
    padding-right: 8px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 6mm 7mm;
  }
  body.printing-simulator {
    background: #fff;
    color: #111;
  }
  body.printing-simulator * {
    visibility: hidden;
  }
  body.printing-simulator #invoicePdfPreview,
  body.printing-simulator #invoicePdfPreview * {
    visibility: visible;
  }
  body.printing-simulator #invoicePdfPreview {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    background: #fff;
  }
  body.printing-simulator .pdf-sheet {
    width: 196mm !important;
    max-width: 196mm !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 4.5mm 4mm !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    overflow: visible !important;
  }
  body.printing-simulator .pdf-watermark {
    color: rgba(180, 83, 9, 0.12) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.printing-simulator .pdf-credit-watermark {
    color: rgba(15, 118, 110, 0.12) !important;
  }
  body.printing-simulator .pdf-proforma-badge,
  body.printing-simulator .pdf-credit-badge,
  body.printing-simulator .pdf-legal-disclaimer,
  body.printing-simulator .pdf-total {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.printing-simulator .pdf-party-grid > div,
  body.printing-simulator .pdf-lines,
  body.printing-simulator .pdf-summary {
    page-break-inside: avoid;
    break-inside: avoid;
  }
  body.printing-simulator .pdf-sheet {
    font-size: 7.6pt !important;
    line-height: 1.18 !important;
  }
  body.printing-simulator .pdf-sheet h3 {
    margin-bottom: 1.5mm !important;
    font-size: 14pt !important;
    line-height: 1.05 !important;
  }
  body.printing-simulator .pdf-kicker,
  body.printing-simulator .pdf-party-grid span,
  body.printing-simulator .pdf-summary span {
    margin-bottom: 1mm !important;
    font-size: 6.2pt !important;
  }
  body.printing-simulator .pdf-doc-meta {
    gap: 1.5mm !important;
    font-size: 7pt !important;
  }
  body.printing-simulator .pdf-doc-meta > span {
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }
  body.printing-simulator .pdf-editable,
  body.printing-simulator .pdf-editable-select,
  body.printing-simulator textarea.pdf-editable {
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: inherit !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    resize: none !important;
  }
  body.printing-simulator .pdf-editable-h3 {
    min-width: 0 !important;
    font-size: 14pt !important;
  }
  body.printing-simulator .pdf-logo-button {
    width: 28mm !important;
    height: 12mm !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    color: #526579 !important;
  }
  body.printing-simulator .pdf-logo-button:not(.has-logo) {
    display: none !important;
  }
  body.printing-simulator .pdf-party-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 3mm !important;
    margin: 3mm 0 !important;
  }
  body.printing-simulator .pdf-party-grid > div {
    gap: 0.7mm !important;
    padding: 2mm 2.5mm !important;
    font-size: 7.2pt !important;
    line-height: 1.15 !important;
  }
  body.printing-simulator .pdf-party-grid span {
    font-size: 7pt !important;
    margin-bottom: 1mm !important;
  }
  body.printing-simulator .pdf-party-grid strong {
    font-size: 8.5pt !important;
    margin-bottom: 0.5mm !important;
  }
  body.printing-simulator .pdf-party-grid small {
    font-size: 6.8pt !important;
    line-height: 1.12 !important;
  }
  body.printing-simulator .pdf-party-action,
  body.printing-simulator .pdf-line-remove,
  body.printing-simulator .pdf-option-chips,
  body.printing-simulator .pdf-editor-actions,
  body.printing-simulator .invoice-top-actionbar,
  body.printing-simulator .pdf-edit-hint {
    display: none !important;
  }
  body.printing-simulator .pdf-sheet-header {
    gap: 4mm !important;
    margin-bottom: 0 !important;
    padding-bottom: 2mm !important;
  }
  body.printing-simulator .pdf-lines {
    margin: 2.5mm 0 3mm !important;
    font-size: 6.8pt !important;
  }
  body.printing-simulator .pdf-lines th,
  body.printing-simulator .pdf-lines td {
    padding: 1.15mm 1.25mm !important;
    font-size: 6.8pt !important;
    line-height: 1.12 !important;
  }
  body.printing-simulator .pdf-lines thead th {
    font-size: 5.8pt !important;
  }
  body.printing-simulator .pdf-line-note {
    display: none !important;
  }
  body.printing-simulator .pdf-sheet:not(.has-line-codes) .pdf-col-code,
  body.printing-simulator .pdf-sheet:not(.has-line-units) .pdf-col-unit,
  body.printing-simulator .pdf-sheet:not(.has-line-discounts) .pdf-col-discount {
    display: none !important;
  }
  body.printing-simulator .pdf-summary {
    grid-template-columns: minmax(0, 1fr) 48mm !important;
    gap: 4mm !important;
    margin-top: 2mm !important;
    font-size: 7pt !important;
  }
  body.printing-simulator .pdf-exemption {
    margin-top: 2mm !important;
    padding: 1.5mm 2mm !important;
    border-radius: 1mm !important;
  }
  body.printing-simulator .pdf-summary dl {
    gap: 0 !important;
  }
  body.printing-simulator .pdf-summary dl div {
    padding: 1mm 0 !important;
    gap: 3mm !important;
  }
  body.printing-simulator .pdf-total {
    padding: 2mm !important;
  }
  body.printing-simulator .pdf-note {
    margin-top: 2.5mm !important;
    padding-top: 1.5mm !important;
    font-size: 6.2pt !important;
  }
  body.printing-simulator .pdf-legal-disclaimer {
    margin-top: 2.5mm !important;
    padding: 1.7mm 2mm !important;
    font-size: 6.8pt !important;
    line-height: 1.18 !important;
  }
  body.printing-simulator .pdf-sheet.has-many-lines {
    font-size: 7pt !important;
  }
  body.printing-simulator .pdf-sheet.has-many-lines .pdf-party-grid {
    margin: 2mm 0 !important;
  }
  body.printing-simulator .pdf-sheet.has-many-lines .pdf-party-grid > div {
    padding: 1.5mm 2mm !important;
  }
  body.printing-simulator .pdf-sheet.has-many-lines .pdf-lines th,
  body.printing-simulator .pdf-sheet.has-many-lines .pdf-lines td {
    padding: 0.85mm 1mm !important;
    font-size: 6.2pt !important;
  }
  body.printing-invoice {
    background: #fff;
    color: #111;
    font-size: 9.5pt;
  }
  body.printing-invoice * {
    visibility: hidden;
  }
  body.printing-invoice #invoiceViewer,
  body.printing-invoice #invoiceViewer * {
    visibility: visible;
  }
  body.printing-invoice #invoiceViewer {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    background: #fff;
  }
  body.printing-invoice .invoice-document,
  body.printing-invoice .fpa-document {
    border: none !important;
    box-shadow: none !important;
    background: #fff !important;
    padding: 0 !important;
    gap: 8px !important;
  }
  body.printing-invoice .fpa-header {
    padding-bottom: 6px !important;
    border-bottom: 1.5pt solid #0f766e !important;
  }
  body.printing-invoice .fpa-eyebrow {
    font-size: 7pt !important;
  }
  body.printing-invoice .fpa-title {
    font-size: 14pt !important;
    margin-bottom: 2px !important;
  }
  body.printing-invoice .fpa-subtitle {
    font-size: 8.5pt !important;
  }
  body.printing-invoice .fpa-parties {
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
  }
  body.printing-invoice .fpa-party,
  body.printing-invoice .fpa-section {
    padding: 6px 8px !important;
    border-radius: 4px !important;
    background: #fff !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  body.printing-invoice .fpa-party-title,
  body.printing-invoice .fpa-section-title {
    font-size: 6.5pt !important;
    margin-bottom: 4px !important;
  }
  body.printing-invoice .fpa-party-name {
    font-size: 10pt !important;
    margin-bottom: 4px !important;
  }
  body.printing-invoice .fpa-party-grid,
  body.printing-invoice .fpa-meta-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 3px 8px !important;
  }
  body.printing-invoice .fpa-party-grid > div,
  body.printing-invoice .fpa-meta-grid > div {
    font-size: 8pt !important;
  }
  body.printing-invoice .fpa-party-grid dt,
  body.printing-invoice .fpa-meta-grid dt {
    font-size: 6.5pt !important;
  }
  body.printing-invoice .fpa-table-wrap {
    border: 1px solid #999 !important;
    border-radius: 0 !important;
  }
  body.printing-invoice .fpa-table {
    font-size: 8pt !important;
  }
  body.printing-invoice .fpa-table th,
  body.printing-invoice .fpa-table td {
    padding: 3px 5px !important;
    border-bottom: 1px solid #ccc !important;
  }
  body.printing-invoice .fpa-table thead th {
    background: #f1f5f4 !important;
    color: #0f766e !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-size: 7pt !important;
  }
  body.printing-invoice .fpa-totals {
    padding-top: 6px !important;
    border-top: 1.5pt solid #0f766e !important;
  }
  body.printing-invoice .fpa-totals-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
  }
  body.printing-invoice .fpa-totals-grid > div {
    padding: 4px 6px !important;
    border-radius: 4px !important;
  }
  body.printing-invoice .fpa-totals-grid span {
    font-size: 6.5pt !important;
  }
  body.printing-invoice .fpa-totals-grid strong {
    font-size: 9pt !important;
  }
  body.printing-invoice .fpa-grand-total {
    background: #0f766e !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.printing-invoice .fpa-grand-total strong {
    font-size: 10pt !important;
    color: #fff !important;
  }
  body.printing-invoice .fpa-bollo p {
    font-size: 7.5pt !important;
    margin: 0 !important;
  }
  body.printing-invoice .invoice-viewer-actions,
  body.printing-invoice .empty-state {
    display: none !important;
  }
  body.printing-f24 {
    background: #fff;
    color: #111;
  }
  body.printing-f24 * {
    visibility: hidden;
  }
  body.printing-f24 #bolliF24Panel,
  body.printing-f24 #bolliF24Panel * {
    visibility: visible;
  }
  body.printing-f24 #bolliF24Panel {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
  body.printing-f24 #bolliF24Panel .panel-header {
    display: none !important;
  }
  body.printing-f24 .f24-facsimile {
    border: 0;
    box-shadow: none;
  }
}

/* ========================================================================
   Simulatore lavoratore sportivo
   ======================================================================== */

.simulator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 18px;
  margin-top: 18px;
}

@media (max-width: 1100px) {
  .simulator-grid {
    grid-template-columns: 1fr;
  }
}

.simulator-input-panel fieldset.fpa-fieldset {
  margin-bottom: 14px;
}

.simulator-input-panel input[type="number"],
.simulator-input-panel select {
  font-variant-numeric: tabular-nums;
}

.sim-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

@media (max-width: 480px) {
  .sim-summary {
    grid-template-columns: 1fr;
  }
}

.sim-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong, var(--line));
  border-left: 4px solid var(--line-strong, var(--line));
  border-radius: 12px;
  background: var(--surface, #ffffff);
  color: var(--ink, #1a1a1a);
}

.sim-card-primary {
  border-left-color: var(--teal, #155e9f);
  background: rgba(21, 94, 159, 0.06);
}

body.dark .sim-card-primary {
  background: rgba(67, 184, 166, 0.10);
  border-left-color: var(--teal-strong, #43b8a6);
}

.sim-card-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--ink, #1a1a1a);
  opacity: 0.72;
}

.sim-card-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--ink, #1a1a1a);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.sim-card-primary .sim-card-value {
  color: var(--teal, #155e9f);
  font-size: 1.6rem;
}

body.dark .sim-card-primary .sim-card-value {
  color: var(--teal-strong, #7bd6c8);
}

.sim-card-foot {
  font-size: 0.78rem;
  color: var(--ink, #1a1a1a);
  opacity: 0.72;
}

.sim-detail-block {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line, #e0e0e0);
}

.sim-detail-block h3 {
  margin: 0 0 10px;
  font-size: 0.92rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink, #1a1a1a);
  opacity: 0.78;
}

.sim-detail {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 0;
}

.sim-detail > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line, #e0e0e0);
}

.sim-detail dt {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink, #1a1a1a);
  opacity: 0.78;
}

.sim-detail dd {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink, #1a1a1a);
}

.sim-detail dd strong,
.sim-detail dt strong {
  font-weight: 800;
  opacity: 1;
  color: var(--teal, #155e9f);
}

body.dark .sim-detail dd strong,
body.dark .sim-detail dt strong {
  color: var(--teal-strong, #7bd6c8);
}

.sim-disclaimer {
  margin-top: 16px;
  font-size: 0.8rem;
  font-style: italic;
}

.sim-import-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.sim-import-row button {
  align-self: flex-start;
}

.sim-imported-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 12px;
  margin: 0 0 10px;
  border: 1px solid rgba(21, 94, 159, 0.22);
  border-left: 4px solid var(--teal, #155e9f);
  border-radius: 10px;
  background: rgba(21, 94, 159, 0.06);
}

.sim-imported-line span {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink, #1a1a1a);
}

.sim-imported-line strong {
  font-size: 1rem;
  color: var(--teal, #155e9f);
  font-variant-numeric: tabular-nums;
}

.sim-imported-line small {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  color: var(--muted, #65756f);
}

body.dark .sim-imported-line {
  background: rgba(67, 184, 166, 0.10);
  border-color: rgba(67, 184, 166, 0.28);
  border-left-color: var(--teal-strong, #43b8a6);
}

body.dark .sim-imported-line strong {
  color: var(--teal-strong, #7bd6c8);
}

#simImportHint {
  margin-top: 0;
  margin-bottom: 10px;
}

/* ====== Demo banner (mostrato quando user e' cliente@demo.it) ====== */
.demo-banner {
  position: sticky;
  top: 0;
  z-index: 999;
  background: var(--amber);
  color: #fff;
  border-bottom: 1px solid var(--amber-strong, #b07a14);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.demo-banner-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
}

.demo-banner-inner > span {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
}

.demo-banner-inner > span svg {
  width: 16px;
  height: 16px;
  color: #fff;
}

.demo-banner-text {
  flex: 1;
  min-width: 0;
}

.demo-banner-text strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
}

.demo-banner-text small {
  display: block;
  font-size: 0.82rem;
  opacity: 0.92;
  line-height: 1.35;
}

.demo-banner-cta {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 8px;
  background: #fff;
  color: var(--amber-strong, #b07a14);
  font-weight: 800;
  font-size: 0.88rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
}

.demo-banner-cta:hover {
  background: rgba(255, 255, 255, 0.88);
}

@media (max-width: 720px) {
  .demo-banner-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 14px;
  }
  .demo-banner-cta {
    text-align: center;
    justify-content: center;
  }
}

/* ====== Demo login block nella schermata di accesso ====== */
.demo-login-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0;
}

.demo-login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 2px;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.demo-login-divider::before,
.demo-login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.demo-login-btn {
  border-color: var(--amber) !important;
  color: var(--amber-strong) !important;
  font-weight: 700;
}

.demo-login-btn:hover {
  background: var(--amber-soft) !important;
}

body.dark .demo-login-btn {
  color: var(--amber) !important;
}

.demo-login-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.bolli-toolbar {
  align-items: flex-start;
  gap: 18px;
}

.bolli-year-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.bolli-year-picker select {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  outline: 0;
}

.bolli-hero-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-top: 16px;
  background:
    linear-gradient(135deg, rgba(16, 118, 112, 0.08), transparent 58%),
    #fff;
}

.bolli-total {
  display: block;
  margin-top: 10px;
  font-size: clamp(38px, 6vw, 62px);
  line-height: 0.95;
  letter-spacing: 0;
  color: var(--ink);
}

.bolli-deadline {
  margin: 14px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.bolli-hero-meta {
  min-width: 180px;
  padding: 16px;
  border: 1px solid rgba(16, 118, 112, 0.22);
  border-radius: 8px;
  background: rgba(16, 118, 112, 0.08);
  text-align: right;
}

.bolli-hero-meta span,
.bolli-hero-meta small {
  display: block;
}

.bolli-hero-meta span {
  color: var(--ink);
  font-weight: 900;
}

.bolli-hero-meta small {
  margin-top: 6px;
  color: var(--brand);
  font-weight: 800;
}

.bolli-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  padding: 14px 16px;
  border: 1px solid rgba(16, 118, 112, 0.16);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.bolli-notice > span[data-icon] {
  color: var(--brand);
}

.bolli-notice strong,
.bolli-notice small {
  display: block;
}

.bolli-notice small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 700;
}

.bolli-quarter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 14px;
}

.bolli-quarter-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  min-height: 210px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.bolli-quarter-card.is-clickable {
  cursor: pointer;
}

.bolli-quarter-card:focus-visible {
  outline: 3px solid rgba(16, 118, 112, 0.24);
  outline-offset: 2px;
}

.bolli-quarter-card.is-selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(16, 118, 112, 0.1);
}

.bolli-quarter-card.is-paid {
  background: rgba(16, 118, 112, 0.06);
}

.bolli-quarter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bolli-quarter-card small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.bolli-quarter-card strong {
  color: var(--ink);
  font-size: 1.6rem;
  letter-spacing: 0;
}

.bolli-quarter-card > span {
  align-self: flex-start;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(16, 118, 112, 0.1);
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 900;
}

.bolli-card-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.bolli-quarter-card button {
  width: 100%;
  justify-content: center;
}

.bolli-invoice-row {
  cursor: pointer;
}

.bolli-invoice-row:hover {
  background: rgba(16, 118, 112, 0.05);
}

.bolli-invoice-row:focus-visible {
  outline: 2px solid rgba(16, 118, 112, 0.24);
  outline-offset: -2px;
}

.bolli-invoice-doc {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.bolli-invoice-doc small {
  color: var(--muted);
  font-weight: 700;
}

.bolli-invoice-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.bolli-invoice-link:hover {
  color: var(--brand);
  text-decoration: underline;
}

.bolli-invoice-actions {
  justify-content: flex-end;
  min-width: 86px;
}

.bolli-f24-panel[hidden] {
  display: none;
}

.f24-facsimile {
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}

.f24-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
}

.f24-title strong,
.f24-title span {
  display: block;
}

.f24-title strong {
  color: var(--ink);
  font-size: 1.2rem;
}

.f24-title span {
  color: var(--muted);
  font-weight: 700;
}

.f24-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.f24-field {
  min-height: 66px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.f24-field span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.f24-field strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
}

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

.f24-table th,
.f24-table td {
  padding: 10px;
  border: 1px solid var(--ink);
  text-align: left;
}

.f24-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.f24-table tfoot th {
  color: var(--ink);
}

@media (max-width: 720px) {
  .bolli-toolbar {
    align-items: stretch;
  }

  .bolli-toolbar .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .bolli-year-picker {
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
  }

  .bolli-year-picker select {
    min-height: 40px;
    text-align: right;
  }

  .bolli-hero-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .bolli-total {
    font-size: clamp(34px, 12vw, 48px);
  }

  .bolli-hero-meta {
    min-width: 0;
    text-align: left;
  }

  .bolli-notice {
    align-items: flex-start;
  }

  .bolli-quarter-grid {
    grid-template-columns: 1fr;
  }

  .bolli-quarter-card {
    min-height: 0;
  }

  .bolli-quarter-head {
    align-items: flex-start;
  }

  .bolli-quarter-card strong {
    font-size: 1.35rem;
  }

  .bolli-invoice-actions {
    justify-content: flex-start;
  }

  .f24-facsimile {
    padding: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .f24-title {
    display: grid;
    grid-template-columns: 1fr;
  }

  .f24-grid {
    grid-template-columns: 1fr;
  }

  .f24-table {
    min-width: 520px;
  }
}

.tax-cross-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 18px 22px;
  border: 1px solid var(--line-strong, var(--line));
  border-left: 4px solid var(--teal, #155e9f);
  border-radius: 14px;
  background: var(--surface, #ffffff);
  color: var(--ink, #1a1a1a);
}

.tax-cross-link > div {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.tax-cross-link > div > span {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--teal, #155e9f);
  color: #fff;
}

.tax-cross-link > div > span svg {
  width: 20px;
  height: 20px;
}

.tax-cross-link strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
}

.tax-cross-link small {
  display: block;
  margin-top: 4px;
  font-size: 0.85rem;
  opacity: 0.78;
  line-height: 1.45;
}

.tax-cross-link button {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 720px) {
  .tax-cross-link {
    flex-direction: column;
    align-items: stretch;
  }

  .tax-cross-link button {
    align-self: stretch;
    justify-content: center;
  }
}

/* === Legal pages (privacy, cookie-policy) === */
.auth-card-wide {
  max-width: 920px;
}
.legal-content {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  line-height: 1.55;
  text-align: left;
}
.legal-content h2 {
  margin: 1.3rem 0 0.2rem;
  font-size: 1.15rem;
}
.legal-content h3 {
  margin: 0.8rem 0 0.1rem;
  font-size: 1rem;
}
.legal-content p,
.legal-content li {
  font-size: 0.95rem;
}
.legal-content ul {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.legal-content a {
  color: inherit;
  text-decoration: underline;
}
.legal-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1rem;
  font-size: 0.88rem;
}
.legal-table th,
.legal-table td {
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 0.5rem 0.6rem;
  text-align: left;
  vertical-align: top;
}
.legal-table th {
  background: rgba(0, 0, 0, 0.04);
  font-weight: 600;
}
.legal-table code {
  font-size: 0.85em;
  background: rgba(0, 0, 0, 0.05);
  padding: 0.05em 0.3em;
  border-radius: 3px;
}
.legal-footer-note {
  margin-top: 1.2rem;
  font-size: 0.85rem;
  opacity: 0.75;
}

/* === Cookie notice banner === */
.cookie-notice {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 9999;
  background: #1f2937;
  color: #f9fafb;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  padding: 0.9rem 1.1rem;
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 880px;
  margin: 0 auto;
}
.cookie-notice--hidden {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}
.cookie-notice__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.1rem;
}
.cookie-notice__text {
  flex: 1 1 320px;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}
.cookie-notice__link {
  color: #93c5fd;
  text-decoration: underline;
  font-size: 0.88rem;
  white-space: nowrap;
}
.cookie-notice__button {
  background: #f9fafb;
  color: #111827;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}
.cookie-notice__button:hover {
  background: #e5e7eb;
}
@media (max-width: 520px) {
  .cookie-notice {
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    padding: 0.8rem 0.9rem;
  }
  .cookie-notice__inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .cookie-notice__button {
    align-self: stretch;
  }
}

/* === Legal footer (visibile in ogni pagina) === */
.legal-footer {
  margin-top: 3rem;
  padding: 1.4rem 1.25rem 1.1rem;
  background: #f3f4f6;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  color: #374151;
  font-size: 0.85rem;
  line-height: 1.5;
}
.legal-footer__inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}
.legal-footer__partnership {
  margin: 0;
  font-size: 0.9rem;
  color: #111827;
  letter-spacing: 0.01em;
}
.legal-footer__partnership strong {
  font-weight: 700;
}
.legal-footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.25rem 0.55rem;
  font-size: 0.83rem;
}
.legal-footer__links a {
  color: #1d4ed8;
  text-decoration: none;
}
.legal-footer__links a:hover {
  text-decoration: underline;
}
.legal-footer__links span {
  color: #9ca3af;
}
.legal-footer__copyright {
  margin: 0;
  font-size: 0.78rem;
  color: #6b7280;
}
@media (max-width: 600px) {
  .legal-footer {
    padding: 1.2rem 0.9rem 0.9rem;
  }
}

/* === GDPR rights panel === */
.gdpr-panel {
  margin-top: 1.5rem;
}
.gdpr-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}
.gdpr-action {
  background: rgba(0, 0, 0, 0.03);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.gdpr-action h3 {
  margin: 0;
  font-size: 1rem;
}
.gdpr-action .muted-copy {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
}
.gdpr-action button {
  align-self: flex-start;
  margin-top: 0.3rem;
}
.gdpr-action--danger {
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.18);
}
.gdpr-action--danger h3 {
  color: #b91c1c;
}
.destructive-action {
  background: #b91c1c;
  color: #fff;
  border: none;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.destructive-action:hover {
  background: #991b1b;
}
.destructive-action:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Banner globale "cancellazione in corso" */
.gdpr-erasure-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #b91c1c;
  color: #fff;
  padding: 0.7rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem 1rem;
  font-size: 0.9rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}
.gdpr-erasure-banner__action {
  margin-left: auto;
  background: #fff;
  color: #b91c1c;
  border: none;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.gdpr-erasure-banner__action:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* === Chip attivo per Fattura PA === */
#invoiceTopFunctionActions .chip-active {
  background: #0f766e;
  color: #fff;
  border-color: #0f766e;
}
#invoiceTopFunctionActions .chip-active:hover {
  background: #115e59;
}

/* ============================================================
   Navigazione mobile: bottom tab bar + sidebar come drawer
   ============================================================ */
.bottom-nav {
  display: none;
}

@media (max-width: 720px) {
  /* contenuto a tutta larghezza: niente rail laterale */
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  /* la sidebar diventa un pannello a scomparsa (drawer) */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1200;
    width: min(84vw, 320px);
    max-width: 320px;
    height: 100dvh;
    min-height: 100dvh;
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--line-strong);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.28);
  }
  body.nav-drawer-open .sidebar {
    transform: translateX(0);
  }

  /* nel drawer le etichette tornano visibili */
  .sidebar .brand {
    justify-content: flex-start;
  }
  .sidebar .brand > div:not(.brand-mark) {
    display: block;
  }
  .main-nav {
    width: 100%;
  }
  .sidebar .nav-item {
    justify-content: flex-start;
    width: 100%;
    padding: 0 12px;
  }
  .sidebar .nav-item > span:not([data-icon]):not(.nav-badge) {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }
  .advisor-mini {
    display: flex;
  }

  /* sfondo scuro dietro al drawer */
  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    border: 0;
    background: rgba(15, 23, 20, 0.45);
  }
  .nav-backdrop[hidden] {
    display: none;
  }

  /* barra di navigazione in basso */
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--surface-strong);
    border-top: 1px solid var(--line-strong);
    box-shadow: 0 -4px 16px rgba(41, 35, 26, 0.08);
  }

  .bottom-nav .bottom-nav-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    min-width: 0;
    min-height: 52px;
    padding: 6px 2px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font: 600 0.66rem/1 Inter, system-ui, sans-serif;
  }
  .bottom-nav .bottom-nav-item.is-active {
    color: var(--teal-strong);
    background: transparent;
  }
  .bottom-nav .bottom-nav-item [data-icon] {
    width: 22px;
    height: 22px;
    color: inherit;
  }
  .bottom-nav .bottom-nav-item [data-icon] svg {
    width: 22px;
    height: 22px;
  }
  .bottom-nav-label {
    font-size: 0.66rem;
    line-height: 1;
  }

  /* pulsante centrale "Crea" in evidenza, stile FAB */
  .bottom-nav .bottom-nav-cta {
    color: var(--muted);
  }
  .bottom-nav .bottom-nav-cta [data-icon] {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    margin-top: -20px;
    border-radius: 16px;
    background: var(--teal);
    color: #fff;
    box-shadow: 0 6px 16px rgba(15, 118, 110, 0.4);
  }
  .bottom-nav .bottom-nav-cta [data-icon] svg {
    width: 26px;
    height: 26px;
  }
  .bottom-nav .bottom-nav-cta.is-active {
    color: var(--teal-strong);
  }

  /* hamburger del tab "Menu" */
  .bottom-nav-burger {
    display: grid;
    gap: 4px;
    width: 22px;
    height: 22px;
    align-content: center;
  }
  .bottom-nav-burger span {
    height: 2px;
    border-radius: 2px;
    background: currentColor;
  }

  /* spazio in fondo al contenuto per non finire sotto la bottom bar */
  .workspace {
    padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  }
}

/* Dettaglio fattura: su mobile i molti comandi restano raggiungibili senza
   occupare tutta la schermata o finire sotto il bordo del popup PDF. */
.invoice-actions-divider {
  display: block;
  width: 100%;
  height: 0;
  margin: 4px 0;
  border-top: 1px dashed #cbd5e1;
}

.invoice-viewer-actions button,
.invoice-panel-actions button {
  min-width: 0;
}

@media (max-width: 720px) {
  .invoice-action-panel {
    gap: 10px;
    padding: 12px;
  }

  .invoice-panel-block {
    gap: 9px;
    padding-top: 10px;
  }

  .invoice-payment-line {
    grid-template-columns: 1fr auto;
    min-height: 0;
    gap: 6px 10px;
    font-size: 0.78rem;
  }

  .invoice-payment-line strong {
    grid-column: 1 / -1;
    text-align: left;
    font-size: 0.98rem;
  }

  .invoice-panel-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .invoice-panel-facts div {
    display: grid;
    gap: 3px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .invoice-panel-facts dd {
    text-align: left;
    overflow-wrap: anywhere;
  }

  .invoice-panel-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .invoice-panel-actions > * {
    min-width: 0;
  }

  .invoice-panel-actions button {
    width: 100%;
    min-height: 38px;
    padding: 6px 8px;
    justify-content: center;
    gap: 6px;
    font-size: 0.74rem;
    line-height: 1.15;
  }

  .invoice-panel-actions button [data-icon] {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
  }

  body.pdf-preview-active #invoiceViewer {
    top: 8px;
    right: 6px;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    left: 6px;
    width: auto;
    transform: none;
    padding: 8px 8px 0;
    border-radius: 10px;
  }

  body.pdf-preview-active #invoiceViewer .invoice-document {
    padding-bottom: 0;
  }

  body.pdf-preview-active #invoiceViewer .fpa-document {
    padding: 14px 10px 0;
  }

  body.pdf-preview-active #invoiceViewer .invoice-viewer-actions {
    position: fixed;
    right: 6px;
    bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    left: 6px;
    z-index: 98;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    max-height: none;
    margin: 0;
    padding: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.18);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  body.pdf-preview-active #invoiceViewer .invoice-viewer-actions button {
    flex: 0 0 auto;
    width: auto !important;
    min-width: 74px;
    max-width: 118px;
    min-height: 44px;
    padding: 5px 8px;
    justify-content: center;
    gap: 5px;
    font-size: 0.68rem;
    line-height: 1.12;
    text-align: center;
    white-space: normal;
  }

  body.pdf-preview-active #invoiceViewer .invoice-viewer-actions button [data-icon] {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
  }

  body.pdf-preview-active #invoiceViewer .invoice-actions-divider {
    flex: 0 0 1px;
    align-self: stretch;
    width: 1px;
    height: auto;
    margin: 0 2px;
    border-top: 0;
    border-left: 1px dashed #cbd5e1;
  }
}

@media (max-width: 380px) {
  body.pdf-preview-active #invoiceViewer {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  .invoice-panel-actions {
    gap: 6px;
  }

  .invoice-panel-actions button {
    min-height: 34px;
    padding-inline: 5px;
    font-size: 0.68rem;
  }

  body.pdf-preview-active #invoiceViewer .invoice-viewer-actions button {
    min-width: 66px;
    max-width: 104px;
    min-height: 40px;
    padding-inline: 6px;
    font-size: 0.64rem;
  }
}

/* Reset robusto preview fattura mobile: il documento resta dentro lo schermo
   e le azioni sono una barra superiore sticky, non una barra fuori popup. */
@media (max-width: 820px) {
  body.pdf-preview-active #invoiceViewer {
    top: max(8px, env(safe-area-inset-top, 0px));
    right: 6px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    left: 6px;
    width: auto;
    max-width: none;
    min-width: 0;
    transform: none;
    overflow: auto;
    padding: 8px;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
  }

  body.pdf-preview-active #invoiceViewer .invoice-document,
  body.pdf-preview-active #invoiceViewer .fpa-document {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    box-sizing: border-box;
  }

  body.pdf-preview-active #invoiceViewer .fpa-document {
    padding: 12px 10px;
    gap: 10px;
  }

  body.pdf-preview-active #invoiceViewer .invoice-viewer-actions {
    order: -1;
    position: sticky;
    top: -8px;
    right: auto;
    bottom: auto;
    left: auto;
    z-index: 30;
    display: flex !important;
    flex-wrap: nowrap;
    gap: 6px;
    width: calc(100% + 20px);
    max-width: none;
    max-height: none;
    margin: -12px -10px 10px;
    padding: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 8px 8px 0 0;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.1);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  body.pdf-preview-active #invoiceViewer .invoice-viewer-actions button {
    flex: 0 0 auto;
    width: auto !important;
    min-width: 72px;
    max-width: 116px;
    min-height: 40px;
    padding: 5px 8px;
    justify-content: center;
    gap: 5px;
    font-size: 0.66rem;
    line-height: 1.12;
    text-align: center;
    white-space: normal;
  }

  body.pdf-preview-active #invoiceViewer .invoice-viewer-actions button [data-icon] {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
  }

  body.pdf-preview-active #invoiceViewer .invoice-actions-divider {
    flex: 0 0 1px;
    align-self: stretch;
    width: 1px;
    height: auto;
    margin: 0 2px;
    border-top: 0;
    border-left: 1px dashed #cbd5e1;
  }

  body.pdf-preview-active #invoiceViewer .fpa-table-wrap {
    max-width: 100%;
    overflow: visible;
  }

  body.pdf-preview-active #invoiceViewer .fpa-header,
  body.pdf-preview-active #invoiceViewer .fpa-section,
  body.pdf-preview-active #invoiceViewer .fpa-party {
    padding: 8px 9px;
  }

  body.pdf-preview-active #invoiceViewer .fpa-title {
    font-size: 1.08rem;
  }

  body.pdf-preview-active #invoiceViewer .fpa-table th,
  body.pdf-preview-active #invoiceViewer .fpa-table td {
    padding: 4px 6px;
    font-size: 0.76rem;
  }

  body.pdf-preview-active #invoiceViewer .fpa-document > :not(.invoice-viewer-actions) {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    zoom: 1;
    transform: none;
  }

  body.pdf-preview-active #invoiceViewer .fpa-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  body.pdf-preview-active #invoiceViewer .fpa-header-status {
    justify-items: start;
  }

  body.pdf-preview-active #invoiceViewer .fpa-parties,
  body.pdf-preview-active #invoiceViewer .fpa-party-grid,
  body.pdf-preview-active #invoiceViewer .fpa-meta-grid,
  body.pdf-preview-active #invoiceViewer .fpa-totals-grid {
    grid-template-columns: 1fr;
  }

  body.pdf-preview-active #invoiceViewer .fpa-table,
  body.pdf-preview-active #invoiceViewer .fpa-table thead,
  body.pdf-preview-active #invoiceViewer .fpa-table tbody,
  body.pdf-preview-active #invoiceViewer .fpa-table tr,
  body.pdf-preview-active #invoiceViewer .fpa-table th,
  body.pdf-preview-active #invoiceViewer .fpa-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  body.pdf-preview-active #invoiceViewer .fpa-table thead {
    position: absolute;
    left: -10000px;
  }

  body.pdf-preview-active #invoiceViewer .fpa-table tbody {
    display: grid;
    gap: 8px;
  }

  body.pdf-preview-active #invoiceViewer .fpa-table tr {
    display: grid;
    gap: 5px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
  }

  body.pdf-preview-active #invoiceViewer .fpa-table td {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 0;
    border: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }

  body.pdf-preview-active #invoiceViewer .fpa-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 800;
    text-align: left;
    text-transform: uppercase;
  }

  body.pdf-preview-active #invoiceViewer .fpa-table td.fpa-line-desc {
    display: block;
    text-align: left;
  }

  body.pdf-preview-active #invoiceViewer .fpa-table td.fpa-line-desc::before {
    display: block;
    margin-bottom: 2px;
  }

  #pdfPreviewClose {
    top: 10px;
    right: 10px;
    z-index: 120;
  }
}

@media (max-width: 390px) {
  body.pdf-preview-active #invoiceViewer .fpa-document {
    padding-inline: 8px;
    font-size: 0.72rem;
  }
}
