/*
 * Mobile form workflow layer.
 * Scope: primary ledger entry forms and the station archive form.
 */
.mobile-form-assistant,
.mobile-form-status-card {
  display: none;
}

@media (max-width: 767.98px) {
  .entry-page,
  .station-page {
    padding-bottom: 6.8rem !important;
  }

  .mobile-form-assistant {
    position: sticky;
    top: 4.55rem;
    z-index: 1015;
    display: grid;
    gap: .55rem;
    margin: 0 0 .8rem;
    padding: .7rem;
    border: 1px solid rgba(7, 91, 136, .1);
    border-radius: 18px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 8px 24px rgba(15, 52, 77, .08);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .mobile-form-progress-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .65rem;
  }

  .mobile-form-progress-label {
    color: #244e63;
    font-size: .74rem;
    font-weight: 850;
    white-space: nowrap;
  }

  .mobile-form-progress-track {
    flex: 1 1 auto;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #e7f0f4;
  }

  .mobile-form-progress-fill {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #087aa8, #22a9c8);
    transition: width .2s ease;
  }

  .mobile-form-section-nav {
    display: flex;
    gap: .42rem;
    overflow-x: auto;
    padding-bottom: .05rem;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  .mobile-form-section-nav::-webkit-scrollbar {
    display: none;
  }

  .mobile-form-section-link {
    flex: 0 0 auto;
    min-height: 32px;
    padding: .34rem .66rem;
    border: 1px solid rgba(7, 91, 136, .1);
    border-radius: 999px;
    background: #f4f9fb;
    color: #567181;
    font-size: .7rem;
    font-weight: 800;
    white-space: nowrap;
    scroll-snap-align: start;
  }

  .mobile-form-section-link.is-active {
    border-color: #087aa8;
    background: #087aa8;
    color: #fff;
    box-shadow: 0 5px 14px rgba(8, 122, 168, .18);
  }

  .entry-section,
  .station-section-card {
    scroll-margin-top: 9.6rem;
  }

  .entry-section-header,
  .station-section-header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
  }

  .entry-section-header > div,
  .station-section-header > div {
    min-width: 0;
  }

  .entry-section-header .small,
  .station-section-header .small {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .entry-field-col,
  .station-section-card .row > div {
    position: relative;
    padding-top: .08rem;
  }

  .entry-page .form-control,
  .entry-page .form-select,
  .station-page .form-control,
  .station-page .form-select {
    min-height: 48px !important;
    padding: .68rem .82rem !important;
    border: 1px solid #cfdee6 !important;
    border-radius: 13px !important;
    color: #163d52 !important;
    -webkit-text-fill-color: #163d52 !important;
    font-size: 16px !important;
    font-weight: 650 !important;
    line-height: 1.35 !important;
    box-shadow: 0 2px 8px rgba(15, 52, 77, .025) !important;
  }

  .entry-page .form-control::placeholder,
  .station-page .form-control::placeholder {
    color: #9aabb5 !important;
    -webkit-text-fill-color: #9aabb5 !important;
    font-weight: 500 !important;
  }

  .entry-page .form-control:focus,
  .entry-page .form-select:focus,
  .station-page .form-control:focus,
  .station-page .form-select:focus {
    border-color: #168ab5 !important;
    box-shadow: 0 0 0 3px rgba(22, 138, 181, .12) !important;
  }

  .entry-page textarea.form-control,
  .station-page textarea.form-control {
    min-height: 84px !important;
    max-height: 180px;
    line-height: 1.55 !important;
  }

  .entry-page input[type="file"].form-control,
  .station-page input[type="file"].form-control {
    min-height: 50px !important;
    padding: .42rem !important;
    font-size: .78rem !important;
  }

  .entry-page input[type="file"]::file-selector-button,
  .station-page input[type="file"]::file-selector-button {
    min-height: 34px;
    margin-right: .6rem;
    padding: .38rem .7rem;
    border: 0;
    border-radius: 9px;
    background: #e8f4f8;
    color: #075b88;
    font-weight: 800;
  }

  .entry-page .form-label,
  .station-page .form-label {
    display: flex;
    align-items: baseline;
    gap: .18rem;
    margin-bottom: .4rem !important;
    color: #244e63 !important;
    -webkit-text-fill-color: #244e63 !important;
    font-size: .82rem !important;
    font-weight: 850 !important;
  }

  .entry-required,
  .station-required {
    color: #cc3f47 !important;
    -webkit-text-fill-color: #cc3f47 !important;
  }

  .entry-page .form-text,
  .station-page .form-text,
  .station-link-hint {
    margin-top: .3rem !important;
    color: #718795 !important;
    -webkit-text-fill-color: #718795 !important;
    font-size: .7rem !important;
    line-height: 1.45 !important;
  }

  .entry-page .text-danger.small,
  .station-page .text-danger.small,
  .mobile-form-error-summary {
    color: #b62f3b !important;
    -webkit-text-fill-color: #b62f3b !important;
  }

  .entry-page .text-danger.small,
  .station-page .text-danger.small {
    margin-top: .35rem !important;
    padding: .42rem .55rem;
    border-radius: 9px;
    background: #fff1f2;
    font-size: .72rem !important;
    line-height: 1.45;
  }

  .mobile-form-invalid {
    border-color: #d94b56 !important;
    background-color: #fffafb !important;
  }

  .mobile-form-error-summary {
    display: none;
    margin: 0 0 .75rem;
    padding: .7rem .8rem;
    border: 1px solid rgba(182, 47, 59, .16);
    border-radius: 13px;
    background: #fff1f2;
    font-size: .76rem;
    font-weight: 750;
    line-height: 1.5;
  }

  .mobile-form-error-summary.is-visible {
    display: block;
  }

  .mobile-form-status-card {
    display: block;
    margin: 0 0 .8rem;
    padding: .8rem;
    border: 1px solid rgba(7, 91, 136, .1);
    border-radius: 16px;
    background: #f4f9fb;
  }

  .mobile-form-status-card .form-check {
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
  }

  .mobile-form-status-card .form-check-label {
    color: #244e63;
    font-size: .82rem;
    font-weight: 850;
  }

  .entry-action-bar,
  .station-action-bar {
    position: sticky !important;
    bottom: calc(4.65rem + env(safe-area-inset-bottom)) !important;
    z-index: 1020 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: .5rem !important;
    min-height: 64px;
    margin: .85rem -.95rem -.95rem !important;
    padding: .6rem .75rem !important;
    border-top: 1px solid rgba(7, 91, 136, .1) !important;
    background: rgba(255, 255, 255, .96) !important;
    box-shadow: 0 -10px 28px rgba(15, 52, 77, .1) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .entry-action-bar .btn,
  .station-action-bar .btn {
    width: auto !important;
    min-width: 0 !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: .55rem .72rem !important;
    border-radius: 12px !important;
    font-size: .8rem !important;
    font-weight: 850 !important;
    white-space: normal;
  }

  .entry-action-bar .btn-primary,
  .station-action-bar .btn-primary {
    grid-column: 1;
  }

  .entry-action-bar .btn-outline-secondary,
  .station-action-bar .btn-outline-secondary {
    grid-column: 2;
    min-width: 72px !important;
  }

  .entry-action-bar:has(> button:nth-of-type(2)) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .entry-action-bar:has(> button:nth-of-type(2)) > .btn-primary {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .entry-action-bar:has(> button:nth-of-type(2)) > .btn-outline-primary {
    grid-column: 1;
    grid-row: 2;
  }

  .entry-action-bar:has(> button:nth-of-type(2)) > .btn-outline-secondary {
    grid-column: 2;
    grid-row: 2;
  }

  .station-action-bar > .form-check {
    display: none !important;
  }

  .station-action-bar > .d-flex {
    display: contents !important;
  }

  .mobile-form-submitting {
    pointer-events: none;
  }

  .mobile-form-submitting .entry-form-body,
  .mobile-form-submitting .station-section-card {
    opacity: .7;
  }

  .mobile-form-submitting button[type="submit"]::before {
    content: "";
    display: inline-block;
    width: .82rem;
    height: .82rem;
    margin-right: .42rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -.12rem;
    animation: mobile-form-spin .72s linear infinite;
  }
}

@keyframes mobile-form-spin {
  to { transform: rotate(360deg); }
}
