@media(max-width:760px){
  body{max-width:100%;overflow-wrap:anywhere}
  main,header,section,form,article,.card{min-width:0;max-width:100%;box-sizing:border-box}
  header nav,nav,.actions,.toolbar{display:flex;flex-wrap:wrap;gap:.45rem}
  main{padding-inline:clamp(.5rem,3vw,1rem)}
  .grid,.split,.columns{grid-template-columns:minmax(0,1fr)!important}
  #quickCounts,#counts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.5rem}
  input:not([type=checkbox]):not([type=radio]),select,textarea{max-width:100%;min-width:0;font-size:16px;box-sizing:border-box}
  button,nav a{min-height:44px;box-sizing:border-box}
  nav a{display:inline-flex;align-items:center}
  nav [hidden]{display:none!important}
  dialog{box-sizing:border-box;width:calc(100% - 1rem);max-width:calc(100% - 1rem);max-height:92vh;max-height:92dvh;overflow:auto}
  .table,.table-wrap,table{max-width:100%;overflow-x:auto}
  table{display:block}
}
/* The existing desktop attachment selector remains available alongside camera capture. */
#cameraUpload{display:none}
@media(pointer:coarse){#cameraUpload{display:block}}

@supports (-webkit-touch-callout:none){
  @media(max-width:760px){
    body{-webkit-text-size-adjust:100%}
    main{padding-inline:max(.75rem,env(safe-area-inset-left)) max(.75rem,env(safe-area-inset-right));padding-bottom:max(1rem,env(safe-area-inset-bottom))}
    input:not([type=checkbox]):not([type=radio]),select,textarea{font-size:16px;min-height:44px}
    summary,nav a,button{min-height:44px}
    summary{align-content:center}
    dialog{overscroll-behavior:contain}
  }
}

/* iPhone workspace. Desktop retains the original navigation, tables and actions. */
.iphone-only{display:none}
@media (max-width:600px) and (pointer:coarse){
 .iphone-desk{--navy:#193454;--teal:#006c62;--ink:#182f44;--muted:#486177;--line:#d6e2eb;color:var(--ink);background:#f4f7fa;font-family:-apple-system,BlinkMacSystemFont,"PingFang SC",sans-serif;font-size:16px}
 .iphone-desk .iphone-only{display:revert}
 .iphone-desk header{position:sticky;top:0;z-index:5;background:var(--navy);padding:calc(10px + env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) 11px max(16px,env(safe-area-inset-left))}
 .iphone-desk header>nav,.iphone-desk #quick h2,.iphone-desk #quickClients,.iphone-desk #excel,.iphone-desk #rules{display:none!important}
 .iphone-desk header h1{font-size:13px;font-weight:500;color:#d8e6f3;margin:3px 0 0 37px;line-height:1.35}
 .iphone-desk .phone-brand{display:flex;align-items:center;gap:9px;font-weight:700;font-size:16px;line-height:1}
 .iphone-desk .phone-brand img{width:28px;height:28px;border-radius:8px}
 .iphone-desk main{width:100%;margin:12px auto 0;padding:0 max(14px,env(safe-area-inset-right)) calc(78px + env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left))}
 .iphone-desk main>[data-iphone-active="false"]{display:none}
 .iphone-desk #message:empty,.iphone-desk #worklogMessage:empty,.iphone-desk #detailMessage:empty{display:none}
 .iphone-desk main section,.iphone-desk main details,.iphone-desk #detail{border-radius:16px;border:1px solid var(--line);padding:14px;margin:0 0 12px}
 .iphone-desk h2{font-size:20px;line-height:1.3}
 .iphone-desk h3{font-size:16px;margin:12px 0 8px}
 .iphone-desk p{margin:8px 0}
 .iphone-desk button,.iphone-desk input,.iphone-desk select,.iphone-desk summary{min-height:44px}
 .iphone-desk input:not([type=checkbox]),.iphone-desk select,.iphone-desk textarea{display:block;width:100%;min-width:0;padding:9px 10px;color:var(--ink);background:#fff;border:1px solid #b3c8d9;font-size:16px;margin-top:3px}
 .iphone-desk input[type=checkbox]{min-height:0;width:20px;height:20px;vertical-align:middle}
 .iphone-desk input[type=date]{-webkit-appearance:none;appearance:none}
 .iphone-desk main label,.iphone-desk #detail label{font-size:14px;color:var(--muted);margin:0 0 7px}
 .iphone-desk form .grid,.iphone-desk #clients>.grid{display:grid;grid-template-columns:minmax(0,1fr)!important;align-items:start;gap:5px}
 .iphone-desk #filters{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:5px 10px}
 .iphone-desk #filters button,.iphone-desk #newClient button,.iphone-desk #eventForm>button,.iphone-desk #worklogForm button{width:100%}
 .iphone-desk button{border-radius:10px;background:var(--teal);border-color:var(--teal)}
 .iphone-desk button.light{color:var(--navy);background:#eff5fa;border-color:#d2e1ec}
 .iphone-desk button:disabled{opacity:.48}
 .iphone-desk #quickCounts{display:none}
 .iphone-desk #phoneMetrics{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 .iphone-desk .phone-metric{background:#ebf4f4;border-radius:12px;padding:10px}
 .iphone-desk .phone-metric:first-child{grid-column:1/-1;background:#dff0ed}
 .iphone-desk .phone-metric small{display:block;color:var(--muted)}
 .iphone-desk .phone-metric strong{display:block;font-size:26px;line-height:1.25;color:var(--navy);font-variant-numeric:tabular-nums}
 .iphone-desk .phone-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:9px 0 2px}
 .iphone-desk .phone-actions button{font-size:14px;font-weight:650;min-height:46px;text-align:left;padding:8px}
 .iphone-desk .phone-team{list-style:none;padding:0;margin:0;color:var(--muted);font-size:14px}
 .iphone-desk .phone-team li{margin:0;padding:7px 0;border-bottom:1px solid var(--line)}
 .iphone-desk #clients table,.iphone-desk #clients tbody{display:block;width:100%}
 .iphone-desk #clients thead{display:none}
 .iphone-desk #clientRows tr{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:3px 8px;border:1px solid var(--line);border-radius:12px;padding:10px;margin:0 0 8px;background:#f9fbfd}
 .iphone-desk #clientRows td{padding:0;border:0;font-size:14px;min-width:0}
 .iphone-desk #clientRows td:first-child{grid-column:1/-1;font-size:16px;font-weight:700;color:var(--navy)}
 .iphone-desk #clientRows td:nth-child(2),.iphone-desk #clientRows td:nth-child(3),.iphone-desk #clientRows td:nth-child(5){color:var(--muted)}
 .iphone-desk #clientRows td:nth-child(3){text-align:right}
 .iphone-desk #clientRows td:nth-child(6){grid-column:1/-1}
 .iphone-desk #clientRows button{width:100%;margin-top:4px}
 .iphone-desk #phoneProfile a,.iphone-desk #phoneProfile button{display:flex;align-items:center;min-height:44px;margin:7px 0}
 .iphone-desk #phoneProfile a{color:var(--teal);text-decoration:none;font-weight:650}
 .iphone-desk .phone-future{font-size:14px;color:var(--muted)}
 .iphone-desk .phone-tabbar{position:fixed;z-index:15;bottom:0;left:0;right:0;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:3px;background:#fff;padding:5px max(8px,env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));border-top:1px solid var(--line)}
 .iphone-desk .phone-tabbar button{background:transparent;color:var(--muted);border:0;display:grid;place-items:center;gap:2px;font-size:12px;font-weight:650;line-height:1.2;padding:4px}
 .iphone-desk .phone-tabbar button[aria-current="page"]{background:#e3f2ee;color:var(--teal)}
 .iphone-desk .phone-tabbar svg{width:21px;height:21px;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
 .iphone-desk #detail{width:calc(100% - 16px);max-width:calc(100% - 16px);max-height:calc(100dvh - 20px);margin:auto;overscroll-behavior:contain}
 .iphone-desk #detail .phone-detail-close{float:right;margin-left:6px;padding:7px 10px}
 .iphone-desk #detail .links{display:grid;grid-template-columns:minmax(0,1fr)!important}
 .iphone-desk #cameraUpload{display:block}
 .iphone-desk #detail [type=file]{padding:5px;font-size:14px}
 .iphone-desk details>summary{padding:10px 0;font-weight:650}
}


@media (max-width:600px) and (pointer:coarse){
 .iphone-desk #detail[data-iphone-options="false"] .iphone-extra{display:none!important}
 .iphone-desk #phoneDetailOptions{margin-bottom:8px}
 .iphone-desk #profile{font-size:14px;color:var(--muted);line-height:1.5}
}

@media (max-width:600px) and (pointer:coarse){
 .iphone-desk .desktop-client-id{display:none}
 .iphone-desk #filters .phone-date{grid-column:1/-1;min-width:0}
 .iphone-desk #filters .phone-date input{width:100%;height:46px;min-width:0;-webkit-text-fill-color:currentColor}
 .iphone-desk #filters .phone-date input::-webkit-date-and-time-value{text-align:left}
}
