@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Manrope:wght@400;600;700&display=swap');

:root {
  --surface: #f8f9fa;
  --surface_container_low: #f3f4f5;
  --surface_container: #edeeef;
  --surface_container_high: #e7e8e9;
  --surface_container_highest: #e1e3e4;
  --on_surface: #191c1d;
  --on_surface_variant: #434656;
  
  --primary: #41557c;
  --primary_container: #596d96;
  --on_primary_container: #ecf0ff;
  
  --tertiary: #006056;
  --outline_variant: rgba(196, 197, 217, 0.15); /* Ghost border */
  --money-positive: #00a86b;
  --money-positive-bg: rgba(0, 168, 107, 0.12);
  --money-negative: #e11d48;
  --money-negative-bg: rgba(225, 29, 72, 0.12);
  
  /* Badges */
  --badge-libero-bg: #8df5e4;
  --badge-libero-text: #005048;
  --badge-occupato-bg: #d8e2ff;
  --badge-occupato-text: #32466d;
  --badge-scaduto-bg: #ffdad6;
  --badge-scaduto-text: #93000a;
  --badge-pagato-bg: #d3e4f8;
  --badge-pagato-text: #394858;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--surface);
  color: var(--on_surface);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, .currency {
  font-family: 'Manrope', sans-serif;
}

/* Layout */
.sidebar {
  width: 260px;
  background-color: var(--surface_container_low);
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  margin-bottom: 32px;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
}

.sidebar-brand h2 {
  margin-bottom: 0;
  padding-left: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 8px 8px;
  padding: 12px 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(65, 85, 124, 0.08), rgba(65, 85, 124, 0.04));
  border: 1px solid rgba(65, 85, 124, 0.1);
  box-shadow: 0 10px 24px rgba(25, 28, 29, 0.04);
}

.sidebar-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  background: linear-gradient(135deg, var(--money-positive) 0%, #35c37f 100%);
  color: #ffffff;
  font-family: 'Manrope', sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 18px rgba(0, 168, 107, 0.24);
  border: 2px solid rgba(255, 255, 255, 0.9);
}

.sidebar-user-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-user-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--on_surface);
  line-height: 1.1;
}

.sidebar-user-role {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--money-positive);
}

.sidebar a {
  text-decoration: none;
  color: var(--on_surface_variant);
  padding: 12px 16px;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease-out;
}

.sidebar a:hover, .sidebar a.active {
  background-color: var(--surface_container_high);
  color: var(--on_surface);
}

.sidebar-version {
  margin: 10px 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(65, 85, 124, 0.06);
  color: var(--on_surface_variant);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.sidebar-menu-toggle {
  display: none;
}

.main-content {
  flex: 1;
  padding: 48px;
  max-width: 1200px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}

/* Cards & Containers (No-line rule) */
.section-container {
  background-color: var(--surface_container_low);
  padding: 32px;
  border-radius: 12px;
  margin-bottom: 32px;
}

.app-global-guide {
  margin-bottom: 28px;
  padding: 22px 24px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(65, 85, 124, 0.08) 0%, rgba(65, 85, 124, 0.04) 100%);
  border: 1px solid rgba(65, 85, 124, 0.14);
  box-shadow: 0 18px 40px rgba(25, 28, 29, 0.05);
}

.app-global-guide-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.app-global-guide-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary_container) 100%);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(65, 85, 124, 0.22);
  font-size: 1.1rem;
}

.app-global-guide-kicker {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
  margin-bottom: 4px;
}

.app-global-guide h3 {
  margin: 0;
  font-size: 1.15rem;
}

.app-global-guide p {
  margin: 6px 0 0;
  color: var(--on_surface_variant);
  font-size: 0.92rem;
}

.app-global-guide-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.app-global-guide-list li {
  position: relative;
  padding-left: 18px;
  color: var(--on_surface_variant);
  font-size: 0.92rem;
}

.app-global-guide-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.68em;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--money-positive);
  box-shadow: 0 0 0 4px rgba(0, 168, 107, 0.12);
}

.flash-message {
  margin-bottom: 24px;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(25, 28, 29, 0.06);
}

.flash-success {
  background: rgba(0, 168, 107, 0.14);
  color: var(--money-positive);
  border: 1px solid rgba(0, 168, 107, 0.24);
}

.flash-error {
  background: rgba(225, 29, 72, 0.14);
  color: var(--money-negative);
  border: 1px solid rgba(225, 29, 72, 0.24);
}

.dashboard-visual-card,
.dashboard-alert-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
  border: 1px solid rgba(65, 85, 124, 0.12);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(25, 28, 29, 0.05);
}

.dashboard-visual-card {
  padding: 18px 18px 14px;
}

.dashboard-visual-card .subtitle,
.dashboard-alert-card .subtitle {
  margin-bottom: 18px;
  color: var(--on_surface);
}

.dashboard-chart-shell {
  background: linear-gradient(180deg, rgba(65, 85, 124, 0.04) 0%, #ffffff 100%);
  border: 1px solid rgba(65, 85, 124, 0.08);
  border-radius: 16px;
  padding: 18px 18px 12px;
}

.dashboard-chart-legend {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--on_surface_variant);
}

.dashboard-alert-card {
  padding: 18px;
}

.dashboard-notifications-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid rgba(65, 85, 124, 0.08);
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(25, 28, 29, 0.02);
}

.alert-item:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(25, 28, 29, 0.06);
}

.alert-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.alert-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.alert-message {
  font-size: 0.95rem;
  color: var(--on_surface);
  font-weight: 500;
}

.alert-arrow {
  font-size: 1.2rem;
  opacity: 0.3;
  transition: all 0.2s ease;
}

.alert-item:hover .alert-arrow {
  opacity: 1;
  transform: translateX(4px);
}

/* Alert Colors */
.alert-warning {
  border-left: 5px solid #ff9800;
}
.alert-warning .alert-title { color: #e68a00; }

.alert-danger {
  border-left: 5px solid var(--money-negative);
  background: rgba(225, 29, 72, 0.02);
}
.alert-danger .alert-title { color: var(--money-negative); }

.alert-info {
  border-left: 5px solid var(--primary);
}
.alert-info .alert-title { color: var(--primary); }

.dashboard-alert-empty {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 14px;
  border: 1px dashed rgba(65, 85, 124, 0.14);
  background: rgba(65, 85, 124, 0.03);
  color: var(--on_surface_variant);
  font-weight: 600;
}

.card {
  background-color: #ffffff; /* surface_container_lowest */
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(25, 28, 29, 0.02);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.kpi-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--on_surface);
  align-self: flex-end;
}
.kpi-label {
  font-size: 0.875rem; /* label-sm */
  color: var(--on_surface_variant);
  font-weight: 500;
}
.kpi-currency { color: var(--money-positive); }

.expense-period-visual {
  margin-bottom: 2rem;
  padding: 1.35rem;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(65, 85, 124, 0.08), rgba(65, 85, 124, 0.03)),
    #ffffff;
  border: 1px solid rgba(65, 85, 124, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.expense-period-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 1rem;
}

.expense-period-kicker {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 4px;
}

.expense-period-head h3 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--on_surface);
}

.expense-period-meta {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0, 168, 107, 0.12);
  color: var(--money-positive);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.expense-period-months {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 10px;
}

.expense-period-month {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 12px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(65, 85, 124, 0.1);
  min-height: 78px;
  justify-content: center;
}

.expense-period-month.is-start,
.expense-period-month.is-end {
  border-color: rgba(0, 168, 107, 0.28);
  background: linear-gradient(180deg, rgba(0, 168, 107, 0.08), rgba(0, 168, 107, 0.03));
}

.expense-period-month-label {
  font-family: 'Manrope', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  color: var(--on_surface);
}

.expense-period-month-year {
  font-size: 0.8rem;
  color: var(--on_surface_variant);
  font-weight: 600;
}

.expense-note-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.expense-note-card {
  padding: 16px 18px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(65, 85, 124, 0.04), #ffffff);
  border: 1px solid rgba(65, 85, 124, 0.1);
}

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

.expense-note-head h4 {
  margin: 0 0 4px;
  font-size: 1rem;
  color: var(--on_surface);
}

.expense-note-head small {
  color: var(--on_surface_variant);
  font-weight: 600;
}

.expense-note-body {
  color: var(--on_surface);
  font-size: 0.95rem;
  line-height: 1.55;
}

.expense-note-attachments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.expense-note-attachment {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(65, 85, 124, 0.05);
  border: 1px solid rgba(65, 85, 124, 0.1);
  color: var(--on_surface);
  text-decoration: none;
}

.expense-note-attachment strong {
  font-size: 0.88rem;
}

.expense-note-attachment span {
  font-size: 0.76rem;
  color: var(--primary);
  font-weight: 700;
}

.expense-note-form-shell {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(65, 85, 124, 0.1);
}

.expense-note-paste-zone {
  padding: 16px 18px;
  border-radius: 14px;
  border: 2px dashed rgba(65, 85, 124, 0.22);
  background: linear-gradient(180deg, rgba(65, 85, 124, 0.04), rgba(255, 255, 255, 0.96));
  color: var(--on_surface_variant);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: text;
  transition: all 0.2s ease;
}

.expense-note-paste-zone:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(65, 85, 124, 0.12);
}

.expense-note-paste-zone.has-success {
  border-color: var(--money-positive);
  background: linear-gradient(180deg, rgba(0, 168, 107, 0.08), rgba(255, 255, 255, 0.96));
}

.expense-note-pasted-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.expense-note-pasted-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(65, 85, 124, 0.05);
  border: 1px solid rgba(65, 85, 124, 0.1);
}

.expense-note-pasted-card img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 8px;
  background: #ffffff;
}

.expense-note-pasted-card small {
  color: var(--on_surface_variant);
  font-weight: 700;
}

.expense-ai-import-card {
  border: 2px solid rgba(65, 85, 124, 0.25);
  background:
    radial-gradient(circle at top right, rgba(255, 196, 94, 0.18), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 248, 234, 0.96));
  box-shadow: 0 4px 16px rgba(65, 85, 124, 0.08);
}

.expense-ai-import-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.expense-ai-import-head h3 {
  margin: 4px 0 6px;
}

.expense-ai-import-head p {
  margin: 0;
  color: var(--on_surface_variant);
}

.expense-ai-import-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
}

.expense-ai-import-result {
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(15, 118, 110, 0.14);
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.expense-ai-warning-list {
  margin: 4px 0 0;
  padding-left: 18px;
}

.expense-ai-warning-list li {
  margin: 4px 0;
}

.money-positive {
  color: var(--money-positive);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.money-negative {
  color: var(--money-negative);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.money-positive-bg {
  background: var(--money-positive-bg);
}

.money-negative-bg {
  background: var(--money-negative-bg);
}

/* Help & Instructions */
.help-section {
    background-color: var(--surface_container);
    border-left: 4px solid var(--primary);
    padding: 20px 24px;
    border-radius: 8px;
    margin-bottom: 24px;
    display: none; /* Hidden by default */
    animation: slideIn 0.3s ease-out;
}

.help-section h3 {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-section ul {
    list-style: none;
    padding-left: 0;
}

.help-section li {
    font-size: 0.875rem;
    color: var(--on_surface_variant);
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.help-section li::before {
    content: "•";
    color: var(--primary);
    font-weight: bold;
}

.btn-help {
    background-color: var(--surface_container_high);
    color: var(--primary);
    padding: 8px 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    border: none;
    transition: all 0.2s;
}

.btn-help:hover {
    background-color: var(--primary);
    color: white;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Typography */
.title { font-size: 2rem; font-weight: 700; }
.subtitle { font-size: 1.25rem; font-weight: 600; margin-bottom: 16px; }

.title-link,
.title-link:visited,
.subtitle-link,
.subtitle-link:visited,
.table-link,
.table-link:visited {
  color: inherit;
  text-decoration: none;
}

.title-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.title-link:hover,
.subtitle-link:hover {
  color: var(--primary);
  opacity: 0.96;
}

.table-link {
  display: inline-block;
  padding: 2px 8px;
  margin: -2px -8px;
  border-radius: 999px;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.table-link:hover {
  color: var(--primary);
  background-color: rgba(65, 85, 124, 0.08);
  box-shadow: inset 0 0 0 1px rgba(65, 85, 124, 0.08);
  transform: translateY(-1px);
}

.title-link:focus-visible,
.subtitle-link:focus-visible,
.table-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 4px;
}

.table-link {
  font-weight: 600;
}

/* Tables */
.table-container {
  background-color: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(25, 28, 29, 0.02);
}

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

th {
  text-align: left;
  padding: 16px 24px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--on_surface_variant);
  font-weight: 600;
  border-bottom: 1px solid var(--outline_variant);
}

td {
  padding: 16px 24px;
  font-size: 0.875rem;
  transition: background-color 0.2s ease-out;
}

tr:hover td {
  background-color: var(--surface_container_high);
}

/* Sortable table header links */
.sort-link {
  color: inherit;
  font-weight: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  font-size: inherit;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
}
.sort-link:hover {
  color: var(--primary);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.libero { background-color: var(--badge-libero-bg); color: var(--badge-libero-text); }
.badge.occupato, .badge.attivo { background-color: var(--badge-occupato-bg); color: var(--badge-occupato-text); }
.badge.scaduto, .badge.insoluto { background-color: var(--badge-scaduto-bg); color: var(--badge-scaduto-text); }
.badge.pagato { background-color: var(--badge-pagato-bg); color: var(--badge-pagato-text); }

.badge.attivo {
  background-color: rgba(0, 168, 107, 0.16);
  color: var(--money-positive);
}

.badge.congelato {
  background-color: rgba(245, 158, 11, 0.16);
  color: #8a5a00;
}

.badge.insoluto {
  background-color: rgba(225, 29, 72, 0.16);
  color: var(--money-negative);
}

.badge-cat {
  text-decoration: none;
  font-size: 0.7rem;
  padding: 3px 8px;
  letter-spacing: 0.03em;
  transition: filter 0.15s, transform 0.15s;
}
.badge-cat:hover {
  filter: brightness(0.92);
  transform: scale(1.05);
}
.badge-cat-luce           { background-color: #fff3c4; color: #7a5e00; }
.badge-cat-gas            { background-color: #ffe0cc; color: #7a3e00; }
.badge-cat-acqua          { background-color: #d4f0ff; color: #005f8a; }
.badge-cat-internet       { background-color: #e0d4ff; color: #4a2e8a; }
.badge-cat-condominio     { background-color: #d4e8d4; color: #2e5a2e; }
.badge-cat-manutenzione   { background-color: #ffe0e0; color: #8a2e2e; }
.badge-cat-pulizie        { background-color: #e8f5e0; color: #3e6b2e; }
.badge-cat-tassa-rifiuti  { background-color: #e0e0e0; color: #4a4a4a; }
.badge-cat-altro          { background-color: #f0f0f0; color: #5a5a5a; }

/* Buttons Forms */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 6px;
  border: none;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease-out;
  text-decoration: none;
}

.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary_container) 100%);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  background-color: var(--surface_container_high);
  color: var(--on_surface);
}

.btn-secondary:hover {
  background-color: var(--surface_container_highest);
}

.btn-warning {
  color: #5f4300;
  background: linear-gradient(135deg, #ffd54f 0%, #ffca28 100%);
  border: 1px solid rgba(95, 67, 0, 0.12);
  box-shadow: 0 10px 24px rgba(255, 202, 40, 0.28);
}

.btn-warning:hover {
  filter: brightness(1.04);
  box-shadow: 0 12px 28px rgba(255, 202, 40, 0.34);
}

.btn-danger {
  background-color: var(--badge-scaduto-bg);
  color: var(--badge-scaduto-text);
}

/* Inputs */
.form-group {
  margin-bottom: 24px;
}
.form-group label {
  display: block;
  font-size: 0.875rem;
  color: var(--on_surface_variant);
  margin-bottom: 8px;
}
.form-control {
  width: 100%;
  padding: 12px;
  font-size: 0.875rem;
  font-family: inherit;
  border: none;
  border-bottom: 2px solid var(--surface_container_highest);
  background-color: var(--surface_container_low);
  transition: all 0.2s ease-out;
}
.form-control:focus {
  outline: none;
  border-bottom-color: var(--primary);
  background-color: var(--surface_container);
}
.form-group select.form-control {
  appearance: none;
}

/* Modal/Glassmorphism */
.modal {
  background: rgba(248, 249, 250, 0.8);
  backdrop-filter: blur(12px);
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow-y: auto;
  padding: 20px;
}

.modal-content {
  background-color: #ffffff;
  padding: 32px;
  border-radius: 12px;
  width: 95%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(25, 28, 29, 0.06);
  position: relative;
  scrollbar-width: thin;
}

/* Launcher wrap is defined below with flex layout */

.ticket-launcher {
  border: none;
  border-radius: 999px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--money-negative) 0%, #ff5a78 100%);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: 0 16px 30px rgba(225, 29, 72, 0.28);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.ticket-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 38px rgba(225, 29, 72, 0.34);
  filter: brightness(1.03);
}

.ticket-launcher-wrap {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ticket-launcher-toggle {
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(225, 29, 72, 0.12);
  color: var(--money-negative);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.ticket-launcher-toggle:hover {
  background: rgba(225, 29, 72, 0.22);
  transform: scale(1.1);
}

.ticket-launcher-wrap.is-collapsed .ticket-launcher {
  display: none !important;
}

.ticket-launcher-wrap.is-collapsed .ticket-launcher-toggle {
  background: linear-gradient(135deg, var(--money-negative) 0%, #ff5a78 100%);
  color: #fff;
  width: 36px;
  height: 36px;
  box-shadow: 0 8px 16px rgba(225, 29, 72, 0.2);
}

.report-widget {
  position: fixed;
  inset: auto 18px 80px 18px;
  display: none;
  justify-content: flex-start;
  z-index: 1199;
  pointer-events: none;
}

.report-widget.is-open {
  display: flex;
}

.report-widget-card {
  width: min(100%, 420px);
  max-height: calc(100vh - 120px);
  overflow: auto;
  pointer-events: auto;
  background: linear-gradient(180deg, #ffffff 0%, #fbfbfd 100%);
  border: 1px solid rgba(65, 85, 124, 0.12);
  border-radius: 22px;
  box-shadow: 0 24px 54px rgba(25, 28, 29, 0.16);
  padding: 22px;
}

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

.report-widget-kicker {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--money-negative);
  font-weight: 800;
  margin-bottom: 4px;
}

.report-widget-header h3 {
  font-size: 1.25rem;
  margin: 0;
}

.report-widget-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--surface_container_high);
  color: var(--on_surface_variant);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.report-widget-bubble {
  background: linear-gradient(180deg, rgba(65, 85, 124, 0.06), rgba(65, 85, 124, 0.03));
  border: 1px solid rgba(65, 85, 124, 0.08);
  border-radius: 18px;
  padding: 14px 16px;
  color: var(--on_surface_variant);
  font-size: 0.92rem;
  margin-bottom: 18px;
}

.report-widget-form .form-group {
  margin-bottom: 16px;
}

.report-type-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(225, 29, 72, 0.12);
  color: var(--money-negative);
  font-weight: 800;
  font-size: 0.82rem;
}

.report-capture-box {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(65, 85, 124, 0.04);
  border: 1px solid rgba(65, 85, 124, 0.08);
  margin-bottom: 16px;
}

.report-capture-box p {
  margin: 6px 0 0;
  color: var(--on_surface_variant);
  font-size: 0.85rem;
}

.report-preview {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(65, 85, 124, 0.08);
}

.report-preview img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 12px;
  display: block;
  margin-bottom: 10px;
}

.report-preview-meta {
  font-size: 0.85rem;
  color: var(--on_surface_variant);
}

.report-widget-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.ticket-list {
  display: grid;
  gap: 20px;
}

.ticket-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 10px 28px rgba(25, 28, 29, 0.05);
  border: 1px solid rgba(65, 85, 124, 0.08);
}

.ticket-card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.ticket-kicker {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--on_surface_variant);
  font-weight: 700;
  margin-bottom: 6px;
}

.ticket-title {
  font-size: 1.2rem;
  margin: 0;
}

.ticket-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ticket-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
  color: var(--on_surface_variant);
  font-size: 0.9rem;
}

.ticket-message {
  background: linear-gradient(180deg, rgba(65, 85, 124, 0.04), rgba(65, 85, 124, 0.02));
  border: 1px solid rgba(65, 85, 124, 0.08);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 18px;
  white-space: pre-wrap;
}

.ticket-attachments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.ticket-shot {
  display: block;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1px solid rgba(65, 85, 124, 0.08);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(25, 28, 29, 0.04);
}

.ticket-shot span {
  display: block;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  background: rgba(65, 85, 124, 0.04);
}

.ticket-shot img {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.ticket-admin-note {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(0, 168, 107, 0.08);
  color: var(--on_surface);
}

.ticket-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.ticket-status-form {
  display: inline-flex;
}

.alert {
  padding: 16px;
  border-radius: 6px;
  margin-bottom: 24px;
  font-weight: 500;
  font-size: 0.875rem;
}
.alert-success { background-color: var(--badge-libero-bg); color: var(--badge-libero-text); }
.alert-error { background-color: var(--badge-scaduto-bg); color: var(--badge-scaduto-text); }

/* Utilities */
.text-right { text-align: right; }
.flex { display: flex; flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* Gallery Layout */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface_container);
  border: 4px solid #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}

.gallery-item img:hover {
  transform: scale(1.05);
}

.gallery-item .delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--badge-scaduto-text);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.muted {
  color: var(--on_surface_variant);
  font-size: 0.9rem;
}

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

.form-group-wide {
  grid-column: 1 / -1;
}

.filters-bar,
.link-create-form,
.question-status-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.media-card,
.question-card {
  background: #fff;
  border: 1px solid var(--outline_variant);
  border-radius: 8px;
  overflow: hidden;
}

.media-preview {
  height: 170px;
  background: var(--surface_container);
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-preview img,
.media-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-file-icon {
  font-weight: 800;
  color: var(--primary);
  border: 1px solid var(--outline_variant);
  border-radius: 6px;
  padding: 10px 14px;
}

.media-card-body {
  padding: 14px;
}

.media-card-body h3 {
  font-size: 1rem;
  margin: 0 0 6px;
}

.media-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.media-use-badge {
  flex-shrink: 0;
  border: 1px solid var(--outline_variant);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--surface_container_low);
}

.media-card-body p,
.media-meta {
  color: var(--on_surface_variant);
  font-size: 0.85rem;
  margin: 0;
}

.media-edit-details {
  margin-top: 12px;
  border-top: 1px solid var(--outline_variant);
  padding-top: 10px;
}

.media-edit-details summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--primary);
  font-size: 0.85rem;
}

.media-edit-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--outline_variant);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  color: var(--on_surface_variant);
}

.annuncio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 20px;
  align-items: start;
}

.annuncio-media-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 12px;
  max-height: 900px;
  overflow: auto;
  padding-right: 4px;
}

.listing-media-upload {
  border: 1px dashed var(--outline_variant);
  border-radius: 8px;
  background: var(--surface_container_low);
  padding: 14px;
  margin-bottom: 16px;
}

.annuncio-upload-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.annuncio-upload-chip {
  border: 1px solid var(--outline_variant);
  border-radius: 999px;
  background: #fff;
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 700;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-select-card {
  border: 1px solid var(--outline_variant);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 6px;
  cursor: pointer;
  background: #fff;
}

.media-select-card:has(input[type="checkbox"]:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(65, 85, 124, 0.12);
}

.media-select-preview {
  height: 95px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface_container);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--primary);
}

.media-select-preview img,
.media-select-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-select-title {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
  min-height: 2.1em;
}

.media-cover-choice {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--on_surface_variant);
}

.media-order-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.media-order-controls .btn {
  padding: 6px 8px;
  font-size: 0.75rem;
}

.share-link-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.share-link-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--outline_variant);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.share-url {
  font-family: monospace;
  font-size: 0.82rem;
  word-break: break-all;
  color: var(--primary);
  margin: 4px 0;
}

.question-inbox {
  display: grid;
  gap: 14px;
}

.question-card {
  padding: 18px;
}

.question-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.question-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-content: flex-start;
}

.ai-provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.ai-provider-card {
  background: var(--surface_container_high);
  border: 1px solid var(--outline_variant);
  border-radius: 8px;
  padding: 18px;
}

.ai-provider-card h3 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.ai-faq-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.ai-faq-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(260px, 1.15fr);
  gap: 10px;
}

.public-ai-chat {
  border-bottom: 1px solid var(--outline_variant);
  margin-bottom: 22px;
  padding-bottom: 22px;
}

.ai-chat-suggestions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.ai-chat-suggestions button {
  border: 1px solid var(--outline_variant);
  background: var(--surface_container_low);
  color: var(--on_surface);
  border-radius: 999px;
  padding: 7px 10px;
  font-weight: 700;
  cursor: pointer;
}

.ai-chat-log {
  display: grid;
  gap: 8px;
  max-height: 310px;
  overflow: auto;
  border: 1px solid var(--outline_variant);
  background: #fff;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}

.ai-chat-message {
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.ai-chat-message.assistant {
  background: var(--surface_container_low);
  color: var(--on_surface);
}

.ai-chat-message.user {
  background: var(--primary);
  color: #fff;
  justify-self: end;
  max-width: 88%;
}

.ai-chat-message.loading {
  opacity: 0.75;
}

.ai-chat-form {
  display: grid;
  gap: 10px;
}

.question-card h3 {
  margin: 0 0 4px;
}

.question-card p {
  margin: 8px 0;
}

.question-context {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--on_surface_variant);
  font-size: 0.85rem;
  margin: 10px 0;
}

.question-row {
  border-top: 1px solid var(--outline_variant);
  padding: 12px 0;
}

.public-listing-body {
  display: block;
  background: #f7f8fb;
}

.public-listing {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 18px 48px;
}

.public-card {
  background: #fff;
  border: 1px solid var(--outline_variant);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(25, 28, 29, 0.04);
}

.form-honeypot {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
}

.conversation-workspace {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.conversation-list,
.conversation-detail {
    background: var(--surface, #fff);
    border: 1px solid var(--outline-variant, #dfe3e8);
    border-radius: 8px;
    overflow: hidden;
}

.conversation-list-item {
    display: block;
    padding: 14px;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid var(--outline-variant, #dfe3e8);
}

.conversation-list-item:hover,
.conversation-list-item.active {
    background: var(--surface-container, #f3f5f7);
}

.conversation-list-head,
.conversation-list-meta,
.conversation-message-meta,
.conversation-detail-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.conversation-list-item p,
.conversation-list-meta,
.conversation-detail-head p {
    margin: 6px 0 0;
    color: var(--on-surface-variant, #5f6368);
    font-size: .86rem;
}

.conversation-warning {
    display: inline-block;
    margin-top: 8px;
    color: #a13b27;
    font-size: .82rem;
    font-weight: 700;
}

.conversation-detail {
    padding: 18px;
}

.conversation-detail-head {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--outline-variant, #dfe3e8);
}

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

.conversation-messages {
    display: grid;
    gap: 12px;
    padding: 16px 0;
    max-height: 620px;
    overflow-y: auto;
}

.conversation-message {
    max-width: 85%;
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--surface-container, #f3f5f7);
}

.conversation-message.assistant {
    margin-left: auto;
    background: #eef6f2;
}

.conversation-message p {
    margin: 8px 0 0;
}

.conversation-message-meta {
    font-size: .78rem;
    color: var(--on-surface-variant, #5f6368);
}

.guardrail-result {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,.08);
    font-size: .78rem;
}

.guardrail-result.safe { color: #236b49; }
.guardrail-result.blocked { color: #a13b27; }

.conversation-review-form {
    display: grid;
    grid-template-columns: 180px 180px minmax(240px, 1fr) auto;
    gap: 10px;
    align-items: end;
    padding-top: 14px;
    border-top: 1px solid var(--outline-variant, #dfe3e8);
}

.notification-settings {
    display: grid;
    grid-template-columns: minmax(220px, 1.2fr) minmax(220px, 1fr);
    gap: 12px 20px;
    margin: 18px 0;
    padding: 16px 0;
    border-top: 1px solid var(--outline-variant, #dfe3e8);
    border-bottom: 1px solid var(--outline-variant, #dfe3e8);
}

.notification-settings h3,
.notification-settings p {
    margin-top: 0;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lead-actions {
    display: flex;
    gap: 12px;
    align-items: end;
    margin-top: 12px;
}

.lead-reply-form {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 10px;
    flex: 1;
    align-items: end;
}

.lead-history {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--outline-variant, #dfe3e8);
}

.lead-history > div {
    padding: 10px 0;
    border-bottom: 1px solid var(--outline-variant, #dfe3e8);
}

.lead-history span {
    margin-left: 10px;
    color: var(--on-surface-variant, #5f6368);
    font-size: .82rem;
}

.lead-history p {
    margin: 6px 0 0;
}

.translation-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 8px 16px;
    align-items: center;
}

.translation-toolbar h2,
.translation-toolbar p {
    margin-top: 0;
}

.translation-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.translation-actions label {
    display: flex;
    align-items: center;
    gap: 4px;
}

.media-dropzone {
    padding: 16px;
    border: 2px dashed var(--outline-variant, #c8cdd3);
    border-radius: 8px;
    transition: border-color .15s ease, background-color .15s ease;
}

.media-dropzone.dragging {
    border-color: var(--primary, #176b55);
    background: #eef6f2;
}

.annuncio-upload-chip {
    position: relative;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 28px;
    align-items: center;
    gap: 8px;
}

.annuncio-upload-chip img,
.annuncio-upload-chip video {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 4px;
}

.annuncio-upload-chip button {
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    font-size: 1.25rem;
    cursor: pointer;
}

.media-upload-chip-simple {
    display: block;
}

.upload-progress {
    position: relative;
    height: 28px;
    overflow: hidden;
    border-radius: 4px;
    background: var(--surface-container, #edf0f2);
}

.upload-progress > div {
    width: 0;
    height: 100%;
    background: var(--primary, #176b55);
    transition: width .12s linear;
}

.upload-progress > span {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
}

.public-media-item {
    position: relative;
    cursor: zoom-in;
}

.public-media-caption {
    position: absolute;
    right: 8px;
    bottom: 8px;
    left: 8px;
    padding: 6px 8px;
    overflow: hidden;
    color: #fff;
    background: rgba(0, 0, 0, .65);
    font-size: .78rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.public-lightbox {
    width: min(1100px, calc(100vw - 32px));
    max-width: none;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: #111;
    color: #fff;
}

.public-lightbox::backdrop {
    background: rgba(0, 0, 0, .82);
}

.public-lightbox-toolbar,
.public-lightbox-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
    padding: 8px 14px;
}

.public-lightbox button {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 4px;
    background: #fff;
    color: #111;
    font-size: 1.5rem;
    cursor: pointer;
}

.public-lightbox-content {
    display: grid;
    place-items: center;
    min-height: 55vh;
    max-height: 75vh;
    background: #000;
}

.public-lightbox-content img,
.public-lightbox-content video {
    display: block;
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
}

.privacy-consent-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 10px 0;
    font-size: .84rem;
    line-height: 1.35;
}

.privacy-consent-row input {
    margin-top: 2px;
    flex: 0 0 auto;
}

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

.maintenance-list {
    display: grid;
    gap: 8px;
    margin-top: 16px;
}

.maintenance-list > div,
.maintenance-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--outline-variant, #dfe3e8);
}

.maintenance-list span,
.maintenance-row span {
    color: var(--on-surface-variant, #5f6368);
    font-size: .84rem;
}

#translation-status {
    grid-column: 1 / -1;
}

@media (max-width: 900px) {
    .main-content {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    .conversation-workspace { grid-template-columns: 1fr; }
    .conversation-review-form { grid-template-columns: 1fr; }
    .conversation-message { max-width: 95%; }
    .notification-settings { grid-template-columns: 1fr; }
    .lead-actions,
    .lead-reply-form { display: grid; grid-template-columns: 1fr; }
    .translation-toolbar { grid-template-columns: 1fr; }
    .translation-actions { justify-content: flex-start; }
    .system-grid {
        grid-template-columns: minmax(0, 1fr);
        min-width: 0;
        max-width: 100%;
    }
    .system-grid > *,
    .system-grid .section-container {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }
    .maintenance-list > div,
    .maintenance-row {
        align-items: flex-start;
        flex-direction: column;
    }
}

.public-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.public-section-head h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.public-section-head p {
  margin: 0;
  color: var(--on_surface_variant);
}

.public-section-head span {
  border: 1px solid var(--outline_variant);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--surface_container_low);
  white-space: nowrap;
}

.public-password {
  max-width: 460px;
  margin: 14vh auto;
  background: #fff;
  border-radius: 8px;
  padding: 28px;
  border: 1px solid var(--outline_variant);
}

.public-password form {
  display: grid;
  gap: 12px;
}

.public-hero {
  padding: 26px;
  margin-bottom: 18px;
}

.public-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 4vw, 3.5rem);
}

.public-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.public-facts span {
  border: 1px solid var(--outline_variant);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--surface_container_low);
  font-weight: 700;
}

.public-gallery-card {
  padding: 18px;
  margin-bottom: 18px;
}

.public-gallery {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) repeat(2, minmax(150px, 0.75fr));
  gap: 12px;
}

.public-media-item {
  min-height: 180px;
  background: var(--surface_container);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--outline_variant);
}

.public-media-item:first-child {
  grid-column: span 2;
  grid-row: span 2;
}

.public-media-item img,
.public-media-item video {
  width: 100%;
  height: 100%;
  min-height: 180px;
  object-fit: cover;
  display: block;
}

.public-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.public-question-box {
  padding: 22px;
}

.public-details-card {
  padding: 22px;
}

.public-lang-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.public-lang-tabs button {
  border: 1px solid var(--outline_variant);
  background: #fff;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 800;
}

.public-lang-tabs button.active {
  background: var(--primary);
  color: #fff;
}

.public-description {
  display: none;
  line-height: 1.65;
}

.public-description.active {
  display: block;
}

.public-map {
  margin-top: 22px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--outline_variant);
}

.public-map iframe {
  width: 100%;
  height: 320px;
  border: 0;
  display: block;
}


/* Calendar Grid */
/* Calendar Premium Redesign */
.calendar-container {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.03);
    overflow-x: auto;
}

.calendar-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 4px;
    min-width: 900px;
}

.calendar-table th {
    background: none;
    border: none;
    text-align: center;
    font-size: 11px;
    color: var(--on_surface_variant);
    padding: 12px 4px;
    font-weight: 700;
    text-transform: uppercase;
}

.calendar-table .group-row td {
    background-color: var(--surface_container_low);
    padding: 10px 16px;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--primary);
    border-radius: 8px;
    border: none;
}

.calendar-table .unit-row td {
    padding: 2px;
    border: none;
}

.calendar-table .unit-label {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--on_surface);
    width: 180px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-cell {
    height: 44px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--outline_variant);
}

.calendar-cell:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.calendar-cell.free {
    background-color: var(--badge-libero-bg);
    color: var(--badge-libero-text);
    opacity: 0.4;
}

.calendar-cell.occupied {
    background-color: var(--badge-occupato-bg);
    color: var(--badge-occupato-text);
}

.calendar-cell.expiring {
    background-color: var(--badge-scaduto-bg);
    color: var(--badge-scaduto-text);
    border: 1px dashed var(--badge-scaduto-text);
}

.calendar-cell.current-month {
    border: 2px solid var(--primary);
}

.day-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 800;
    margin-top: 2px;
}
.day-badge-in {
    background-color: var(--tertiary);
    color: white;
}
.day-badge-out {
    background-color: #f44336;
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
  body { flex-direction: column; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 10px 14px;
    box-sizing: border-box;
  }
  .sidebar-brand { margin: 0; }
  .sidebar-menu-toggle {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: var(--surface_container_high);
    color: var(--on_surface);
    font-size: 1.35rem;
    cursor: pointer;
  }
  .sidebar:not(.menu-open) > a,
  .sidebar:not(.menu-open) > .sidebar-user,
  .sidebar:not(.menu-open) > .sidebar-version,
  .sidebar:not(.menu-open) > div[style] {
    display: none;
  }
  .sidebar > a,
  .sidebar > .sidebar-user,
  .sidebar > .sidebar-version,
  .sidebar > div[style] {
    grid-column: 1 / -1;
  }
  .sidebar-user { width: 100%; margin: 8px 0; }
  .main-content { padding: 20px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
  .page-header .flex { width: 100%; justify-content: space-between; }
  .help-section { padding: 16px; }
  .table-container { margin: 0 -20px; border-radius: 0; border-left: none; border-right: none; }
  .table-container table { font-size: 13px; }
  th, td { padding: 12px 16px; }
  .ticket-launcher-wrap { left: 12px; bottom: 12px; }
  .report-widget { inset: auto 12px 72px 12px; }
  .report-widget-card { width: 100%; }
  
  /* Modal Mobile Optimizations */
  .modal {
    padding: 8px;
    align-items: flex-start;
  }
  .modal-content {
    padding: 24px 16px;
    margin: 10px auto;
    border-radius: 16px;
    width: 100%;
    max-width: 100%;
    max-height: 95vh;
  }
  .flex:not(.flex-nowrap) {
    flex-direction: column !important;
    gap: 12px;
  }
  .flex:not(.flex-nowrap) > * {
    width: 100% !important;
    flex: none !important;
  }
  .modal-content .btn {
    width: 100%;
    text-align: center;
    padding: 14px;
    font-size: 1rem;
  }
  .form-group {
    margin-bottom: 16px;
  }
  .form-grid,
  .annuncio-layout,
  .ai-faq-row,
  .public-content,
  .public-gallery {
    grid-template-columns: 1fr;
  }
  .public-media-item:first-child {
    grid-column: auto;
    grid-row: auto;
  }
  .share-link-row,
  .question-card-head,
  .filters-bar,
  .link-create-form,
  .question-status-form {
    flex-direction: column;
    align-items: stretch;
  }
}
