/* Mobile layout for the same Eventos Ruiz app and database. */
.mobile-nav-toggle,
.mobile-bottom-nav,
#mobile-backdrop { display: none; }

@media (max-width: 760px) {
  html, body { min-width: 320px; overflow-x: hidden; }
  body { padding-bottom: env(safe-area-inset-bottom); }
  aside#app-sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); height: 100dvh;
    z-index: 1001; overflow-y: auto; transform: translateX(-105%);
    transition: transform .2s ease; padding: 18px 15px;
  }
  body.mobile-nav-open aside#app-sidebar { transform: translateX(0); box-shadow: 10px 0 30px #10253635; }
  #mobile-backdrop {
    display: none; position: fixed; inset: 0; z-index: 1000; width: 100%; height: 100%;
    padding: 0; border: 0; border-radius: 0; background: #10253675;
  }
  body.mobile-nav-open #mobile-backdrop { display: block; }
  main { margin-left: 0 !important; min-width: 0; width: 100%; }
  main > header {
    position: sticky; top: 0; z-index: 50; height: 58px; min-height: 58px;
    padding: 0 12px; gap: 10px; justify-content: flex-start;
  }
  .mobile-nav-toggle { display: inline-flex; align-items: center; justify-content: center; min-width: 42px; min-height: 42px; font-size: 21px; }
  main > header > span { font-size: 14px; }
  main > header > div { margin-left: auto; font-size: 13px; white-space: nowrap; }
  main > header > div button { min-height: 38px; padding: 7px 10px; }
  .content { width: 100%; max-width: none; padding: 16px 12px calc(82px + env(safe-area-inset-bottom)); }
  .heading { align-items: stretch; flex-direction: column; gap: 10px; margin-bottom: 16px; }
  .heading h1 { font-size: 26px; margin: 0; }
  .heading > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
  .heading > div:last-child button { flex: 1 1 auto; }
  .panel { padding: 14px; margin-bottom: 14px; border-radius: 12px; }
  .bar, .toolbar { flex-wrap: wrap; gap: 8px; }
  button, input, select, textarea { font-size: 16px; }
  button { min-height: 42px; }
  .inventory-filters { grid-template-columns: 1fr; gap: 10px; }
  .inventory-filters input, .inventory-filters select { width: 100%; min-width: 0; }
  .mobile-bottom-nav {
    position: fixed; inset: auto 0 0; z-index: 900; display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: #fff; border-top: 1px solid #d9e4e9; box-shadow: 0 -4px 18px #10253612;
  }
  .mobile-bottom-nav button {
    display: flex; min-width: 0; min-height: 54px; padding: 5px 2px; border: 0;
    flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    background: transparent; color: #49657a; font-size: 10px; line-height: 1.15;
  }
  .mobile-bottom-nav button b { font-size: 17px; }
  .mobile-bottom-nav button.active { color: #008e96; font-weight: 700; background: #e8f5f2; border-radius: 9px; }
  /* Inventory rows become readable cards instead of a tiny ten-column table. */
  #inventory-table { overflow: visible; }
  #inventory-table table { display: block; width: 100%; min-width: 0; border-collapse: separate; border-spacing: 0; }
  #inventory-table thead { display: none; }
  #inventory-table tbody { display: grid; gap: 11px; }
  #inventory-table tr { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 0 10px; padding: 11px; border: 1px solid #dce6eb; border-radius: 12px; background: #fff; }
  #inventory-table td { display: block; min-width: 0; padding: 5px 0; border: 0; overflow-wrap: anywhere; }
  #inventory-table td:first-child { grid-column: 1; grid-row: 1; }
  #inventory-table td:nth-child(2) { grid-column: 2; grid-row: 1; align-self: center; font-size: 15px; font-weight: 700; }
  #inventory-table td:nth-child(n+3):nth-child(-n+9) { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid #edf1f3; font-size: 13px; }
  #inventory-table td:nth-child(n+3):nth-child(-n+9)::before { flex: 0 0 42%; color: #657b8a; font-size: 11px; font-weight: 700; }
  #inventory-table td:nth-child(3)::before { content: 'Categoría'; }
  #inventory-table td:nth-child(4)::before { content: 'Precio sin IVA'; }
  #inventory-table td:nth-child(5)::before { content: 'Tipo'; }
  #inventory-table td:nth-child(6)::before { content: 'En almacén'; }
  #inventory-table td:nth-child(7)::before { content: 'Mantenimiento'; }
  #inventory-table td:nth-child(8)::before { content: 'Previsión a 7 días'; }
  #inventory-table td:nth-child(9)::before { content: 'Ubicación'; }
  #inventory-table td:nth-child(10) { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid #edf1f3; padding-top: 9px; }
  #inventory-table td:nth-child(10) button { flex: 1 1 auto; min-height: 38px; padding: 7px 9px; }
  /* Keep data tables usable with a deliberate horizontal swipe. */
  .panel table:not(#inventory-table table) { min-width: 620px; }
  .panel:has(> table), .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .grid, .grid-2, .grid-3, .metrics, .event-grid, .planning-job-grid { grid-template-columns: 1fr !important; }
  .tabs, .event-hub-tabs { overflow-x: auto; justify-content: flex-start; white-space: nowrap; }
  .tabs > *, .event-hub-tabs > * { flex: 0 0 auto; }
  dialog, #modal {
    box-sizing: border-box; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
    margin: 0; padding: 18px 14px calc(20px + env(safe-area-inset-bottom)); border-radius: 0;
  }
  dialog form, #modal form { grid-template-columns: 1fr !important; }
  dialog input, dialog select, dialog textarea, #modal input, #modal select, #modal textarea { min-width: 0; width: 100%; }
}
