/* Mobile housekeeping: navigation, deal cards and touch targets. */

.mobile-navigation,
.deal-mobile-list,
.mobile-bottom-navigation,
.mobile-dashboard-view,
.mobile-active-deal-groups {
  display: none;
}

.mobile-navigation {
  position: relative;
}

.mobile-navigation-trigger {
  min-width: 76px;
  min-height: 44px;
  padding: 10px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.mobile-navigation-trigger::-webkit-details-marker {
  display: none;
}

.mobile-navigation-panel {
  position: fixed;
  z-index: 50;
  top: 58px;
  right: 12px;
  width: min(310px, calc(100vw - 24px));
  max-height: calc(100vh - 70px);
  max-height: calc(100dvh - 70px);
  padding: 10px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}

.mobile-navigation-account {
  padding: 10px 12px 14px;
  display: grid;
  gap: 3px;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.mobile-navigation-account span {
  color: var(--text-muted);
  font-size: 13px;
}

.mobile-navigation-label {
  margin: 12px 12px 5px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mobile-navigation-action {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  font-weight: 700;
}

.mobile-navigation-action:hover,
.mobile-navigation-action:focus-visible {
  background: var(--surface-muted);
  color: var(--text);
}

.mobile-navigation-logout-form {
  margin: 8px 0 0;
  padding: 8px 0 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.mobile-navigation-logout {
  width: 100%;
  min-height: 44px;
  margin: 0;
  background: var(--red-soft);
  color: var(--red-dark);
}

.deal-mobile-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.deal-mobile-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.deal-mobile-card-heading {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.deal-mobile-customer {
  color: var(--text);
  font-size: 17px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.deal-mobile-card-heading > span {
  color: var(--text-soft);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.deal-mobile-details {
  margin: 18px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.deal-mobile-details div {
  min-width: 0;
}

.deal-mobile-details dt {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.deal-mobile-details dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.deal-mobile-actions {
  padding-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border-top: 1px solid var(--border);
}

.deal-mobile-actions > * {
  width: 100%;
  min-height: 44px;
}

.deal-record-link {
  color: var(--text);
  text-decoration: none;
}

.deal-record-link:hover {
  color: var(--blue);
}

@media (max-width: 720px) {
  .desktop-navigation,
  .deal-desktop-list {
    display: none;
  }

  body { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }

  .desktop-dashboard-view { display: none; }
  .mobile-dashboard-view { display: grid; gap: 18px; }
  .mobile-active-deal-groups { display: grid; gap: 18px; }

  .mobile-bottom-navigation {
    align-items: stretch;
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--border);
    bottom: 0;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.09);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    left: 0;
    padding: 7px max(8px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    position: fixed;
    right: 0;
    z-index: 60;
  }

  .mobile-bottom-link {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 10px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    font-size: 11px;
    gap: 2px;
    justify-content: center;
    min-height: 50px;
    padding: 4px;
    text-decoration: none;
  }
  .mobile-bottom-link > span { font-size: 20px; line-height: 1; }
  .mobile-bottom-link.is-active { background: #eff6ff; color: var(--blue); }
  .mobile-navigation { display: block; position: static; }
  .mobile-navigation[open] .mobile-navigation-trigger { background: #eff6ff; color: var(--blue); }
  .mobile-navigation-trigger { min-height: 50px; min-width: 0; padding: 4px; width: 100%; }
  .mobile-navigation-panel {
    bottom: calc(70px + env(safe-area-inset-bottom));
    max-height: min(520px, calc(100dvh - 100px));
    right: 12px;
    top: auto;
  }

  .deal-mobile-list {
    display: grid;
    gap: 14px;
  }

  .app-header { position: sticky; top: 0; z-index: 40; }
  .deal-insights-section { display: none; }
  .deal-workspace-header { gap: 12px; }
  .deal-workspace-header .deal-view-tabs {
    display: flex;
    gap: 7px;
    margin-inline: -16px;
    overflow-x: auto;
    padding: 0 16px 5px;
    scrollbar-width: none;
    width: calc(100% + 32px);
  }
  .deal-workspace-header .deal-view-tab { flex: none; white-space: nowrap; }
  .deal-list-header { margin-top: 10px; }
  .mobile-deal-status-group { display: grid; gap: 10px; }
  .mobile-deal-status-group > header { align-items: center; display: flex; justify-content: space-between; }
  .mobile-deal-status-group > header > strong { background: var(--surface-muted); border-radius: 999px; min-width: 28px; padding: 4px 8px; text-align: center; }
  .mobile-current-deliveries { border-top: 1px solid var(--border); padding-top: 16px; }
  .mobile-current-deliveries > p { color: var(--text-muted); margin: 0; }
  .deal-mobile-card { padding: 14px; }
  .deal-mobile-details { margin: 13px 0; }
  .deal-mobile-details-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

  .mobile-dashboard-hero { padding-top: 4px; }
  .mobile-dashboard-hero h1 { margin: 2px 0 4px; }
  .mobile-dashboard-hero p:last-child { color: var(--text-muted); margin: 0; }
  .mobile-dashboard-search {
    align-items: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    display: grid;
    gap: 8px;
    grid-template-columns: auto 1fr;
    padding: 4px 12px;
  }
  .mobile-dashboard-search > span { color: var(--text-muted); font-size: 22px; }
  .mobile-dashboard-search input { border: 0; box-shadow: none; min-height: 48px; padding: 0; width: 100%; }
  .mobile-dashboard-search input:focus { box-shadow: none; outline: none; }
  .mobile-sales-mix,
  .mobile-up-next { background: #fff; border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-sm); padding: 16px; }
  .mobile-section-heading { align-items: end; display: flex; justify-content: space-between; margin-bottom: 14px; }
  .mobile-section-heading h2 { margin: 2px 0 0; }
  .mobile-inline-link { color: var(--blue); font-size: 13px; font-weight: 800; }
  .mobile-sales-totals { display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 14px; }
  .mobile-sales-totals > div { background: var(--surface-muted); border-radius: 11px; display: grid; gap: 2px; padding: 10px; }
  .mobile-sales-totals span { color: var(--text-muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
  .mobile-sales-totals strong { font-size: 22px; }
  .mobile-sales-metrics { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-sales-metrics article { min-width: 0; }
  .mobile-sales-metrics article > div:first-child { display: flex; gap: 8px; justify-content: space-between; }
  .mobile-sales-metrics article span { font-size: 13px; }
  .mobile-sales-metrics article small { color: var(--text-muted); font-size: 10px; }
  .mobile-sales-progress { background: #e2e8f0; border-radius: 999px; height: 5px; margin: 5px 0 3px; overflow: hidden; }
  .mobile-sales-progress span { background: var(--blue); display: block; height: 100%; }
  .mobile-deals-shortcut { align-items: center; background: linear-gradient(135deg, #0f2747, #174b78); border-radius: 16px; color: #fff; display: flex; justify-content: space-between; padding: 17px; text-decoration: none; }
  .mobile-deals-shortcut > span { display: grid; gap: 2px; }
  .mobile-deals-shortcut small,
  .mobile-deals-shortcut em { color: #cbd5e1; font-style: normal; }
  .mobile-deals-shortcut strong { color: #fff; font-size: 19px; }
  .mobile-deals-shortcut > b { font-size: 28px; }
  .mobile-up-next-list { display: grid; }
  .mobile-up-next-item { align-items: center; color: var(--text); display: grid; gap: 12px; grid-template-columns: 55px minmax(0, 1fr) auto; padding: 12px 0; text-decoration: none; }
  .mobile-up-next-item + .mobile-up-next-item { border-top: 1px solid var(--border); }
  .mobile-up-next-item time { display: grid; text-align: center; }
  .mobile-up-next-item time strong { font-size: 14px; }
  .mobile-up-next-item time span { color: var(--text-muted); font-size: 10px; }
  .mobile-up-next-copy { display: grid; gap: 2px; min-width: 0; }
  .mobile-up-next-copy strong,
  .mobile-up-next-copy em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-up-next-copy em { color: var(--text-muted); font-size: 12px; font-style: normal; }
  .mobile-kind-badge { font-size: 10px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
  .mobile-kind-appointment { color: #7c3aed; }
  .mobile-kind-delivery { color: #15803d; }
  .mobile-up-next-empty { color: var(--text-muted); display: grid; gap: 3px; padding: 18px 0 6px; text-align: center; }

  .app-header {
    min-height: 64px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .prospect-small-action,
  .calendar-nav-button,
  .dialog-close-button,
  .tools-dialog-close {
    min-width: 44px;
    min-height: 44px;
  }

  .calendar-nav-button {
    width: 44px;
    height: 44px;
  }

  .page-content > form {
    padding: 18px;
  }

  .paid-dialog-actions,
  .tools-panel {
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 380px) {
  .deal-mobile-details,
  .deal-mobile-actions {
    grid-template-columns: 1fr;
  }
  .deal-mobile-details-compact { grid-template-columns: 1fr 1fr; }
}
