.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  #cf,
  #pf,
  #tf,
  #nf {
    position: relative;
    z-index: 2;
    isolation: isolate;
  }

  #cf input,
  #cf select,
  #cf textarea,
  #pf input,
  #pf select,
  #pf textarea,
  #tf input,
  #tf select,
  #tf textarea,
  #nf input,
  #nf select,
  #nf textarea {
    position: relative;
    z-index: 3;
    pointer-events: auto;
    touch-action: manipulation;
  }

  :root {
    --mobile-gap-sm: 8px;
    --mobile-gap-md: 12px;
    --mobile-gap-lg: 16px;
    --mobile-gap-xl: 20px;
    --mobile-card-padding: 16px;
    --mobile-hero-padding: 20px;
    --mobile-radius: 18px;
    --mobile-radius-sm: 14px;
    --mobile-border: rgba(226, 232, 240, 0.95);
    --mobile-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
    --mobile-surface: #ffffff;
    --mobile-surface-soft: #f8fafc;
    --mobile-text: #0f172a;
    --mobile-muted: #64748b;
    --mobile-accent: #2563eb;
  }

  .toast-container {
    position: fixed;
    top: env(safe-area-inset-top, 14px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: min(90%, 420px);
    max-width: 100%;
    padding: 0 10px;
    z-index: 99999;
    pointer-events: none;
  }

  .toast-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,.15);
    box-shadow: 0 24px 60px rgba(15,23,42,.18);
    backdrop-filter: blur(12px);
    background: rgba(15,23,42,.92);
    color: #fff;
    opacity: 0;
    transform: translateY(-22px);
    animation: toastSlideIn .35s cubic-bezier(.22,.12,.08,1) forwards;
    pointer-events: auto;
    overflow: visible;
  }

  .toast-item--success {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    animation: toastSlideIn .35s cubic-bezier(.22,.12,.08,1) forwards, toastSuccessGlow 1.4s ease .25s both;
  }

  .toast-item--delete {
    background: linear-gradient(135deg, #dc2626, #ef4444);
  }

  .toast-item--error {
    background: linear-gradient(135deg, #f97316, #ef4444);
  }

  .toast-item--warning {
    background: linear-gradient(135deg, #f59e0b, #f97316);
  }

  .toast-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.18);
    flex-shrink: 0;
  }

  .toast-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
    line-height: 1.4;
    color: #fff;
  }

  .toast-body span {
    display: block;
  }

  .toast-title {
    font-weight: 700;
    font-size: 15px;
  }

  .toast-message {
    font-size: 13px;
    color: rgba(255,255,255,.92);
  }

  .toast-item.toast-item--delete {
    animation: toastSlideIn .35s cubic-bezier(.22,.12,.08,1) forwards, toastShake .45s ease .15s;
  }

  .toast-item.toast-item--error {
    animation: toastSlideIn .35s cubic-bezier(.22,.12,.08,1) forwards, toastPulse .38s ease .1s;
  }

  .toast-item.hide {
    animation: toastFadeOut .25s ease forwards;
  }

  .modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15,23,42,.35);
    z-index: 99998;
  }

  .modal.active {
    display: flex;
  }

  .modal-box {
    width: min(100%, 420px);
    border-radius: 24px;
    padding: 24px;
    background: rgba(255,255,255,.97);
    border: 1px solid rgba(15,23,42,.08);
    box-shadow: 0 32px 80px rgba(15,23,42,.18);
    backdrop-filter: blur(14px);
    color: #111827;
    max-width: 420px;
  }

  .modal-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 16px;
  }

  .modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #2563eb;
  }

  .modal-title {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
    font-weight: 800;
    color: #111827;
  }

  .modal-text {
    margin: 6px 0 0;
    color: #475569;
    font-size: 15px;
    line-height: 1.7;
  }

  .modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 22px;
  }

  .modal-box .btn.primary {
    min-width: 120px;
    width: 100%;
  }

  .modal-box .actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .modal-box .actions .btn {
    width: 100%;
  }

  .modal-box .btn.ghost {
    background: rgba(15,23,42,.05);
    color: #334155;
    border-color: rgba(15,23,42,.12);
  }

  .modal-actions .btn {
    flex: 1 1 100%;
    min-width: 0;
  }

  .modal-actions .btn + .btn {
    margin-left: 0;
  }

  @keyframes toastSlideIn {
    from { opacity: 0; transform: translateY(-22px); }
    to { opacity: 1; transform: translateY(0); }
  }

  @keyframes toastFadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-18px); }
  }

  @keyframes toastShake {
    0%, 100% { transform: translateY(0); }
    20%, 60% { transform: translateY(-2px) rotate(-0.5deg); }
    40%, 80% { transform: translateY(2px) rotate(0.5deg); }
  }

  @keyframes toastPulse {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
  }

  @keyframes toastSuccessGlow {
    0% { box-shadow: 0 20px 50px rgba(22,163,74,0.28); }
    50% { box-shadow: 0 24px 68px rgba(34,197,94,0.32); }
    100% { box-shadow: 0 20px 50px rgba(22,163,74,0.22); }
  }

  /* Quick Actions (PhonePe/Paytm small tiles) */
  .quick-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 16px;
    margin-top: 12px;
    margin-bottom: 12px;
    width: 100%;
    box-sizing: border-box;
  }

  /* Section container styling (requirement 9) */
  .quick-actions-panel .quick-actions {
    background: #ffffff;
    border-radius: 28px;
    padding: 20px;
  }

  .quick-action {
    width: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    background: transparent;
    border-radius: 12px;
    padding: 6px 0;
    min-height: 72px; /* touchable area */
    cursor: pointer;
    transition: transform .12s var(--anim-ease), box-shadow .12s ease, opacity .12s ease;
    position: relative;
    overflow: visible;
    -webkit-tap-highlight-color: transparent;
    opacity: 0;
    animation: qaFadeIn .28s cubic-bezier(.22,.12,.08,1) both;
  }

  .quick-action:active { transform: scale(.95); }

  @media (hover:hover) {
    .quick-action:hover { transform: translateY(-4px); }
  }

  .quick-action .qa-icon {
    width: 56px;
    height: 56px;
    border-radius: 999px; /* circular */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 6px 18px rgba(15,23,42,.06);
  }

  /* Colored icon backgrounds like PhonePe */
  .qa-icon--violet { background: linear-gradient(135deg,#7c3aed,#a78bfa); }
  .qa-icon--blue { background: linear-gradient(135deg,#2563eb,#60a5fa); }
  .qa-icon--green { background: linear-gradient(135deg,#16a34a,#34d399); }
  .qa-icon--teal { background: linear-gradient(135deg,#0891b2,#5eead4); }
  .qa-icon--whatsapp { background: linear-gradient(135deg,#10b981,#34d399); }
  .qa-icon--orange { background: linear-gradient(135deg,#f97316,#fb923c); }
  .qa-icon--gray { background: linear-gradient(135deg,#94a3b8,#cbd5e1); color:#0f172a; }
  .qa-icon--indigo { background: linear-gradient(135deg,#4f46e5,#818cf8); }

  .quick-action .qa-label {
    margin-top: 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--mobile-text);
    text-align: center;
    line-height: 1.1;
    width: 100%;
  }

  /* Ripple effect element */
  .quick-action .ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    background: rgba(0,0,0,0.08);
    animation: ripple 600ms linear;
    pointer-events: none;
  }

  @keyframes ripple { to { transform: scale(4); opacity: 0; } }

  @keyframes qaFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Force 4 columns on mobile and small screens per product requirement */
  .quick-actions-panel .quick-actions,
  .quick-actions {
    grid-template-columns: repeat(4, minmax(0,1fr)) !important;
    gap: 16px !important;
  }

  /* Trend chart glass look */

  .trend-chart-wrap .panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
  }

  .trend-chart-wrap .panel-head > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
  }

  .trend-chart-wrap .panel-head h3 {
    margin: 6px 0 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.2;
    align-self: center;
  }

  .trend-chart-wrap .panel-subtitle {
    margin: 4px 0 0;
    color: var(--mobile-muted);
    font-size: 0.92rem;
    line-height: 1.5;
    max-width: 100%;
    align-self: center;
  }

  .trend-chart-wrap .panel-head a.text-link {
    align-self: center;
    margin-top: 4px;
    white-space: nowrap;
  }
  
  .trend-chart-wrap {
    margin-top: 12px;
    padding: 0 6px 8px 6px;
    height: 330px;
    box-sizing: border-box;
  }
  .trend-chart-wrap canvas {
    width: 100% !important;
    height: auto !important;
    display: block;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
    box-shadow: 0 6px 18px rgba(15,76,219,0.04);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-sizing: border-box;
  }

  /* Adjust layout specifically for narrow mobile screens (<=480px) */
  @media (max-width: 480px) {
    .quick-actions-panel .quick-actions,
    .quick-actions {
      grid-template-columns: repeat(4, minmax(0,1fr)) !important;
      gap: 10px !important;
    }

    .quick-action {
      padding: 10px 6px !important;
    }

    .quick-action .qa-icon {
      width: 40px;
      height: 40px;
      font-size: 18px;
      line-height: 40px;
    }

    .quick-action .qa-label {
      font-size: 12px;
      margin-top: 6px;
    }

  }

  
  html,
  body {
    min-width: 0;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  body {
    background: #f5f7fb;
    color: var(--mobile-text);
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
    position: relative;
    margin: 0;
    padding: 0;
    min-height: 100dvh;
  }

  .app {
    display: block;
    min-height: 100dvh;
    width: min(100%, 500px);
    max-width: 500px;
    margin: 0 auto;
    padding-top: 0;
    background: var(--mobile-surface-soft);
    overflow-x: hidden;
  }

  .main {
    margin-left: 8px;
    padding: calc(72px + env(safe-area-inset-top)) 14px calc(92px + env(safe-area-inset-bottom) * 2);
    background: transparent;
    display: block;
    min-height: 100dvh;
    width: 96%;
    box-sizing: border-box;
  }

  .content h1 {
    font-size: 22px;
    margin-bottom: 12px;
    line-height: 1.2;
  }

  .content {
    padding-bottom:
      calc(120px +env(safe-area-inset-bottom))!important;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    align-items: center;
  }

  .footer,
  footer {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
  }

.topbar{
    position:fixed;
    top:0;
    left:0;
    right:0;

    z-index:1300;

    height:
      calc(
         64px +
         env(safe-area-inset-top)
      );

    width:100%;

    max-width:100%;

    margin:0;

    padding:
      calc(env(safe-area-inset-top) + 8px)
      12px
      8px;

    background:var(--mobile-surface);

    display:flex;
    align-items:center;
    justify-content:space-between;

    box-sizing:border-box;

    border-radius:0;

    transform:none;

    border-bottom:
      1px solid rgba(19, 2, 2, 0.12);

    box-shadow:
      0 8px 25px rgba(0,0,0,.12);
}

  .topbar-left,
  .topbar-right {
    flex: 1 1 auto;
    min-width: 0;
  }

  .topbar-left {
    margin-left: 8px;
  }

  .topbar-right {
    margin-right: 8px;
    gap: 6px;
  }

  .topbar-center {
    flex: 0 0 auto;
    display: none;
  }


  .content h1 {
    font-size: 22px;
    margin-bottom: 14px;
    letter-spacing: -0.02em;
  }

  .content > * + * {
    margin-top: var(--mobile-gap-lg);
  }

  .panel,
  .card,
  .dashboard-hero-card,
  .stat-card,
  .quick-card,
  .table-wrap {
    border-radius: var(--radius);
    box-shadow: var(--mobile-shadow);
    background: var(--mobile-surface);
    border: 1px solid rgba(226,232,240,.9);
  }

  .collect-page .panel,
  .cards-page .panel {
    padding: 18px;
  }

  .collect-page .panel-head,
  .cards-page .panel-head {
    gap: 10px;
  }

  .collect-page .panel-head h3,
  .cards-page .panel-head h3 {
    font-size: 17px;
    margin: 0;
  }

  .collect-page .panel-subtitle,
  .cards-page .panel-subtitle {
    font-size: 13px;
    color: var(--mobile-muted);
    margin: 4px 0 0;
  }

  .collect-page #reader {
    margin-top: 18px;
    min-height: 220px;
    border-radius: 20px;
    overflow: hidden;
    background: #eef6ff;
    border: 1px solid rgba(37, 99, 235, 0.14);
  }

  .collect-page .row,
  .cards-page .row {
    display: grid;
    gap: 12px;
  }

  .collect-page .row button,
  .cards-page .row button {
    width: 100%;
  }

  .cards-page .cards-grid {
    margin-top: 16px;
    gap: 16px;
  }

  .register-page .content {
    padding: 0 0 24px;
    margin-bottom: 24px;  
  }

  .register-page .register-shell {
    gap: 12px;
    max-width: 100%;
    width: 100%;
  }

  .register-page .register-hero,
  .register-page .register-card {
    padding: 16px;
    border-radius: 18px;
    margin-top: 18px;
  }

  .register-page .register-hero h2 {
    font-size: 20px;
  }

  .register-page .register-hero p,
  .register-page .register-hero li {
    font-size: 13px;
  }

  .register-page .field-group {
    padding: 12px 0;
    margin-bottom: 10px;
  }

  .register-page .register-card .row {
    gap: 10px;
  }

  .register-page .register-submit {
    width: 100%;
    min-width: 0;
    padding: 12px 16px;
    font-size: 15px;
  }

  .cards-page .farmer-card .body {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  @media (max-width: 360px) {

    .subscription-payment-grid {
      grid-template-columns: 1fr;
      gap: 14px;
    }

    .subscription-payment-qr,
    .subscription-payment-details,
    .subscription-form {
      width: 100%;
      min-width: 0;
      padding: 14px;
    }

    .subscription-payment-qr img {
      max-width: 180px;
      width: 100%;
      height: auto;
    }

    .subscription-payment-details .value {
      gap: 10px;
      flex-direction: column;
      align-items: stretch;
    }

    .subscription-payment-details .value button,
    .subscription-payment-details .value input {
      width: 100%;
      min-width: 0;
    }

    .subscription-payment-details .detail-row {
      flex-wrap: wrap;
      gap: 10px;
    }
  }

  @media (max-width: 480px) {
    .subscription-payment-grid {
      grid-template-columns: 1fr;
      gap: 16px;
    }

    .subscription-payment-qr,
    .subscription-payment-details,
    .subscription-form {
      width: 100%;
      min-width: 0;
      padding: 16px;
      box-sizing: border-box;
    }

    .subscription-payment-qr img {
      width: 100%;
      max-width: 220px;
      height: auto;
    }

    .subscription-payment-details {
      display: grid;
      gap: 14px;
    }

    .subscription-payment-details .field {
      display: grid;
      gap: 10px;
    }

    .subscription-payment-details .value {
      flex-direction: column;
      align-items: stretch;
      justify-content: flex-start;
      gap: 10px;
    }

    .subscription-payment-details .value button,
    .subscription-payment-details .value input {
      width: 100%;
      min-width: 0;
    }

    .subscription-form input,
    .subscription-form textarea {
      padding: 14px;
    }

    .subscription-form .btn.primary {
      width: 100%;
      min-width: 0;
      align-self: stretch;
    }
  }
  .cards-page{
    margin-top:24px;
  }

  .cards-page .farmer-card .photo {
    width: 100%;
    height: 180px;
  }

  .cards-page .farmer-card .qr-wrap {
    align-items: flex-start;
    width: 100%;
  }

  .cards-page .farmer-card .info .fid,
  .cards-page .farmer-card .info .mob,
  .cards-page .farmer-card .info .addr {
    white-space: normal;
  }

  .cards-page #list table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border-radius: 20px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
  }

  .cards-page #list thead,
  .cards-page #list th {
    display: none;
  }

  .cards-page #list tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .cards-page #list tr {
    display: block;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
  }

  .cards-page #list td {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end; 
    gap: 10px 12px;
    padding: 14px 16px;
    color: var(--mobile-text);
  }

  .cards-page #list td::before {
    content: attr(data-label);
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .5px;
    justify-self: start;
    line-height: 1.2;
    white-space: normal;
  }

  .cards-page #list td[data-label="Actions"] {
    display: flex;
    flex-wrap: wrap;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start !important;
    gap: 10px;
    padding-right: 4px;
  }

  .cards-page #list td[data-label="Actions"]::before {
    flex: 0 0 auto;
    order: 1;
    justify-self: start;
    margin-right: 0;
  }

  .cards-page #list td[data-label="Actions"] .btn {
    order: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 6px;
    min-width: 0;
    min-height: 36px;
    padding: 8px 10px;
    font-size: 13px;
    white-space: normal;
    margin: 0;
  }

  .cards-page #list td[data-label="Select"] .sel {
    transform: scale(0.9);
    margin-top: 0;
    width: 18px;
    height: 18px;
    align-items: right;
    justify-content: right;
    margin-right: 0;
  }

  .cards-page #list td[data-label="ID"],
  .cards-page #list td[data-label="Name"],
  .cards-page #list td[data-label="Mobile"] {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: space-between;
  }

  .cards-page #list td[data-label="ID"] b {
    display: block;
  }

  .cards-page .farmer-card .qr {
    width: 100%;
    max-width: 220px;
    height: auto;
    aspect-ratio: 1 / 1;
  }

  .cards-page .farmer-card .qr-label {
    text-align: left;
    width: 100%;
  }


  .topbar-desktop-shell {
    display: none;
  }

  .topbar-mobile-shell {
    display: grid;
    grid-template-columns: auto minmax(0,1fr) auto;
    align-items: center;
    width: 100%;
    height: auto;
    padding: 0 12px;
    box-sizing: border-box;
    gap: 10px;
    justify-content: space-between;
  }

  .topbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
  }
  .topbar-right .btn {
    width: auto;
    min-width: 80px;
    min-height: 40px;
    padding: 0 12px;
    font-size: 14px;
    white-space: nowrap;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #ffffff;
    color: #0f172a;
    box-shadow: none;
    text-decoration: none;
  }

  .topbar-right .btn:active {
    transform: translateY(0);
  }
  .topbar-right .btn.secondary,
  .topbar-right .btn.primary {
    min-width: 80px;
  }
  .topbar-right .btn.primary {
    height: 40px;
    line-height: 40px;
    text-decoration: none;
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
  }
  .topbar-right .btn.secondary {
    height: 40px;
    line-height: 40px;
    text-decoration: none;
  }
  @media (max-width: 900px) {
    .topbar-left h2 {
      display: none;
    }
  }

  .menu-toggle {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: #f3f6ff;
    color: var(--mobile-accent);
    border: 0;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .menu-toggle::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.15) 0%, rgba(255,255,255,0) 70%);
    transform: scale(0.5);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: -1;
  }

  .menu-toggle:active::before {
    transform: scale(1.7);
    opacity: 1;
  }

  .appbar-icon-btn {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 12px;
    background: #f3f6ff;
    color: var(--mobile-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
  }

  .global-search,
  .topbar-right .floating-install-btn,
  .user-chip {
   display: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(92vw, 320px);
    min-width: 0;
    height: 100dvh;
    max-height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    border-radius: 0 24px 24px 0;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.24);
    background:  #166543 ;
    z-index: 1500;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 24px 56px rgba(15, 23, 42, 0.28);
  }

  .mobile-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.48);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 1299;
  }

  .mobile-drawer-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  body.drawer-open .sidebar {
    transform: translateX(0) !important;
  }

  body.drawer-open .topbar {
    z-index: 1200;
  }

  body:has(.sidebar.open) .main {
    /* Avoid transforming the main content when drawer is open.
       Transform creates a new stacking context which can place
       the topbar above fixed-position elements like the sidebar.
       Keep only a subtle visual effect without transform. */
    filter: saturate(0.96);
  }

  .sidebar::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.08), transparent 30%);
    pointer-events: none;
  }

  @media (max-width: 480px) {
    .main {
      padding-bottom: calc(92px + env(safe-area-inset-bottom));
    }

    .content {
      padding-bottom: calc(14px + 72px + env(safe-area-inset-bottom));
    }

    .mobile-bottom-nav {
      height: calc(72px + env(safe-area-inset-bottom));
    }

    .panel-head > div:last-child {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-end;
      align-items: center;
      gap: 8px;
      width: 100%;
    }

    .panel-head > div:last-child .farmer-search {
      width: min(100%, 160px);
      flex: 1 1 auto;
      min-width: 0;
      box-sizing: border-box;
    }

    .panel-head > div:last-child .btn.primary.sm {
      min-width: 0;
      flex: 0 0 auto;
      width: auto;
    }

    .farmer-panel-add-btn {
      width: 100% !important;
      flex: 1 1 100% !important;
    }
  }

  .sidebar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 14px;
    margin: 12px 12px 10px;
    border-radius: 18px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.09);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  }

  .sidebar .brand-logo {
    width: 46px;
    height: 46px;
    padding: 10px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(255,255,255,0.16);
  }

  .sidebar .brand-text h1 {
    font-size: 18px;
    margin: 0 0 2px;
    color: #fff;
    line-height: 1.15;
  }

  .sidebar .brand-text p {
    font-size: 12px;
    line-height: 1.3;
    color: rgba(255,255,255,0.7);
  }

  .sidebar .nav {
    padding: 8px 10px 10px;
  }

  .sidebar .nav-link {
    height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    color: #f3eeee;
    font-size: 14px;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    isolation: isolate;
  }

  .sidebar .nav-link::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.24) 0%, rgba(255,255,255,0) 70%);
    transform: scale(0.4);
    transform-origin: center;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: -1;
  }

  .sidebar .nav-link:active::before {
    transform: scale(2.2);
    opacity: 1;
  }

  .sidebar .nav-link:hover,
  .sidebar .nav-link.active {
    background: linear-gradient(135deg, #166543, #34d399);
    color: #fff;
    box-shadow: 0 10px 24px rgba(37, 235, 156, 0.25);
  }

  .sidebar .sidebar-account {
    margin: 8px 10px 18px;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
  }

  .sidebar .sidebar-account-title {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.62);
    margin-bottom: 8px;
  }

  .hero-dashboard,
  .dashboard-hero-card,
  .farmer-portal-hero,
  .pricing-hero,
  .settings-hero,
  .profile-hero,
  .wa-hero,
  .audit-hero {
    padding: var(--mobile-hero-padding);
    border-radius: 24px;
    background: linear-gradient(135deg, #f8fbff 0%, #eef6ff 100%);
    border: 1px solid rgba(37, 99, 235, 0.12);
    box-shadow: var(--mobile-shadow);
    color: var(--mobile-text);
  }

  .audit-hero h1,
  .audit-hero p,
  .audit-hero span,
  .audit-hero strong,
  .audit-hero div {
    color: var(--mobile-text) !important;
  }

  .settings-hero .settings-title h2,
  .settings-hero .settings-title p,
  .settings-hero .settings-status {
    color: var(--mobile-text);
  }

  .panel-head,
  .section-head,
  .portal-section-header,
  .settings-card-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
  }

  .panel-head h3,
  .section-head h3,
  .portal-section-header h3,
  .panel-head h2,
  .section-head h2 {
    font-size: 16px;
    margin: 0;
  }

  .profile-hero {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    width: 90%;
    margin-bottom: 12px;
  }

  .profile-avatar {
    width: 72px;
    height: 72px;
    min-width: 72px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: #ffffff;
    background: #244b87;
    box-shadow: 0 10px 24px rgba(22, 163, 74, 0.16);
    position: relative;
    overflow: visible;
    cursor: pointer;
  }

  .profile-avatar-default { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
  .profile-avatar-default svg { width: 68%; height: 68%; fill: currentColor; }
  .profile-avatar img { border-radius: 50%; }
  .profile-avatar-edit { position: absolute; right: -7px; bottom: -6px; width: 27px; height: 27px; display: flex; align-items: center; justify-content: center; background: #19a7d8; border: 2px solid #fff; border-radius: 50%; color: #fff; line-height: 1; }
  .profile-avatar-edit svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

  .profile-details {
    min-width: 0;
  }

  .profile-details h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .profile-details p {
    margin: 4px 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .profile-role {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-top: 6px;
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
  }

  .profile-hero > div:last-child {
    justify-self: end;
    width: auto;
    max-width: 120px;
  }

  .profile-hero .btn.ghost {
    width: 100%;
    min-width: 0;
    white-space: nowrap;
  }

  .profile-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .profile-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px;
    border-radius: 20px;
    background: var(--mobile-surface);
    border: 1px solid var(--mobile-border);
    text-align: left;
  }

  .profile-stat span {
    font-size: 13px;
    color: var(--mobile-muted);
  }

  .profile-stat strong {
    font-size: 18px;
    color: var(--mobile-text);
  }

  .panel,
  .panel-body,
  .dashboard-shell .panel,
  .settings-card,
  .profile-edit-card,
  .payment-summary-card,
  .report-card,
  .notice-card,
  .wa-card,
  .audit-card,
  .plan-card,
  .farmer-card,
  .collection-stat,
  .stat-card,
  .quick-card,
  .collection-entry-panel,
  .payment-card,
  .timeline-item {
    background: var(--mobile-surface);
    border: 1px solid var(--mobile-border);
    border-radius: var(--mobile-radius);
    box-shadow: var(--mobile-shadow);
    padding: var(--mobile-card-padding);
    margin-bottom: var(--mobile-gap-md);
  }
  .payment-summary-card,
  .report-card,
  .collection-stat,
  .stat-card,
  .quick-card,
  .collection-entry-panel,
  .payment-card,
  .timeline-item {
    border-radius: var(--mobile-radius-sm);
  }

  .dashboard-shell,
  .dashboard-middle,
  .dashboard-cards,
  .stat-grid,
  .quick-grid,
  .quick-actions,
  .payment-summary,
  .report-summary,
  .settings-grid,
  .profile-stats,
  .subscription-overview,
  .farmer-stats-grid,
  .collection-stats,
  .wa-stats,
  .audit-dashboard,
  .milk-test-grid,
  .modern-pricing-grid,
  .pricing-grid,
  .notice-list,
  .timeline-list {
    display: grid;
    gap: var(--mobile-gap-md);
  }

  .dashboard-shell,
  .dashboard-middle {
    gap: var(--mobile-gap-lg);
  }

  .stat-grid,
  .payment-summary,
  .report-summary,
  .collection-stats,
  .wa-stats,
  .dashboard-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    grid-auto-rows: 1fr;
  }

  .report-summary {
    grid-template-columns: 1fr;
  }

  .report-summary .report-card {
    width: 100%;
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
  }

  .quick-grid,
  .quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--mobile-gap-sm);
  }

  .founder-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--mobile-gap-sm);
  }

  .founder-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--mobile-gap-sm);
    width: 100%;
    align-items: stretch;
    justify-items: center; /* center grid items horizontally */
  }

  .founder-actions .action-card {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: center; /* center contents (buttons) */
    align-items: center;
    padding: 6px 0;
  }

  .founder-actions .action-card .btn {
    width: auto; /* don't force full-width buttons on mobile; let them size naturally */
    min-width: 120px;
  }

  .settings-grid,
  .profile-stats,
  .audit-dashboard,
  .milk-test-grid,
  .modern-pricing-grid,
  .pricing-grid {
    grid-template-columns: 1fr;
  }

  .modern-pricing-grid,
  .pricing-grid,
  .dashboard-shell,
  .dashboard-middle {
    overflow: visible;
  }

  .pricing-grid > *,
  .modern-pricing-grid > * {
    min-width: 0;
  }

  .dashboard-middle,
  .dashboard-shell,
  .row,
  .form-row,
  .filter-grid,
  .profile-form-grid,
  .statement-controls,
  .settings-footer,
  .audit-actions {
    display: flex;
    flex-direction: column;
    gap: var(--mobile-gap-md);
  }

  .form-row > div,
  .filter-grid > div,
  .profile-form-grid > div,
  .statement-controls > div,
  .settings-card form > div {
    width: 100%;
    min-width: 0;
  }

  .form-row > div {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
    align-items: flex-start;
  }

  .form-row label,
  .settings-card-header span,
  .panel-subtitle,
  .hero-eyebrow,
  .profile-hero p {
    font-size: 13px;
    color: var(--mobile-muted);
    
  }

  input,
  textarea,
  select {
    width: 100%;
    min-height: 50px;
    padding: 0 16px;
    border-radius: 16px;
    border: 1px solid var(--mobile-border);
    background: var(--mobile-surface-soft);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
    font-size: 16px;
    line-height: 1.4;
    color: var(--mobile-text);
    box-sizing: border-box;
    min-width: 0;
  }

  textarea {
    min-height: 160px;
    padding-top: 14px;
  }

  .btn,
  input,
  textarea,
  select {
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  }

  .btn {
    width: 54px;
    height: 54px;
    padding: 0 16px;
    border-radius: 16px;
    font-size: 15px;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    isolation: isolate;
    box-sizing: border-box;
    min-width: 100%;
  }


  .btn::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 70%);
    transform: scale(0.5);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: -1;
  }

  .btn:active::before {
    transform: scale(1.9);
    opacity: 1;
  }

  .btn.primary {
    background: linear-gradient(135deg, #166534, #22c55e)!important;
    color: #fff;
    border: 0;
  }

  .btn.secondary,
  .btn.ghost {
    background: #fff;
    color: var(--mobile-text);
    border: 1px solid var(--mobile-border);
  }

  .ledger-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
  }

  .ledger-actions button + button {
    margin-left: 10px;
  }

  .stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 142px;
    height: 100%;
    padding: 18px 16px;
    width: 100%;
    box-sizing: border-box;
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
    border: 1px solid rgba(148, 163, 184, .16);
    border-radius: 18px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .06), inset 0 1px 2px rgba(255, 255, 255, .5);
    position: relative;
    overflow: hidden;
    transition: transform .24s cubic-bezier(.22,.12,.08,1), box-shadow .24s ease, background .24s ease;
  }

  .stat-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    opacity: .9;
    border-radius: 3px 0 0 3px;
  }

  .stat-card--farmers::before { background: linear-gradient(180deg, #7c3aed 0%, #a78bfa 100%); }
  .stat-card--collection::before { background: linear-gradient(180deg, #2563eb 0%, #60a5fa 100%); }
  .stat-card--payments::before { background: linear-gradient(180deg, #d97706 0%, #fbbf24 100%); }
  .stat-card--sync::before { background: linear-gradient(180deg, #db2777 0%, #f472b6 100%); }

  .stat-card:active {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, .08), inset 0 1px 2px rgba(255, 255, 255, .6);
  }

  .stat-card .stat-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .08), inset 0 1px 2px rgba(255, 255, 255, .8);
    transition: transform .24s cubic-bezier(.22,.12,.08,1), box-shadow .24s ease;
  }

  .stat-card--farmers .stat-icon { background: linear-gradient(135deg, #ede9fe 0%, #f5f0ff 100%); color: #6d28d9; box-shadow: 0 4px 12px rgba(125, 58, 237, .12), inset 0 1px 2px rgba(255, 255, 255, .8); }
  .stat-card--collection .stat-icon { background: linear-gradient(135deg, #e0e7ff 0%, #ede9fe 100%); color: #1d4ed8; box-shadow: 0 4px 12px rgba(37, 99, 235, .12), inset 0 1px 2px rgba(255, 255, 255, .8); }
  .stat-card--payments .stat-icon { background: linear-gradient(135deg, #fefae8 0%, #fff8e7 100%); color: #b45309; box-shadow: 0 4px 12px rgba(217, 119, 6, .12), inset 0 1px 2px rgba(255, 255, 255, .8); }
  .stat-card--sync .stat-icon { background: linear-gradient(135deg, #fdf1f7 0%, #fce7f3 100%); color: #be185d; box-shadow: 0 4px 12px rgba(219, 39, 119, .12), inset 0 1px 2px rgba(255, 255, 255, .8); }

  .stat-card:active .stat-icon {
    transform: scale(1.05);
  }

  .stat-card .stat-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
  }

  .stat-card__content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
    gap: 2px;
    flex: 1;
  }

  .stat-card .value,
  .collection-stat .value,
  .payment-summary-card .amount,
  .farmer-stat-card .value {
    font-size: 24px;
    line-height: 1.12;
    font-weight: 700;
  }

  .dashboard-hero-card .hero-copy,
  .dashboard-hero-card .hero-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .dashboard-hero-card .hero-meta {
    margin-top: 8px;
  }

  .payment-summary-card .amount,
  .collection-stat .value {
    font-size: 22px;
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
  }

  .report-summary .report-card .value {
    font-size: 22px;
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
  }

  .stat-card__label {
    font-size: 12px;
    line-height: 1.3;
    color: var(--mobile-muted);
    margin: 0;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    opacity: .85;
  }

  .stat-card__value {
    font-size: 26px;
    font-weight: 850;
    line-height: 1.1;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
  }

  .stat-card__hint {
    font-size: 12px;
    line-height: 1.35;
    color: var(--mobile-muted);
    margin: 0;
    font-weight: 500;
    opacity: .8;
  }

  .quick-card {
    min-height: 96px;
    padding: 16px;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 10px;
    text-align: left;
    background: #f8fbff;
    border: 1px solid rgba(37, 99, 235, 0.12);
    box-shadow: none;
  }

  .quick-card .quick-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #fff;
    color: var(--mobile-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .quick-card .quick-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
  }

  .quick-card .quick-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--mobile-text);
  }

  .trend-chart-wrap,
  .trend-panel {
    width: 100%;
    overflow: hidden;
  }

  .payment-summary-card,
  .report-card,
  .collection-stat {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .payment-summary-card h4,
  .report-card h4,
  .collection-stat h4 {
    font-size: 13px;
    color: var(--mobile-muted);
    margin: 0;
    font-weight: 600;
  }

  .settings-card-header {
    margin-bottom: 14px;
  }

  .formula-box,
  .user-management-cta,
  .ledger-summary-cards,
  .msg,
  .status-pill {
    border-radius: 16px;
    padding: 12px;
  }

  .filter-actions {
    display: grid;
    gap: 10px;
  }
  .form-row{
   padding-right:20px;
}
  #cf .form-row > div:first-child > div {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
  }
  #cf .form-row > div:first-child input,
  #cf .form-row #collection_farmer_search{
    flex: 0;
    min-width: 0;
    height: 44px!important;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid var(--mobile-border);
    background: var(--mobile-surface-soft);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
    width: 100%;
    max-width: 100%;
    font-size: 14px;

  }

  #pf .form-row > div:first-child input,
  #pf .form-row #payment_farmer_search {
    flex:0;
    min-width: 0;
    min-height: 44px !important;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid var(--mobile-border);
    background: var(--mobile-surface-soft);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
    width: 100%;
    max-width: 100%;
    font-size: 14px;
  }

  #cf .form-row > div:first-child button {
    flex: 0 0 auto;
    width: auto;
    min-width: 110px;
  }

  .table-wrap {
    width: 100%;
    overflow: visible;
    box-sizing: border-box;
  }

  .table-wrap table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
    display: block;
  }

  .table-wrap th,
  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .table-wrap tr {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 0;
    padding: clamp(16px, 3vw, 20px);
    border-radius: 22px;
    border: 1px solid rgba(226,232,240,.9);
    background: var(--mobile-surface);
    box-shadow: var(--mobile-shadow);
    
  }

  .table-wrap td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding:  0;
    border: 0;
    border-bottom:1px solid #eef2f7;
    color: var(--mobile-text);
    min-width: 0;
    
  }


  .table-wrap td:last-child {
    padding-bottom: 0;
    
  
  }

  .table-wrap td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 12px;
    color: var(--mobile-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    display: flex;
    flex: 0 0 auto;
    align-items: flex-start;
    line-height: 1.3;
    
  }

  .table-wrap td span,
  .table-wrap td strong {
    font-size: 15px;
    color: var(--text);
    width: auto;
    min-width: 0;
    word-break: break-word;
    white-space: normal;
  }
  

  .table-wrap td[data-label="Actions"] {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  /* Centers page: center action buttons on mobile */
  .table-wrap.centers td[data-label="Actions"] {
    justify-content: center;
  }

  .table-wrap td[data-label="Actions"]::before {
    flex: 0;
    margin-right: auto;
  }

  .table-wrap td[data-label="Actions"] .btn {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 82px;
    min-height: 40px;
    padding: 10px 12px;
    font-size: 13px;
    margin-right: 0;
    margin-left: 0;
    white-space: nowrap;

  }

  #logsContainer .audit-logs-table {
    display: block;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }

  #logsContainer .audit-logs-table thead {
    display: none;
  }

  #logsContainer .audit-logs-table tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  #logsContainer .audit-logs-table tr {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  }

  #logsContainer .audit-logs-table td {
    display: block;
    padding: 0;
    border: 0;
    border-bottom: 1px solid #f1f5f9;
    min-width: 0;
  }

  #logsContainer .audit-logs-table td:last-child {
    border-bottom: 0;
  }

  #logsContainer .audit-logs-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1.4;
  }

  #logsContainer .audit-logs-table td > * {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    word-break: break-word !important;
    white-space: normal !important;
  }

  #logsContainer .audit-logs-table td {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 !important;
  }

  #logsContainer .audit-log-cell {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  #logsContainer .audit-log-value,
  #logsContainer .audit-logs-table td span,
  #logsContainer .audit-logs-table td strong {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    white-space: normal !important;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(52px + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.95);
    border-top: 1px solid rgba(226,232,240,.92);
    box-shadow: 0 -10px 30px rgba(15,23,42,.08);
    z-index: 1260;
  }

  .mobile-nav-item {
    flex: 1;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 16px;
    color: var(--mobile-muted);
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    transition: color .25s ease, background .25s ease, transform .25s ease;
    padding: 6px 4px;
  }

  .mobile-nav-item.active {
    color: #000000;
    background: #b3f8da;
    opacity: 0.6;
    box-shadow: 0 6px 20px rgba(22, 101, 67, .24);
  }

  .mobile-nav-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
  }

  .mobile-nav-item:active {
    transform: scale(0.96);
  }

  .mobile-nav-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
  }

  .mobile-nav-item.premium-collect .mobile-nav-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  
  }

  .mobile-nav-item.premium-collect .mobile-nav-icon svg {
    width: 32px;
    height: 32px;
  }

  .mobile-nav-item.premium-collect .mobile-nav-label {
    font-weight: 800;
  }

  .fab {
    position: fixed;
    right: 16px;
    bottom: 92px;
    width: 58px;
    height: 58px;
    border-radius: 18px;
    border: 0;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #fff;
    box-shadow: 0 16px 36px rgba(37, 99, 235, 0.28);
    z-index: 1400;
    overflow: hidden;
    isolation: isolate;
  }

  .fab::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.24) 0%, rgba(255,255,255,0) 72%);
    transform: scale(0.4);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: -1;
  }

  .fab:active::before {
    transform: scale(1.8);
    opacity: 1;
  }

  .fab:active {
    transform: scale(0.96);
  }

  .offline-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: #16a34a;
  }
  .offline-badge .dot{
    width: 10px;
    height: 10px;
    background: #16a34a;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(22,163,74,.25);
  }
}
/* Mobile Dashboard Chart Header */
@media (max-width:768px) {
  .dashboard-middle .panel-head {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 12px;
    width: 100%;
    padding-bottom: 12px;
    margin: 0;
    box-sizing: border-box;
  }

  .dashboard-middle .panel-head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
  }

  .dashboard-middle .panel-head select {
    width: 110px;
    overflow: hidden;
    white-space: nowrap;
  }

  .dashboard-shell .panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
  }

  .dashboard-shell .panel-head > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
  }

  .dashboard-shell .panel-head h3 {
    margin: 6px 0 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.2;
    align-self: center;
  }

  .dashboard-shell .panel-subtitle {
    margin: 4px 0 0;
    color: var(--mobile-muted);
    font-size: 0.92rem;
    line-height: 1.5;
    max-width: 100%;
    align-self: center;
  }

  .dashboard-shell .panel-head a.text-link {
    align-self: center;
    margin-top: 4px;
    white-space: nowrap;
  }

  .dashboard-middle {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    margin-top: 0 !important;
    margin-bottom: 12px !important;
  }



  .trend-panel,
  .subscription-panel,
  .suppliers-panel {
    width: auto !important;
    max-width: 100% !important;
    margin: 0 !important;
    min-height: auto !important;
  }

  .panel,
  .trend-panel,
  .trend-chart-wrap {
    box-sizing: border-box !important;
  }

  .dashboard-middle .chart-container {
    width: 100%;
    max-width: 100%;
    display: block;
  }
  .subscription-overview{
    grid-template-columns: 1fr;
    gap: 12px;
  }

.register-result-body{

    display:flex !important;

    flex-direction:column !important;

    align-items:center !important;

    gap:24px !important;
}

.register-result-info{

    width:100%;

    display:flex;

    flex-direction:column;

    align-items:center;

    text-align:center;

    gap:24px;
}

.result-item{

    width:100%;

    flex:none !important;
}
.register-result-qr{

    width:100%;

    display:flex;

    flex-direction:column;

    align-items:center;

    justify-content:center;

    margin-top:0;
}
.register-result-actions{

    width:100%;

    display:flex;

    flex-direction:column;

    align-items:center;

    gap:12px;
}
.register-result-actions .btn{

    width:min(100%,260px);

    justify-content:center;

    text-align:center;
}
#result{

    padding:18px !important;
}
#result h2{

    font-size:clamp(28px,5vw,38px);
}
.report-card--collection .value,
.report-card--farmers .value,
.report-card--snf .value,
.report-card--revenue .value {
    font-size:clamp(28px,5vw,28px) !important;
    align-items:flex-start !important;
    justify-content:flex-start !important;
    text-align:left !important;
}
.btn.primary.save-settings-btn{
    width:100%;
}
.wa-hero .btn{
    min-width:60%;
}
.subscription-payment-details .value{

    font-size:clamp(16px,5vw,24px) !important;
}
    .user-management-header{
        flex-direction:column;
        align-items:flex-start;
        padding:20px;
        gap:16px;
    }

    .user-management-header > div{
        width:100%;
        min-width:0;
    }

    .user-management-header .btn.primary{
        width:100%;
        margin-top:0;
    }

    .user-search{
        width:100%;
        max-width:100%;
    }

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

    .user-cards-grid{
        grid-template-columns:1fr;
    }
    .user-actions{
        justify-content:flex-start;
    }
    .user-actions .btn{
        width:100%;
        padding:12px 16px;
    }
}
@media(min-width:381px)
and (max-width:390px) {
  .topbar {
    padding: calc(env(safe-area-inset-top) + 8px) 10px 8px;
    gap: 8px;
  }

  .topbar-left,
  .topbar-right {
    margin: 0;
    gap: 8px;
  }

  .topbar-right .btn,
  .topbar-right .btn.primary,
  .topbar-right .btn.secondary {
    min-width: 64px;
    padding: 0 10px;
    font-size: 13px;
    height: 36px;
    line-height: 36px;
  }

  .appbar-brand span {
    font-size: 14px;
    max-width: 100px;
  }

  .appbar-brand img,
  .menu-toggle,
  .appbar-icon-btn {
    width: 38px;
    height: 38px;
  }

  .topbar-mobile-shell {
    padding: 0 10px;
  }

  .quick-grid,
  .quick-actions {
    gap: 6px;
  }

  .dashboard-shell,
  .dashboard-middle {
    gap: 10px;
  }

  .panel,
  .stat-card,
  .quick-card,
  .dashboard-shell .panel {
    padding: 14px;
  }
  .subscription-overview{
    grid-template-columns: 1fr;
    gap: 12px;
  }
  #r_qr{

    width:170px !important;

    height:170px !important;
}
}

@media(min-width:321px)
and (max-width:380px){
  
  .main {
      padding: calc(72px + env(safe-area-inset-top)) 10px calc(92px + env(safe-area-inset-bottom) * 2);
      min-width: none;
    }
  .topbar {
    padding: calc(env(safe-area-inset-top) + 8px) 8px 8px;
    gap: 6px;
  }

  .topbar-left,
  .topbar-right {
    margin: 0;
    gap: 6px;
  }

  .topbar-right .btn,
  .topbar-right .btn.primary,
  .topbar-right .btn.secondary {
    min-width: 56px;
    padding: 0 8px;
    font-size: 12px;
    height: 34px;
    line-height: 34px;
  }

  .appbar-brand span {
    font-size: 13px;
    max-width: 84px;
  }

  .appbar-brand img,
  .menu-toggle,
  .appbar-icon-btn {
    width: 34px;
    height: 34px;
  }

  .topbar-mobile-shell {
    padding: 0 8px;
  }

  .cards-page #list td {
    grid-template-columns: minmax(68px, 30%) minmax(0, 1fr);
    gap: 8px 10px;
    padding: 12px 12px;
  }

  .cards-page #list td[data-label="Actions"] .btn {
    min-width: 68px;
    min-height: 36px;
    padding: 8px 10px;
    font-size: 12px;
  }

  .table-wrap td {
    gap: 8px;
  }

  .mobile-bottom-nav {
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  }

  .mobile-nav-item {
    min-height: 52px;
    font-size: 10px;
    padding: 6px 2px;
  }

  .mobile-nav-icon {
    width: 26px;
    height: 26px;
    font-size: 16px;
  }

  .fab {
    right: 12px;
    bottom: 82px;
    width: 54px;
    height: 54px;
  }

  .dashboard-shell .panel-head,
  .dashboard-middle .panel-head {
    grid-template-columns: 1fr;
  }


  .quick-grid,
  .quick-actions {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .profile-hero {
    grid-template-columns: 1fr;
  }

  .profile-avatar {
    width: 60px;
    height: 60px;
  }

  .profile-details h1 {
    font-size: 18px;
  }
  #r_qr{

    width:170px !important;

    height:170px !important;
}
}



@media (min-width: 321px) and (max-width: 340px) {
  .topbar {
    padding: calc(env(safe-area-inset-top) + 8px) 6px 8px;
  }

  .topbar-right .btn,
  .topbar-right .btn.primary,
  .topbar-right .btn.secondary {
    min-width: 52px;
    padding: 0 6px;
    font-size: 12px;
    height: 32px;
    line-height: 32px;
  }

  .appbar-brand span {
    font-size: 12px;
    max-width: 80px;
  }

  .appbar-brand img,
  .menu-toggle,
  .appbar-icon-btn {
    width: 34px;
    height: 34px;
  }

  .topbar-mobile-shell {
    padding: 0 6px;
  }

  .dashboard-shell,
  .dashboard-middle {
    gap: 7px;
  }

  .quick-grid,
  .quick-actions {
    gap: 4px;
  }

  .panel,
  .stat-card,
  .quick-card,
  .dashboard-shell .panel {
    padding: 12px;
  }
  .subscription-overview{
    grid-template-columns: 1fr;
    gap: 12px;
  }
  #r_qr{

    width:150px !important;

    height:150px !important;

    max-width:100%;
}
}

@media (max-width: 320px) {
  .topbar {
    padding: calc(env(safe-area-inset-top) + 8px) 6px 6px;
  }

  .topbar-left,
  .topbar-right {
    gap: 5px;
  }

  .topbar-right .btn,
  .topbar-right .btn.primary,
  .topbar-right .btn.secondary {
    min-width: 48px;
    padding: 0 4px;
    font-size: 11px;
    height: 30px;
    line-height: 30px;
    white-space: nowrap;
  }

  .appbar-brand span {
    font-size: 11px;
    max-width: 72px;
  }

  .appbar-brand img,
  .menu-toggle,
  .appbar-icon-btn {
    width: 32px;
    height: 32px;
  }

  .topbar-mobile-shell {
    padding: 0 6px;
  }

  .dashboard-shell,
  .dashboard-middle {
    gap: 6px;
  }

  .quick-grid,
  .quick-actions {
    gap: 4px;
  }

  .panel,
  .stat-card,
  .quick-card,
  .dashboard-shell .panel {
    padding: 10px;
  }

  .stat-card__value {
    font-size: 1.05rem;
  }
  .subscription-overview{
    grid-template-columns: 1fr;
    gap: 12px;
  }
  #r_qr{

    width:150px !important;

    height:150px !important;

    max-width:100%;
}
  
  .notice-page-header {
    margin-bottom: 24px;
    padding: 16px 0;
  }
  
  .notice-page-title {
    font-size: 24px;
    margin-bottom: 6px;
  }
  
  .notice-page-subtitle {
    font-size: 14px;
  }
  
  .notice-composer-wrapper {
    max-width: 100%;
    padding: 0;
  }
  
  .notice-create-panel {
    border-radius: 18px;
    margin-bottom: 20px;
  }
  
  .notice-composer {
    gap: 20px;
  }
  
  .notice-section {
    padding-bottom: 20px;
  }
  
  #nf #title {
    height: 48px;
    font-size: 15px;
  }
  
  .notice-create-panel textarea {
    min-height: 150px;
  }
  
  .notice-preview {
    margin-top: 16px;
    padding: 16px;
  }
  
  .notice-actions-buttons {
    flex-direction: column;
  }
  
  .notice-publish-btn {
    width: 100%;
    height: 48px;
    justify-content: center;
  }

}

@media (max-width: 768px) {
  body:not(:has(.farmer-management)):not(:has(.dashboard-shell)) .main {
    padding-top: calc(88px + env(safe-area-inset-top));
  }
}

/* Keep the WhatsApp communication tiles compact after generic mobile rules load. */
@media (max-width: 900px) {
  .whatsapp-page,
  .settings-page {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .whatsapp-header,
  .whatsapp-workspace,
  .settings-header,
  .settings-section {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .whatsapp-section-heading,
  .settings-section__heading {
    flex-wrap: wrap;
  }

  .whatsapp-page .quick-actions2 .quick-action {
    width: 100%;
    min-height: 70px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px;
    opacity: 1;
    animation: none;
    text-align: left;
  }

  .whatsapp-page .whatsapp-workspace > .broadcast-panel {
    min-height: 0;
  }

  .whatsapp-page .quick-actions2 .quick-action__icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    flex: 0 0 38px;
    border-radius: 11px;
    font-size: 1.1rem;
  }

  .whatsapp-page .quick-actions2 .quick-action strong,
  .whatsapp-page .quick-actions2 .quick-action small {
    width: auto;
    text-align: left;
  }
}

@media (max-width: 768px) {
  .whatsapp-page .whatsapp-workspace {
    grid-template-columns: 1fr;
  }
}

.settings-page .input-with-suffix {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 12px;
  border: 1px solid #dfe7f4;
  border-radius: 12px;
  background: #fff;
}

.settings-page .input-with-suffix input {
  min-width: 0;
  min-height: 48px;
  padding: 10px 0;
  border: 0;
  box-shadow: none;
}

.settings-page .input-prefix,
.settings-page .input-suffix {
  color: #64748b;
  font-size: .9rem;
  font-weight: 700;
}

.settings-page .settings-header {
  position: relative;
  min-height: 156px;
  padding: 30px 34px;
  overflow: hidden;
}

.settings-page .settings-header__content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.settings-page .settings-header__center {
  align-self: flex-start;
  margin-top: 2px;
}

.settings-page .settings-header__status {
  flex: 0 0 auto;
  margin-top: 4px;
}

.settings-page .settings-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: -4px 0 0;
}

.settings-page .settings-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #d8e8dc;
  border-radius: 999px;
  background: #fff;
  color: #166534;
  font-size: .84rem;
  font-weight: 700;
  text-decoration: none;
  transition: border-color .2s ease, background .2s ease, color .2s ease;
}

.settings-page .settings-nav a:hover,
.settings-page .settings-nav a:focus-visible {
  border-color: #86efac;
  background: #f0fdf4;
  color: #15803d;
  outline: none;
}

@media (max-width: 600px) {
  .settings-page .settings-header {
    min-height: 0;
    padding: 22px 18px;
  }

  .settings-page .settings-header__status {
    align-self: flex-start;
  }

  .settings-page .settings-nav a {
    flex: 1 1 auto;
    justify-content: center;
  }

  .settings-page .quality-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .settings-page .quality-grid__columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .settings-page .quality-grid input {
    min-width: 0;
    width: 100%;
  }
}

.settings-page .settings-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
  padding: 18px 20px;
  border: 1px solid #d9eee0;
  border-radius: 16px;
  background: linear-gradient(135deg, #f7fcf8 0%, #ecfdf5 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
}

.settings-page .settings-preview__title {
  color: #166534;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.settings-page .settings-preview__row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #365044;
  font-size: .88rem;
  line-height: 1.4;
}

.settings-page .quality-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 800;
}

.settings-page .quality-badge--excellent {
  background: #dcfce7;
  color: #166534;
}

.settings-page .quality-badge--good {
  background: #fef3c7;
  color: #92400e;
}

.settings-page .settings-preview--report {
  background: linear-gradient(135deg, #f8fbff 0%, #eef6ff 100%);
  border-color: #dbeafe;
}

.settings-page .settings-preview--report .settings-preview__title {
  color: #1d4ed8;
}

.settings-page .report-preview__title {
  color: #0f172a;
  font-size: 1.05rem;
  font-weight: 800;
}

.settings-page .report-preview__address,
.settings-page .report-preview__phone {
  color: #475569;
  font-size: .88rem;
}

@media (max-width: 768px) {
  .whatsapp-page .whatsapp-header {
    min-height: 0;
    padding: 22px 18px;
  }

  .whatsapp-page .broadcast-panel textarea {
    min-height: 150px;
  }

  .whatsapp-page .whatsapp-sidebar {
    gap: 12px;
  }
}

.settings-page .settings-info-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 20px;
  padding: 16px 18px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: linear-gradient(135deg, #f8fbff 0%, #eff6ff 100%);
  color: #475569;
}

.settings-page .settings-info-panel__title {
  color: #1e3a8a;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.settings-page .settings-info-panel p {
  margin: 0;
  color: #475569;
  font-size: .88rem;
  line-height: 1.5;
}

