/* MOBILE MANAGER V1 — smartphone-first overrides for the private management UI. */
@media (max-width: 820px) {
  html, body { overflow-x: hidden; }
  body { font-size: 13px; }
  .app { min-height: 100dvh; }

  .sidebar {
    width: min(78vw, 260px);
    padding: 14px 10px;
    box-shadow: 14px 0 36px rgba(13, 22, 16, .24);
  }
  .brand { gap: 8px; padding: 0 8px 13px; }
  .brand-mark { font-size: 31px; }
  .brand b { font-size: 14px; }
  .brand small { font-size: 9px; letter-spacing: 1.4px; }
  .sidebar nav { gap: 2px; }
  .sidebar nav button { gap: 8px; padding: 10px; border-radius: 9px; font-size: 13px; }
  .sidebar nav button span { width: 20px; }
  .sidebar-bottom { gap: 2px; }
  .sidebar-bottom a, .sidebar-bottom button { padding: 9px 10px; font-size: 12px; }

  .topbar {
    height: 64px;
    min-height: 64px;
    padding: 7px 10px;
    gap: 7px;
  }
  .menu-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 9px;
    background: #fff;
    border: 1px solid var(--line);
    font-size: 20px;
  }
  .topbar p { display: none; }
  .topbar h1 { margin: 0; font-size: 20px; line-height: 1.05; }
  .top-actions { gap: 6px; }
  .top-actions .primary { width: 36px; height: 36px; }

  main { padding: 10px 9px 28px; }
  .toolbar {
    margin-bottom: 10px;
    gap: 7px;
    overflow: visible;
    flex-wrap: wrap;
    align-items: flex-end;
    padding-bottom: 0;
  }
  .toolbar h2 { flex: 1 0 100%; margin: 0; font-size: 20px; }
  .toolbar label { min-width: 0; flex: 1 1 120px; font-size: 10px; gap: 4px; }
  .toolbar input, .toolbar select { min-width: 0; padding: 8px 9px; font-size: 12px; }
  .toolbar button, .panel button { padding: 8px 10px; border-radius: 8px; font-size: 12px; }

  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
  .metric { min-width: 0; padding: 11px; border-radius: 12px; }
  .metric small { font-size: 10px; line-height: 1.25; }
  .metric strong { margin: 5px 0; font-size: 20px; overflow-wrap: anywhere; }
  .metric em { font-size: 9px; }
  .two-cols { gap: 10px; margin-bottom: 10px; }
  .panel { padding: 12px; border-radius: 13px; }
  .panel-head { align-items: flex-start; gap: 8px; margin-bottom: 9px; }
  .panel-head h2, .controls-panel h2 { font-size: 18px; }
  .panel-head button { padding: 6px 8px; font-size: 10px; }

  .list { gap: 6px; }
  .list-item { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 8px; padding: 8px; border-radius: 9px; }
  .list-date { width: 40px; padding: 5px 2px; font-size: 11px; }
  .list-item h4 { font-size: 12px; }
  .list-item p { font-size: 10px; overflow-wrap: anywhere; }
  .list-value { font-size: 10px; text-align: right; }
  .empty { padding: 18px !important; font-size: 12px; }

  .bar-chart { min-height: 170px; gap: 6px; padding-top: 8px; }
  .bar-col { min-width: 34px; gap: 4px; }
  .bar-pair { height: 125px; }
  .bar-col small { font-size: 8px; }

  /* Tables become compact cards instead of desktop-width horizontal sheets. */
  .table-panel { padding: 0; overflow: visible; background: transparent; border: 0; box-shadow: none; }
  .table-wrap { overflow: visible; }
  table { min-width: 0 !important; width: 100%; }
  table thead { display: none; }
  table tbody { display: grid; gap: 8px; }
  table tbody tr {
    display: block;
    width: 100%;
    padding: 9px 10px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 5px 16px rgba(28, 39, 31, .05);
  }
  table tbody td {
    display: grid;
    grid-template-columns: 102px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    width: 100%;
    padding: 5px 0;
    border: 0;
    font-size: 11px;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
  table tbody td::before {
    color: var(--muted);
    font-size: 9px;
    line-height: 1.3;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .45px;
  }
  table tbody td:last-child { display: flex; justify-content: flex-end; padding-top: 7px; }
  table tbody td:last-child::before { content: none; }
  table tbody td.empty { display: block; text-align: center; }
  table tbody td.empty::before { content: none; }
  table tbody td strong { font-size: 12px; }
  .icon-btn { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #f8f8f5; }

  #bookingsBody td:nth-child(1)::before { content: 'Ospite'; }
  #bookingsBody td:nth-child(2)::before { content: 'Soggiorno'; }
  #bookingsBody td:nth-child(3)::before { content: 'Fonte'; }
  #bookingsBody td:nth-child(4)::before { content: 'Pagato'; }
  #bookingsBody td:nth-child(5)::before { content: 'Pulizie'; }
  #bookingsBody td:nth-child(6)::before { content: 'Netto'; }
  #bookingsBody td:nth-child(7)::before { content: 'Stato'; }

  #cleaningsBody td:nth-child(1)::before { content: 'Data'; }
  #cleaningsBody td:nth-child(2)::before { content: 'Prenotazione'; }
  #cleaningsBody td:nth-child(3)::before { content: 'Assegnata'; }
  #cleaningsBody td:nth-child(4)::before { content: 'Costo'; }
  #cleaningsBody td:nth-child(5)::before { content: 'Stato'; }
  #cleaningsBody td:nth-child(6)::before { content: 'Note'; }

  #pricesBody td:nth-child(1)::before { content: 'Data'; }
  #pricesBody td:nth-child(2)::before { content: 'Giorno'; }
  #pricesBody td:nth-child(3)::before { content: 'Base'; }
  #pricesBody td:nth-child(4)::before { content: 'Consigliato'; }
  #pricesBody td:nth-child(5)::before { content: 'Manuale'; }
  #pricesBody td:nth-child(6)::before { content: 'Min. notti'; }
  #pricesBody td:nth-child(7)::before { content: 'Motivo'; }

  #eventsBody td:nth-child(1)::before { content: 'Data'; }
  #eventsBody td:nth-child(2)::before { content: 'Evento'; }
  #eventsBody td:nth-child(3)::before { content: 'Luogo'; }
  #eventsBody td:nth-child(4)::before { content: 'Fonte'; }
  #eventsBody td:nth-child(5)::before { content: 'Impatto'; }
  #eventsBody td:nth-child(6)::before { content: 'Moltiplicatore'; }

  #usersBody td:nth-child(1)::before { content: 'Nome'; }
  #usersBody td:nth-child(2)::before { content: 'Email'; }
  #usersBody td:nth-child(3)::before { content: 'Ruolo'; }
  #usersBody td:nth-child(4)::before { content: 'Creato'; }

  /* Calendar becomes a readable two-card mobile grid. */
  .calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px;
    overflow: visible !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  .calendar-grid .cal-head { display: none; }
  .cal-day {
    min-height: 124px !important;
    padding: 8px !important;
    border: 1px solid var(--line) !important;
    border-radius: 11px;
    background: #fff;
  }
  .cal-day.out { opacity: .55; }
  .cal-number { margin-bottom: 5px !important; font-size: 11px !important; }
  .cal-availability, .cal-availability-dot { top: 7px !important; right: 7px !important; width: 8px !important; height: 8px !important; }
  .cal-rate { gap: 2px !important; margin-bottom: 4px !important; }
  .cal-rate strong { font-size: 17px !important; }
  .cal-rate span { font-size: 8px !important; line-height: 1.25 !important; }
  .cal-price-large { margin-top: 11px !important; font-size: 17px !important; }
  .cal-price-note { margin-top: 4px !important; font-size: 8px !important; }
  .cal-event, .cal-booking { margin-top: 4px !important; font-size: 8px !important; }
  .cal-booking { padding: 4px 5px !important; }
  .calendar-legend { gap: 9px; margin: 0 0 9px; font-size: 9px; }

  .form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
  .form-row label { min-width: 0; }
  .form-row button { align-self: end; }
  .guide-editors { grid-template-columns: 1fr; gap: 8px; }
  .guide-card { padding: 11px; border-radius: 12px; }
  .guide-card h3 { margin-bottom: 8px; font-size: 17px; }
  .settings-grid { gap: 9px; padding: 11px; }
  .settings-actions { gap: 7px; padding-top: 3px; }

  /* Mobile forms behave like a bottom sheet and use the full usable width. */
  .modal { align-items: end; padding: 0; }
  .modal-card {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    padding: 16px 14px 14px;
    border-radius: 18px 18px 0 0;
  }
  .modal-card h2 { margin: 0 34px 12px 0; font-size: 21px; }
  .modal-close { right: 10px; top: 7px; font-size: 26px; }
  .modal-form-grid { gap: 8px; }
  .modal-form-grid label { font-size: 10px; gap: 4px; }
  input, select, textarea { padding: 9px 10px; border-radius: 8px; font-size: 14px; }
  textarea { min-height: 82px; }
  .modal-actions { gap: 7px; padding-top: 5px; flex-wrap: wrap; }
  .modal-actions .primary { flex: 1 1 150px; }

  .pricing-summary-card { border-radius: 13px; }
  .pricing-summary-head { padding: 11px; }
  .pricing-summary-head h3 { font-size: 15px; }
  .pricing-mini-controls { gap: 7px; margin-top: 9px; }
  .pricing-breakdown { padding: 4px 10px 9px; }
  .pricing-breakdown > div { gap: 8px; padding: 5px 0; font-size: 11px; }
  .pricing-nightly-field { margin: 10px 10px 2px; }

  .toast { left: 9px; right: 9px; bottom: 9px; max-width: none; padding: 11px 12px; font-size: 12px; }
  .auth-screen { padding: 12px; }
  .auth-card { padding: 20px; border-radius: 18px; }
  .auth-brand { margin-bottom: 18px; }
  .auth-brand span { font-size: 42px; }
  .auth-brand strong { font-size: 21px; }
}

@media (max-width: 430px) {
  .topbar h1 { font-size: 18px; }
  .metric-grid { gap: 7px; }
  .metric { padding: 10px; }
  .metric strong { font-size: 18px; }
  table tbody td { grid-template-columns: 88px minmax(0, 1fr); gap: 6px; }
  .form-row { grid-template-columns: 1fr; }
  .cal-day { min-height: 118px !important; }
  .cal-rate strong, .cal-price-large { font-size: 16px !important; }
}
