.mobile-nav-icon{display:none}
.mobile-nav-label{display:inline}

@media (max-width: 900px){
  html{-webkit-text-size-adjust:100%}
  body{overflow-x:hidden}
  button,.primary,.secondary,.danger,.ghost,input,textarea,select{min-height:44px}
  input,textarea,select{font-size:16px}

  .topbar{
    height:60px;
    padding:0 12px;
    gap:10px;
  }
  .brandline{gap:7px;min-width:0}
  .brandline .wordmark{font-size:22px;white-space:nowrap}
  .brandline small{display:none}
  .topbar .secondary{padding:9px 12px;white-space:nowrap}

  .layout{display:block;min-height:calc(100vh - 60px)}
  .main{
    padding:16px 14px calc(132px + env(safe-area-inset-bottom));
    max-width:none;
  }

  /* Mobile navigation is a solid native-style dock, not a floating overlay.
     The opaque surface prevents page cards/text from showing through or
     visually colliding with the navigation while scrolling. */
  .sidebar{
    position:fixed;
    left:0;right:0;bottom:0;top:auto;
    height:auto;
    min-height:78px;
    padding:8px 10px calc(10px + env(safe-area-inset-bottom));
    display:grid;
    grid-template-columns:repeat(5,minmax(0,1fr));
    gap:4px;
    background:#fff;
    border:0;
    border-top:1px solid rgba(23,63,52,.12);
    border-radius:0;
    box-shadow:0 -10px 30px rgba(20,35,30,.10);
    backdrop-filter:none;
    -webkit-backdrop-filter:none;
    z-index:60;
  }
  .navbtn{
    min-width:0;
    min-height:58px;
    margin:0;
    padding:6px 2px 5px;
    text-align:center;
    font-size:10px;
    line-height:1.05;
    border-radius:14px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:4px;
    color:#67706b;
    transition:background .16s ease,color .16s ease,transform .16s ease;
  }
  .mobile-nav-icon{display:grid;place-items:center;width:22px;height:22px;color:currentColor}
  .mobile-nav-icon svg{display:block;width:21px;height:21px}
  .mobile-nav-label{display:block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:700}
  .navbtn.active{
    box-shadow:none;
    background:#eaf3ef;
    color:var(--green);
  }
  .navbtn.active .mobile-nav-icon{transform:translateY(-1px)}
  .navbtn:active{transform:scale(.97)}

  .page-head{
    margin-bottom:16px;
    gap:12px;
    align-items:stretch;
  }
  .page-head h1{font-size:27px;line-height:1.15}
  .page-head p{font-size:15px;line-height:1.45}
  .page-head .actions,.page-head>.primary,.page-head>.secondary{width:100%}
  .page-head .actions>*{flex:1 1 100%}

  .kpis{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:14px 0}
  .kpi{padding:15px;border-radius:14px}
  .kpi span{font-size:11px}
  .kpi strong{font-size:22px}

  .panel{padding:16px;border-radius:14px}
  .quick-grid,.report-grid,.settings-grid{grid-template-columns:1fr;gap:10px}
  .quick,.report{padding:16px}

  .tabs{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    width:100%;
    padding:4px;
    gap:4px;
    margin-bottom:14px;
  }
  .tab{width:100%;padding:10px 8px;text-align:center}

  .record{padding:15px;border-radius:14px}
  .record-top{flex-direction:column;gap:8px}
  .record h3{font-size:17px;line-height:1.25}
  .record .meta{font-size:13px;line-height:1.45}
  .record .money{text-align:left;font-size:22px}
  .record-actions{display:grid;grid-template-columns:1fr;gap:8px;margin-top:13px}
  .record-actions button{width:100%;min-height:46px}
  .badge{margin-left:4px}

  .modal-backdrop{
    align-items:end;
    padding:0;
  }
  .modal{
    width:100%;
    max-width:none;
    max-height:94dvh;
    border-radius:20px 20px 0 0;
    padding:18px 14px calc(18px + env(safe-area-inset-bottom));
    box-shadow:0 -20px 60px rgba(0,0,0,.22);
  }
  .modal-head{
    position:sticky;
    top:-18px;
    z-index:5;
    margin:-18px -14px 14px;
    padding:16px 14px 12px;
    background:#fff;
    border-radius:20px 20px 0 0;
    border-bottom:1px solid #eee9df;
  }
  .modal-head h2{font-size:22px;line-height:1.2}
  .iconbtn{width:44px;height:44px;flex:0 0 44px}
  .form-grid,.row3,.row2{grid-template-columns:1fr;gap:0}
  .field.wide{grid-column:auto}
  .field{margin-bottom:12px}
  .item-box{padding:12px;margin:10px 0}
  .item-head{gap:8px}
  .form-actions{
    position:sticky;
    bottom:calc(-18px - env(safe-area-inset-bottom));
    z-index:4;
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
    margin:18px -14px calc(-18px - env(safe-area-inset-bottom));
    padding:12px 14px calc(12px + env(safe-area-inset-bottom));
    background:rgba(255,255,255,.98);
    border-top:1px solid #eee9df;
  }
  .form-actions button{width:100%;min-height:48px}

  .table-wrap{
    margin:0 -2px;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    border-radius:10px;
  }
  .table{min-width:660px}
  .table th,.table td{padding:10px 8px}

  .toast{
    bottom:calc(100px + env(safe-area-inset-bottom));
    width:calc(100% - 28px);
    max-width:520px;
    text-align:center;
    border-radius:12px;
  }

  .login-wrap{padding:18px 14px}
  .login-card{padding:24px 18px;border-radius:18px}
  .login-card .wordmark{font-size:31px}
}

@media (max-width: 560px){
  .main{padding-left:12px;padding-right:12px;padding-bottom:calc(136px + env(safe-area-inset-bottom))}
  .kpis{grid-template-columns:1fr}
  .kpi{padding:16px}
  .page-head h1{font-size:25px}
  .panel h2{font-size:18px}
  .tabs{border-radius:11px}
  .tab{font-size:14px}
  .record{padding:14px}
  .form-actions{grid-template-columns:1fr}
  .staging-banner{padding-left:8px;padding-right:8px}
}

@media (max-width: 390px){
  .brandline .wordmark{font-size:20px}
  .topbar .secondary{font-size:13px;padding:8px 10px}
  .navbtn{font-size:9px}
  .main{padding-left:10px;padding-right:10px}
}
