/* All presentation changes are restricted to phones and the signed-in app. */
.mobile-app-nav, .mobile-collection-search, .mobile-collection-summary { display: none; }
@media (max-width: 760px) {
  body.is-authenticated { --mobile-accent: #a18bff; }
  :root[data-theme="light"] body.is-authenticated { --mobile-accent: #7045d3; }
  body.is-authenticated .app-shell { display: block; }
  body.is-authenticated .sidebar { position: sticky; top: 0; z-index: 40; display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; justify-content: space-between; width: 100%; height: 68px; min-height: 68px; padding: 10px 18px; gap: 12px; border-radius: 0; background: var(--bg); border: 0; border-bottom: 1px solid var(--line); }
  body.is-authenticated .sidebar .brand { margin: 0; padding: 0; min-height: 44px; gap: 9px; }
  body.is-authenticated .sidebar .brand-mark { width: 34px; height: 34px; }
  body.is-authenticated .sidebar .brand-copy { display: block; }
  body.is-authenticated .sidebar .brand strong { font-size: 17px; color: var(--ink); letter-spacing: -.03em; }
  body.is-authenticated .sidebar .brand-copy > span,
  body.is-authenticated .sidebar .nav,
  body.is-authenticated .sidebar .sidebar-card,
  body.is-authenticated .sidebar .sidebar-profile-name,
  body.is-authenticated .sidebar .theme-toggle,
  body.is-authenticated .sidebar .feedback-launcher { display: none !important; }
  body.is-authenticated .sidebar .nav-tools { display: flex; width: auto; margin: 0; padding: 0; }
  body.is-authenticated .sidebar .search-shell:not(.is-open) { display: none !important; }
  body.is-authenticated .sidebar .search-shell.is-open { position: absolute; top: 70px; left: 12px; right: 12px; width: auto; background: var(--panel); padding: 8px; border-radius: 16px; }
  body.is-authenticated .sidebar .profile-control { position: relative; margin: 0; }
  body.is-authenticated .sidebar .profile-avatar { width: 40px; height: 40px; min-width: 40px; }
  body.is-authenticated .account-menu { position: fixed; top: 64px; right: 12px; left: auto; width: min(340px, calc(100vw - 24px)); max-height: calc(100dvh - 150px); overflow-y: auto; }
  body.is-authenticated .main { padding: 0 18px calc(96px + env(safe-area-inset-bottom)); min-width: 0; background: var(--bg); }
  body.is-authenticated .main::before, body.is-authenticated .main::after { display: none; }
  body.is-authenticated .topbar { min-height: 0; padding: 24px 0 18px; margin: 0; display: flex; align-items: start; gap: 8px; }
  body.is-authenticated .topbar .eyebrow { display: none; }
  body.is-authenticated #pageTitle { font-size: 30px; line-height: 1.1; letter-spacing: -.045em; text-wrap: balance; }
  body.is-authenticated .save-status { max-width: 110px; font-size: 10px; padding: 5px 0; text-align: right; white-space: normal; }
  body.is-authenticated .view { padding: 0; }
  body.is-authenticated .section-toolbar { gap: 12px; margin-bottom: 16px; }
  body.is-authenticated .section-toolbar h2 { font-size: 22px; }
  body.is-authenticated .mobile-app-nav { position: fixed; z-index: 60; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); box-shadow: 0 -8px 30px rgba(0,0,0,.08); }
  .mobile-app-nav button { display: grid; place-items: center; gap: 5px; min-height: 49px; padding: 5px; color: var(--muted); background: transparent; border: 0; border-radius: 12px; font: inherit; font-size: 10px; font-weight: 650; }
  .mobile-app-nav svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-app-nav button[aria-current="page"] { color: var(--mobile-accent); background: color-mix(in srgb, var(--mobile-accent) 10%, transparent); }
  .mobile-app-nav button:active { transform: scale(.96); }
  .mobile-app-nav button { position: relative; }
  .mobile-app-unread:not([hidden]) { position: absolute; top: 0; right: 16px; min-width: 17px; padding: 2px 4px; border-radius: 10px; background: var(--mobile-accent); color: var(--bg); font-size: 10px; }
  .mobile-app-menu { width: min(480px, calc(100vw - 16px)); max-height: calc(85dvh - env(safe-area-inset-bottom)); margin: auto auto calc(8px + env(safe-area-inset-bottom)); padding: 20px; border: 1px solid var(--line); border-radius: 24px; color: var(--ink); background: var(--panel); overflow-y: auto; }
  .mobile-app-menu::backdrop { background: rgba(0,0,0,.55); }
  .mobile-app-menu header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
  .mobile-app-menu h2 { font-size: 22px; }
  .mobile-app-menu button { min-height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-strong); color: var(--ink); font: inherit; }
  .mobile-app-menu header button { min-width: 44px; font-size: 24px; }
  .mobile-app-menu-items { display: grid; gap: 8px; }
  .mobile-app-menu-items button { padding: 12px 16px; text-align: left; }
  .mobile-app-menu-items button:disabled { opacity: .5; }
  body.is-authenticated #inventoryView { position: relative; }
  body.is-authenticated #inventoryView > .section-toolbar { margin: 0 0 12px; }
  body.is-authenticated #inventoryView > .section-toolbar > div:first-child { display: none; }
  body.is-authenticated #inventoryView .toolbar-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  body.is-authenticated #inventoryView .toolbar-actions [data-open-modal="purchase"] { position: absolute; top: -53px; right: 0; width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 12px; margin: 0; font-size: 0; box-shadow: none; }
  body.is-authenticated #inventoryView .toolbar-actions [data-open-modal="purchase"]::after { content: "+"; font-size: 26px; }
  body.is-authenticated #inventoryView:not(.mobile-filters-open) #inventorySort,
  body.is-authenticated #inventoryView:not(.mobile-filters-open) #exportInventoryCsvBtn { display: none; }
  body.is-authenticated #inventoryView.mobile-filters-open #inventorySort { flex: 1; min-width: 160px; width: auto; }
  body.is-authenticated .mobile-collection-summary { display: block; margin: 0 0 16px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
  body.is-authenticated .collection-controls { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
  body.is-authenticated .mobile-collection-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .mobile-collection-search input { min-width: 0; margin: 0; border-radius: 12px; min-height: 44px; font-size: 16px; }
  .mobile-collection-search button { min-height: 44px; padding: 0 15px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; font: inherit; font-size: 12px; }
  .mobile-collection-search button[aria-expanded="true"] { color: var(--mobile-accent); border-color: var(--mobile-accent); }
  body.is-authenticated .collection-tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding-bottom: 3px; margin: 0; }
  body.is-authenticated .collection-tabs .chip { flex-shrink: 0; min-height: 40px; padding: 8px 12px; font-size: 11px; }
  body.is-authenticated #inventoryView:not(.mobile-filters-open) .collection-filter-grid { display: none; }
  body.is-authenticated .collection-filter-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
  body.is-authenticated .collection-filter-grid input, body.is-authenticated .collection-filter-grid select { min-width: 0; font-size: 16px; }
  body.is-authenticated .collection-list { display: grid; gap: 10px; background: none; border: 0; border-radius: 0; box-shadow: none; }
  body.is-authenticated .collection-head { display: none; }
  body.is-authenticated .collection-row { display: grid; grid-template-columns: 76px repeat(2, minmax(0,1fr)); gap: 7px 12px; padding: 14px; min-height: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); overflow: hidden; }
  body.is-authenticated .collection-row > .collection-main { display: contents; }
  body.is-authenticated .collection-image { grid-column: 1; grid-row: 1 / 5; width: 76px; height: 113px; align-self: center; border-radius: 10px; box-shadow: none; background: transparent; }
  body.is-authenticated .collection-image img { object-fit: contain; }
  body.is-authenticated .collection-main > div:last-child { grid-column: 2 / 4; grid-row: 1; min-width: 0; }
  body.is-authenticated .collection-main strong { font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
  body.is-authenticated .collection-main small { font-size: 10px; line-height: 1.35; margin-top: 3px; }
  body.is-authenticated .collection-main small:nth-of-type(2) { font-size: 9px; }
  body.is-authenticated .collection-row > div:not(.collection-main):not(.card-actions) { justify-self: stretch; text-align: left; padding: 0; border-radius: 0; background: none; }
  body.is-authenticated .collection-row > div:not(.collection-main):not(.card-actions) strong { text-align: left; font-size: 13px; font-variant-numeric: tabular-nums; }
  body.is-authenticated .collection-row > div:not(.collection-main):not(.card-actions) small { display: none; }
  body.is-authenticated .collection-row > div:not(.collection-main):not(.card-actions)::before { font-size: 9px; text-transform: none; font-weight: 500; margin-bottom: 3px; letter-spacing: 0; }
  body.is-authenticated .collection-row > div:nth-of-type(2) { grid-column: 2 / 4; grid-row: 2; }
  body.is-authenticated .collection-row > div:nth-of-type(2)::before { display: none; }
  body.is-authenticated .collection-row > div:nth-of-type(2) strong { color: var(--mobile-accent); font-size: 10px; text-transform: uppercase; }
  body.is-authenticated .collection-row > div:nth-of-type(3) { grid-column: 3; grid-row: 3; }
  body.is-authenticated .collection-row > div:nth-of-type(3)::before { content: "Valore unitario"; }
  body.is-authenticated .collection-row > div:nth-of-type(4) { grid-column: 2; grid-row: 3; }
  body.is-authenticated .collection-row > div:nth-of-type(4)::before { content: "Costo unitario"; }
  body.is-authenticated .collection-row > div:nth-of-type(5) { grid-column: 2 / 4; grid-row: 4; display: flex; align-items: baseline; gap: 8px; }
  body.is-authenticated .collection-row > div:nth-of-type(5)::before { content: "Margine totale"; }
  body.is-authenticated .collection-row .card-actions.compact { grid-column: 1 / -1; grid-row: 5; display: flex; justify-content: flex-end; padding-top: 7px; border-top: 1px solid var(--line); }
  body.is-authenticated .collection-row .card-actions.compact > button:not([data-detail-card]) { display: none; }
  body.is-authenticated .collection-row .card-actions.compact > button[data-detail-card] { width: auto; min-height: 40px; padding: 0 18px; border-radius: 10px; color: var(--mobile-accent); background: color-mix(in srgb, var(--mobile-accent) 10%, transparent); box-shadow: none; border: 0; font-size: 12px; }
  body.is-authenticated #dashboardView .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  body.is-authenticated #dashboardView .kpi-card { min-width: 0; padding: 16px; border-radius: 18px; }
  body.is-authenticated #dashboardView .kpi-card strong { font-size: 25px; }
  body.is-authenticated #dashboardView .panel { padding: 16px; border-radius: 18px; }
  body.is-authenticated #dashboardView .panel-head h2 { font-size: 22px; }
  body.is-authenticated .chart-controls { min-width: 0; max-width: 100%; }
  body.is-authenticated .chart-mode-switch, body.is-authenticated .chart-range-switch { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; }
  body.is-authenticated .chart-controls .chip { flex-shrink: 0; min-height: 40px; }
  body.is-authenticated .modal { max-width: calc(100vw - 16px); }
  body.is-authenticated #cardDetailModal .detail-modal { width: 100%; min-width: 0; padding: 20px; max-height: calc(100dvh - 24px); }
  body.is-authenticated #cardDetailModal .modal-head { min-width: 0; gap: 8px; }
  body.is-authenticated #cardDetailModal .modal-head > div { min-width: 0; }
  body.is-authenticated #cardDetailModal #cardDetailContent { min-width: 0; width: 100%; }
  body.is-authenticated #cardDetailModal .modal-head h2 { font-size: 26px; line-height: 1.1; }
  body.is-authenticated #cardDetailModal .detail-grid { grid-template-columns: minmax(0,1fr); gap: 20px; }
  body.is-authenticated #cardDetailModal .detail-image { height: 240px; min-height: 0; }
  body.is-authenticated #cardDetailModal .detail-image img { height: 100%; width: 100%; object-fit: contain; }
  body.is-authenticated #cardDetailModal .card-detail-kpis { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
  body.is-authenticated #cardDetailModal .card-detail-kpis > * { min-width: 0; padding: 10px 6px; }
  body.is-authenticated #cardDetailModal .card-detail-kpis strong { font-size: 17px; }
  body.is-authenticated #cardDetailModal .card-detail-actions { display: flex; flex-wrap: wrap; }
  body.is-authenticated #cardDetailModal .card-detail-actions > * { flex: 1 1 130px; min-width: 0; }
  body.is-authenticated #purchaseModal .purchase-modal-card { padding: 20px 16px; border-radius: 22px; }
  body.is-authenticated #purchaseModal .purchase-modal-head h2 { font-size: 30px; line-height: 1.05; }
  body.is-authenticated #purchaseModal .purchase-modal-actions { display: grid; grid-template-columns: minmax(0,1fr); gap: 8px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  body.is-authenticated #purchaseModal .purchase-modal-actions .button { width: 100%; min-width: 0; min-height: 46px; white-space: normal; padding: 12px; }
  body.is-authenticated #purchaseModal .purchase-save-hint { grid-column: 1; }
  body.is-authenticated .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  @media (prefers-reduced-motion: reduce) { .mobile-app-nav button:active { transform: none; } }
}
