/* Work Horse phone layout. Loaded after tracker_theme.css. */
@media (max-width: 991.98px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  .main,
  .content-frame,
  .content-area {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .main {
    padding: 10px 10px 16px;
  }

  body.wh-page-field_log .main {
    padding: 0;
  }

  .main .container,
  .main .container-fluid {
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
  }

  .main .container.py-4,
  .main .container.py-5,
  .main .container.mt-5 {
    padding-top: 4px !important;
    padding-bottom: 12px !important;
    margin-top: 0 !important;
  }

  .topbar {
    padding: 0 8px 0 10px;
    gap: 8px;
  }

  .top-actions {
    gap: 6px;
    min-width: 0;
  }

  .top-actions .btn,
  .top-actions .mobile-toggle {
    min-height: 40px;
    padding: 6px 10px;
  }

  .tracker-panel-toggle > span:not(.tracker-alerts-count) {
    display: none;
  }

  .tracker-user-chip {
    max-width: 34vw;
    min-width: 0;
  }

  .tracker-user-label {
    display: none;
  }

  .tracker-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tracker-shell-panel {
    width: min(100vw - 16px, 460px);
    height: min(70dvh, 520px);
    right: -8px;
  }

  .sidebar,
  .mobile-sidebar {
    -webkit-overflow-scrolling: touch;
  }

  h1, .h1 { font-size: 1.55rem; }
  h2, .h2 { font-size: 1.28rem; }
  h3, .h3 { font-size: 1.12rem; }

  img, video {
    max-width: 100%;
    height: auto;
  }

  .brand img,
  .navbar-brand img {
    width: auto;
    max-width: none;
    height: 28px;
  }

  iframe {
    max-width: 100%;
  }

  input,
  select,
  textarea,
  .form-control,
  .form-select,
  .custom-select {
    font-size: 16px !important;
    max-width: 100%;
  }

  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]):not([type="file"]),
  select,
  textarea,
  .form-control,
  .form-select,
  .custom-select,
  .btn:not(.cal-add-day):not(.close):not(.ml-remove):not(.page-link) {
    min-height: 44px;
  }

  .btn-sm:not(.cal-add-day) {
    min-height: 40px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .btn {
    white-space: normal;
  }

  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .form-inline .form-control,
  .form-inline .custom-select,
  .form-inline .form-select {
    width: 100%;
  }

  .d-flex.justify-content-between,
  .d-flex.justify-content-end,
  .d-flex.align-items-center.justify-content-between {
    flex-wrap: wrap;
    gap: 8px;
  }

  .btn-toolbar,
  .btn-group {
    flex-wrap: wrap;
  }

  .table-responsive,
  .main table,
  .content-frame table,
  .ml-table-wrap,
  .ec-table-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-dialog {
    margin: 8px auto;
    max-width: calc(100vw - 16px);
    width: calc(100vw - 16px);
  }

  .modal-content {
    max-height: calc(100dvh - 16px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-body {
    padding: 12px;
  }

  dialog {
    width: min(100vw - 24px, 480px);
    max-height: calc(100dvh - 24px);
  }

  .embedded-tool-frame,
  .contacts-embed,
  .tracker-embed-frame,
  .tracker-embed-shell {
    height: calc(100dvh - 56px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) !important;
    min-height: 0 !important;
    border-radius: 0;
  }

  /* Login */
  body.tracker-theme .tracker-auth-card {
    min-width: 0;
    margin: 0;
  }

  body.tracker-theme > .d-flex.justify-content-center {
    min-height: 100dvh !important;
    padding: 16px;
    box-sizing: border-box;
  }

  .tracker-auth-logo {
    height: 88px !important;
  }

  /* Home */
  .ww-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .ww-tile {
    min-height: 72px;
    padding: 14px;
  }

  .ww-section {
    margin-top: 22px;
  }

  .dash-today {
    margin-bottom: 18px;
  }

  /* Calendar */
  .cal-shell {
    padding: 0 0 12px;
  }

  .cal-hero {
    padding: 12px !important;
    gap: 10px;
  }

  .cal-title {
    font-size: 26px !important;
  }

  .cal-copy,
  .cal-hint {
    display: none;
  }

  .cal-actions {
    width: 100%;
  }

  .cal-actions .btn {
    flex: 1 1 calc(50% - 8px);
    min-height: 44px;
  }

  .cal-toolbar {
    gap: 8px;
  }

  .cal-toolbar > .btn,
  .cal-toolbar > a.btn {
    flex: 1 1 auto;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .cal-toolbar .form-control,
  .cal-toolbar .custom-select {
    max-width: none !important;
    width: 100%;
    flex: 1 1 100%;
  }

  .cal-status {
    flex: 1 1 100%;
  }

  .cal-unscheduled {
    min-height: 180px !important;
    padding: 12px;
  }

  #calUnscheduledList {
    min-height: 100px;
    max-height: 220px;
  }

  .cal-day {
    min-height: 150px;
  }

  .cal-google-cta {
    width: 100%;
    font-size: 16px !important;
  }

  /* Work Timeline */
  .wt-title {
    font-size: 26px !important;
  }

  .wt-copy {
    display: none;
  }

  .wt-tools {
    width: 100%;
  }

  .wt-tools .custom-select,
  .wt-tools .form-control {
    max-width: none;
    flex: 1 1 100%;
  }

  .wt-board {
    max-height: calc(100dvh - 170px);
    -webkit-overflow-scrolling: touch;
  }

  /* Todo */
  .todo-shell {
    padding: 4px 0 12px;
  }

  .todo-hero {
    padding: 14px;
    margin-bottom: 12px;
  }

  .todo-title {
    font-size: 26px !important;
  }

  .todo-copy {
    display: none;
  }

  .todo-stats {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }

  .todo-stat-value {
    font-size: 22px;
  }

  .todo-row {
    flex-direction: column;
  }

  .todo-task-title {
    font-size: 18px;
  }

  .todo-actions {
    min-width: 0;
    width: 100%;
  }

  .todo-open,
  .todo-open-secondary {
    width: 100%;
  }

  /* Mailing / email */
  .ml-hero h1,
  .ec-hero h1 {
    font-size: 26px !important;
  }

  .ml-hero p,
  .ec-hero p {
    font-size: 14px;
  }

  /* Projects */
  .project-directory-title {
    font-size: 28px !important;
  }

  .project-directory-actions .btn {
    flex: 1 1 auto;
  }

  /* Jobs map */
  #jobsMap {
    height: 58dvh !important;
    min-height: 280px !important;
  }

  .jobs-mapbar {
    gap: 8px;
  }

  /* Field log stays its own app; keep tap size only. */
  .fl-app input,
  .fl-app select,
  .fl-app textarea,
  .fl-app .form-control,
  .fl-app .custom-select {
    font-size: 16px !important;
  }
}

@media (max-width: 575.98px) {
  .brand span {
    display: none;
  }

  .main {
    padding: 8px 8px 14px;
  }

  body.wh-page-field_log .main {
    padding: 0;
  }

  .cal-actions .btn {
    flex: 1 1 100%;
  }

  .todo-stats {
    grid-template-columns: 1fr 1fr;
  }

  .tracker-theme-toggle [data-theme-label] {
    display: none;
  }

  .tracker-theme-toggle {
    min-width: 40px;
    padding-left: 10px;
    padding-right: 10px;
  }
}

@media (max-width: 991.98px) {
  a, button, .btn, .side-link {
    -webkit-tap-highlight-color: rgba(57, 160, 255, 0.22);
    touch-action: manipulation;
  }
}
