.mobile-nav,.mobile-install{display:none}
.global-back-button{margin:0 0 16px;display:inline-flex;align-items:center;gap:6px;min-height:44px}
.contact-action-link{color:#a84508;text-decoration:underline;text-underline-offset:3px;font-weight:600}
@media print{.global-back-button{display:none!important}}

@media(max-width:650px){
  html,body{max-width:100%;overflow-x:hidden;-webkit-text-size-adjust:100%}
  body{padding-bottom:82px;font-size:16px}
  .app-shell{display:block;min-width:0;width:100%}
  .sidebar{position:sticky;top:0;z-index:20;width:100%;min-width:0;padding:8px 14px;background:rgba(255,255,255,.97);border-right:0;border-bottom:1px solid #e9e9e7}
  .sidebar nav,.user-panel{display:none!important}
  .sidebar .user-panel{display:flex!important;position:absolute;top:8px;right:10px;margin:0;padding:0;border:0}
  .sidebar .user-panel>div{display:none}
  .sidebar .user-panel form{margin:0}
  .sidebar .user-panel .text-button{min-height:44px;padding:8px 10px;border:1px solid #e5e7eb;border-radius:9px;background:#fff;color:#b42318;font-size:13px;font-weight:700}
  .brand{padding:0!important;min-width:0}
  .sol-home-brand img{width:142px!important;height:42px!important}
  .sol-home-brand .system-name{font-size:11px!important;white-space:nowrap}
  .main{width:100%;min-width:0;max-width:100%;padding:18px 14px 104px}
  .main>*{max-width:100%;min-width:0}
  .page-header{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;margin-bottom:20px;align-items:start}
  .page-header h1{font-size:22px;line-height:1.4;overflow-wrap:anywhere}
  .page-header p{line-height:1.7}
  .header-actions,.form-actions,.search-bar{display:grid!important;grid-template-columns:1fr;gap:10px;width:100%}
  .header-actions>* ,.form-actions>* ,.search-bar>*{width:100%;max-width:100%;text-align:center}
  .panel,.card,.edit-panel,.quote-summary,.economics-summary{width:100%;min-width:0;padding:17px;border-radius:13px}
  .metric-grid,.content-grid,.detail-grid,.admin-grid,.form-grid,.wizard,.economics-grid,.compare-grid{grid-template-columns:minmax(0,1fr)!important}
  .metric-grid{gap:11px}
  .card strong{font-size:25px}
  .primary-button,.secondary-button,.button-link,button,input[type="submit"]{min-height:48px;font-size:16px!important;padding:12px 15px!important;touch-action:manipulation}
  a.primary-button,a.secondary-button,a.button-link{display:flex;align-items:center;justify-content:center;text-decoration:none}
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),select,textarea{width:100%!important;max-width:100%;min-width:0;min-height:50px!important;font-size:16px!important;padding:12px 13px!important}
  input[type="checkbox"],input[type="radio"]{width:24px;height:24px;accent-color:#f47b20}
  textarea{min-height:104px!important;resize:vertical}
  label{line-height:1.55}
  .staff-form,.form-grid,.form-stack{gap:14px!important}
  .project-card,.version-row,.admin-row,.task,.summary-row{min-width:0;gap:12px}
  .project-card,.version-row,.admin-row{display:grid!important;grid-template-columns:minmax(0,1fr)}
  .project-card>* ,.version-row>* ,.admin-row>*{min-width:0;max-width:100%}
  .global-back-button{position:sticky;top:58px;z-index:35;margin-bottom:12px;background:rgba(255,255,255,.97);box-shadow:0 4px 16px rgba(0,0,0,.12)}
  .mobile-nav{display:flex;position:fixed;z-index:50;bottom:0;left:0;right:0;max-width:100vw;overflow-x:auto;overflow-y:hidden;scroll-snap-type:x proximity;-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain;background:#fff;border-top:1px solid #e1e3e5;padding:6px 4px calc(6px + env(safe-area-inset-bottom));scrollbar-width:none}
  .mobile-nav::-webkit-scrollbar{display:none}
  .mobile-nav a{display:grid;flex:0 0 88px;min-height:58px;place-content:center;scroll-snap-align:center;gap:3px;text-align:center;text-decoration:none;color:#596168;font-size:12px;padding:5px 3px;touch-action:pan-x;border-radius:10px}
  .mobile-nav .mobile-logout{display:flex;flex:0 0 94px;scroll-snap-align:center;margin:0}
  .mobile-nav .mobile-logout button{display:grid;width:100%;min-height:58px;place-content:center;gap:3px;padding:5px 3px;border:0;border-radius:10px;background:#fff;color:#b42318;font:inherit;font-size:12px;cursor:pointer}
  .mobile-nav .mobile-logout b{font-size:19px;line-height:1}
  .mobile-nav a.active{color:#b85110;background:#fff3e8;font-weight:700}
  .mobile-nav b{font-size:19px;line-height:1}
  .mobile-install{display:block;position:fixed;right:14px;bottom:86px;z-index:40;border:0;border-radius:999px;background:#f47b20;color:#fff;padding:11px 15px;box-shadow:0 8px 24px #0002}
  .mobile-clock{display:grid;grid-template-columns:1fr 1fr;gap:10px}
  .mobile-clock button{width:100%}
  .table-wrap{overflow:visible!important}
  table.mobile-card-table,table.mobile-card-table tbody,table.mobile-card-table tr,table.mobile-card-table td{display:block;width:100%}
  table.mobile-card-table thead{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
  table.mobile-card-table tbody{display:grid;gap:12px}
  table.mobile-card-table tr{padding:10px 14px;background:#fff;border:1px solid #e3e5e7;border-radius:12px}
  table.mobile-card-table td{display:grid;grid-template-columns:minmax(88px,38%) minmax(0,62%);gap:10px;align-items:center;padding:10px 0!important;border:0!important;border-bottom:1px solid #eee!important;overflow-wrap:anywhere;text-align:left!important}
  table.mobile-card-table td:last-child{border-bottom:0!important}
  table.mobile-card-table td::before{content:attr(data-label);font-weight:700;color:#68747b;font-size:13px}
  table.mobile-card-table td[colspan]::before{display:none}
  table.mobile-card-table td[colspan]{display:block;text-align:center!important}
  .line-item{grid-template-columns:minmax(0,1fr)!important}
  .ai-page-advice{margin-bottom:16px}
}

@media(max-width:390px){
  .main{padding-left:12px;padding-right:12px}
  .panel,.card,.edit-panel,.quote-summary,.economics-summary{padding:15px}
  .mobile-nav a{flex-basis:84px}
  table.mobile-card-table td{grid-template-columns:minmax(76px,36%) minmax(0,64%)}
}
#install-app{display:none!important}

/* Smartphone: the bottom category navigation is the only horizontal scroller. */
@media(max-width:650px){
  body *{min-width:0}
  main.main{overflow-x:clip}
  main.main img,main.main video,main.main iframe,main.main canvas,main.main svg{max-width:100%;height:auto}
  main.main pre,main.main code,main.main p,main.main small,main.main strong,main.main td,main.main th,main.main dd,main.main a{overflow-wrap:anywhere;word-break:break-word}
  main.main pre{white-space:pre-wrap}
  .table-panel,.table-wrap,.chart-scroll,.nav-tabs,.steps{width:100%;max-width:100%;overflow:visible!important}
  .table-panel{border:0;background:transparent}
  table.mobile-card-table{min-width:0!important;table-layout:fixed}
  table.mobile-card-table tbody{width:100%}
  table.mobile-card-table tr{max-width:100%;overflow:hidden}
  table.mobile-card-table td>*{max-width:100%}
  table.mobile-card-table input:not([type="checkbox"]),table.mobile-card-table select,table.mobile-card-table textarea,table.mobile-card-table button,table.mobile-card-table a.secondary-button{width:100%!important;max-width:100%}
  .steps{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:7px}
  .steps>*{width:100%;text-align:center;white-space:normal!important}
  .chart-bars{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px 7px!important;min-width:0!important;width:100%!important;height:auto!important;align-items:end}
  .chart-month{width:100%;min-width:0!important;position:relative}
  .bar-area{height:145px!important}
  .stack{width:min(24px,45%)}
  .chart-detail{position:fixed!important;z-index:80;left:12px!important;right:12px!important;bottom:82px!important;width:auto!important;max-width:calc(100vw - 24px)!important;white-space:normal!important;max-height:55vh;overflow-y:auto}
  .panel dl{grid-template-columns:1fr!important;gap:5px!important}
  .panel dd{margin:0 0 12px}
  .header-actions,.form-actions,.project-actions,.report-actions,.tax-accountant-box form,.commission-form{flex-direction:column!important;align-items:stretch!important;width:100%}
  .header-actions>* ,.form-actions>* ,.project-actions>* ,.report-actions>*{width:100%!important;max-width:100%}
  .billing-steps,.commission-result,.fiscal-breakdown,.report-metrics,.date-grid,.day-attendance-form,.task-create-form,.user-account-list{grid-template-columns:minmax(0,1fr)!important}
  .category-scroll,.category-tabs,[data-mobile-category-scroll],.mobile-nav{overflow-x:auto!important;overflow-y:hidden!important}
}

@media(max-width:390px){
  .chart-bars{grid-template-columns:repeat(2,minmax(0,1fr))}
}
