/* Shared interaction details for the store and internal tools. Keep the
   agricultural brand and each page's established visual language. */
:where(button:not(:disabled), a[href]):active {
  filter: brightness(.92);
}

:where(button, a[href], input, select, textarea) {
  touch-action: manipulation;
}

/* The designed :active state is the press feedback, so the grey iOS tap
   flash is removed instead of stacking two highlights. */
:where(button, a, label, summary, [role="button"]) {
  -webkit-tap-highlight-color: transparent;
}

/* Buttons sink slightly the instant they are pressed (pointer-down), not on
   release. `scale` is independent of `transform`, so components that already
   position themselves with transform are unaffected. */
:is(.btn-hero-main, .btn-hero-secondary, .btn-add-cart, .btn-product-detail,
  .btn-checkout-wa, .btn-calculate, .btn-bundle-view, .btn-icon-nav,
  .btn-primary-consult, .nav-feature-link, .category-btn, .crop-pill,
  .outlet-btn, .btn-qty, .btn-remove-cart, .wa-floating-btn, .toast-action,
  .shipping-rate-option, .kal-pill, .kal-crop,
  .google-button, .primary-button, .primary-action-button, .secondary-button,
  .ghost-button, .table-action, .dms-page .btn, .segmented button,
  .picker-option, .run-cancel-button):not(:disabled):active {
  scale: .97;
}

/* Money, stock and counts line up in columns when digits share one width. */
.admin-page :is(td, .stat-card strong, .stock-value, .production-metrics dd,
  .cost-summary strong, .capital-summary strong, .capital-breakdown strong,
  .repeat-cost, .pack-preview),
.dms-page :is(td, .kpi-card strong, .rank-list, .chart-peak, .pagination,
  .coverage-total, .territory-count, .detail-list dd) {
  font-variant-numeric: tabular-nums;
}

/* Keyboard users can jump past the sidebar straight to the working area. */
:is(.admin-page, .dms-page) .skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  color: #103324;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  font-weight: 800;
  transform: translateY(-160%);
}
:is(.admin-page, .dms-page) .skip-link:focus { transform: none; }
/* The landmark only receives focus as a skip-link target; no ring needed. */
:is(.admin-main, .dms-view):focus { outline: none; }

/* Admin & DMS dialogs: the scrim fades while the card rises into place, and
   closing runs the same path backwards. Browsers without @starting-style or
   discrete display transitions keep the previous instant behaviour. */
.admin-page .admin-modal,
.dms-page :is(.dms-modal, .confirm-modal) {
  transition: display .2s allow-discrete;
}
.admin-page .admin-modal-backdrop,
.dms-page .modal-backdrop {
  transition: opacity .2s ease;
}
.admin-page :is(.admin-modal-card, .confirm-card),
.dms-page :is(.modal-card, .confirm-card) {
  transition: transform .34s cubic-bezier(.16, 1, .3, 1), opacity .2s ease;
}
.admin-page .admin-modal[hidden] > .admin-modal-backdrop,
.dms-page :is(.dms-modal, .confirm-modal)[hidden] > .modal-backdrop {
  opacity: 0;
}
.admin-page .admin-modal[hidden] > :is(.admin-modal-card, .confirm-card),
.dms-page :is(.dms-modal, .confirm-modal)[hidden] > :is(.modal-card, .confirm-card) {
  opacity: 0;
  transform: translateY(12px) scale(.98);
  transition: transform .2s cubic-bezier(.7, 0, .84, 0), opacity .2s ease;
}
@starting-style {
  .admin-page .admin-modal:not([hidden]) > .admin-modal-backdrop,
  .dms-page :is(.dms-modal, .confirm-modal):not([hidden]) > .modal-backdrop {
    opacity: 0;
  }
  .admin-page .admin-modal:not([hidden]) > :is(.admin-modal-card, .confirm-card),
  .dms-page :is(.dms-modal, .confirm-modal):not([hidden]) > :is(.modal-card, .confirm-card) {
    opacity: 0;
    transform: translateY(12px) scale(.98);
  }
}

/* iOS Safari zooms the page when a field under 16px receives focus. */
@media (pointer: coarse) {
  :is(.admin-page, .dms-page) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    font-size: max(1rem, 16px) !important;
  }
}

.admin-page :where(button, a[href], input, select, textarea):focus-visible,
.dms-page :where(button, a[href], input, select, textarea):focus-visible {
  outline: 3px solid #176942;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px #fff;
}

.admin-page .sidebar :where(button, a[href]):focus-visible,
.dms-page .dms-sidebar :where(button, a[href]):focus-visible {
  outline-color: #a7f3d0;
  box-shadow: 0 0 0 6px #0b2419;
}

/* Small labels in the operational tools must still be readable at normal
   browser zoom; hierarchy comes from weight and spacing, not tiny text. */
.admin-page :is(.header-kicker, .eyebrow, .result-info, .field-hint,
  .search-control span, .filter-control span, .product-cell small,
  .stat-card small, .stat-card p, .table-action, .status-switch,
  .secondary-button, .primary-action-button, .ghost-button) {
  font-size: .75rem;
}
.dms-page :is(.eyebrow, .result-info, .field-hint,
  .field > span, .kpi-card small, .kpi-card p, .panel-head p,
  .cell-sub, .mini-select) {
  font-size: .75rem;
}
/* Kept apart from the list above: :is() takes the weight of its heaviest
   selector, and a heavier rule here would beat the collapsed sidebar rule
   that turns group titles into plain dividers. */
.dms-page .nav-group { font-size: .75rem; }
.dms-page :is(.btn.tiny, .btn.small) { font-size: .75rem; }
.admin-page :is(small, th, .status-pill, .category-badge, .stock-value,
  .sop-table td, .sop-note, .sop-empty, .sop-steps p, .section-note,
  .repeat-head > strong, .repeat-cost, .pack-preview,
  .integration-list p, .field > span, .crop-options > legend,
  .field-hint code, .field-error, .image-preview-row strong,
  .switch-field, .product-form-message, .settings-preview p,
  .production-legacy li small) { font-size: .75rem; }
.dms-page :is(small, .badge, .pagination, .field-error, .chart-peak,
  .rank-list small, .filter-summary span, .popup-code, .map-popup p,
  .map-popup dl div, .picker-hint, .territory-count span,
  .coverage-legend li, .line-section > legend, .detail-list dt) {
  font-size: .75rem;
}

.admin-page :is(.modal-close-button, .table-action.icon),
.dms-page .modal-close {
  width: 44px;
  height: 44px;
}

.admin-page :is(.primary-action-button, .secondary-button, .ghost-button,
  .table-action, .status-switch, .search-control input, .filter-control select) {
  min-height: 44px;
}
.admin-page .sidebar-footer :is(a, button) { min-height: 44px; }
.admin-page .back-link,
.dms-page .back-link { min-height: 44px; }
.dms-page :is(.btn, .btn.tiny, .btn.small, .mini-select,
  .field > input, .field > select, .field > textarea, .global-search input) {
  min-height: 44px;
}
/* Sidebar rows follow the pointer: compact for a mouse, full 44px for touch. */
.dms-page :is(.nav-item, .sidebar-footer a, .sidebar-footer button) { min-height: 40px; }
@media (pointer: coarse) {
  .dms-page :is(.nav-item, .sidebar-footer a, .sidebar-footer button) { min-height: 44px; }
}
.dms-page :is(.address-results li button, .outlet-photo-remove) { min-height: 44px; }
.dms-page .outlet-photo-remove { min-width: 44px; }
.dms-page .data-table.sortable th[data-sort] button {
  min-height: 44px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  letter-spacing: inherit;
  text-align: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.dms-page .dms-navbar { background: rgba(255, 255, 255, .94); }
/* While a dialog is open its actions sit at the bottom edge; toasts move to
   the top so they never cover the Save button (same as the admin page). */
.dms-page.modal-open .toast-region { top: 16px; bottom: auto; }

@media (max-width: 760px) {
  .admin-page .menu-button,
  .dms-page .menu-button { min-width: 44px; min-height: 44px; }
  .admin-page .admin-modal-card,
  .dms-page .modal-card,
  .dms-page .modal-card.wide { height: 100dvh; max-height: 100dvh; }
  .admin-page .modal-actions,
  .dms-page .record-actions { padding-bottom: max(17px, env(safe-area-inset-bottom)); }
  .solutions-page .brand-logo { min-width: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  html:has(.admin-page), html:has(.dms-page) { scroll-behavior: auto; }
  .admin-page *, .admin-page *::before, .admin-page *::after,
  .dms-page *, .dms-page *::before, .dms-page *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .admin-page .skeleton-bar,
  .dms-page .skeleton-bar { background: #e7ece8; }
}

@media (prefers-reduced-transparency: reduce) {
  .solutions-page .solutions-visual-card { background: #064e3b; backdrop-filter: none; }
  .admin-page .admin-modal-backdrop,
  .dms-page .modal-backdrop { backdrop-filter: none; background: #12261e; }
  .dms-page .dms-navbar { backdrop-filter: none; background: #fff; }
}

@media (prefers-contrast: more) {
  .admin-page :is(.panel-card, .stat-card, .field input, .field select, .field textarea),
  .dms-page :is(.panel, .kpi-card, .field input, .field select, .field textarea) {
    border-color: #254c35;
  }
  .admin-page .sidebar,
  .dms-page .dms-sidebar { background: #061b10; }
}
