/* Shared mobile layout. Desktop tables and daily schedules retain their layout. */
.mobile-employee-picker {display:none}
.layout > *, .panel, .tablewrap, .table-wrap, .table-container, .table-scroll, .expectations-table-scroll {min-width:0}
.tablewrap, .table-wrap, .table-container, .table-scroll, .expectations-table-scroll {max-width:100%;-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain}
@media (max-width:650px) {
  html {scroll-padding-top:12px}
  body {max-width:100%;overflow-wrap:break-word}
  main, .wrap, .container {min-width:0;max-width:100%}
  main {padding-inline:10px}
  .panel {padding:13px;max-width:100%}
  header, .top, .hero, .list-head {gap:12px;flex-wrap:wrap}
  .hero, .layout, .grid, .two, .editgrid, .filters, .uploads, .toolbar {grid-template-columns:minmax(0,1fr)}
  .controls {align-items:stretch}
  .controls .field, .filters .field, .controls .filter-details, .jobmenu {min-width:0;flex:1 1 100%;max-width:100%}
  input:not([type=checkbox]):not([type=radio]), select, textarea {font-size:16px!important;min-width:0;max-width:100%;box-sizing:border-box}
  input[type=datetime-local], input[type=date], input[type=month], input[type=time] {width:100%}
  button, .btn, summary {min-height:44px;touch-action:manipulation}
  .actions, .toolbar, .modal-actions, .row-actions {flex-wrap:wrap;gap:8px}
  .actions button, .toolbar button, .modal-actions button {flex:1 1 auto}
  .filter-menu {max-width:calc(100vw - 48px);min-width:0;width:100%;position:relative;top:auto;margin-top:6px}
  .filter-menu label {white-space:normal}
  .summary, .group-summary, .payroll-totals {grid-template-columns:repeat(2,minmax(0,1fr))}
  .metric, .metric strong, .overtime-panel strong {min-width:0;overflow-wrap:anywhere}
  .overtime-panel {padding:12px;align-items:stretch}
  .overtime-panel .toolbar {width:100%}
  .roster {max-height:210px}
  .mobile-employee-picker {display:grid}
  .mobile-roster {display:none}
  dialog {width:calc(100% - 20px);max-width:calc(100% - 20px);max-height:90vh;max-height:90dvh;overflow-y:auto;padding:16px;margin:auto}
  dialog form, dialog .field {min-width:0}
  .modal-actions {position:sticky;bottom:0;background:var(--panel);padding-block:10px;margin-bottom:0}
  .profile-grid {grid-template-columns:1fr}
  .images {max-width:100%;flex-wrap:wrap}
  .images img {max-width:100%}
  h1 {font-size:25px;line-height:1.45}
  h2 {font-size:19px}
  /* Each day/employee becomes a labeled card; actions stay in the portrait viewport. */
  .tablewrap:has(> .mobile-cards) {border:0;overflow:visible}
  table.mobile-cards {display:block;min-width:0!important;width:100%;background:transparent}
  .mobile-cards thead {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
  .mobile-cards tbody {display:grid;gap:12px;width:100%}
  .mobile-cards tr {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border:1px solid var(--line,var(--border));border-radius:12px;background:var(--panel2,var(--panel));padding:6px;animation:none!important}
  .mobile-cards td {display:flex;flex-direction:column;gap:4px;min-width:0;padding:9px;white-space:normal;border:0!important;text-align:start;overflow-wrap:anywhere;font-size:14px}
  .mobile-cards td::before {content:attr(data-label);color:var(--muted);font-size:12px;font-weight:400;direction:rtl;text-align:start}
  .mobile-cards td:first-child {grid-column:1/-1;font-weight:700;font-size:16px}
  .mobile-cards td:last-child {grid-column:1/-1;display:flex;flex-direction:row;flex-wrap:wrap;align-items:center}
  .mobile-cards td:last-child::before {flex-basis:100%}
  .mobile-cards td:last-child button {flex:1;padding:10px 12px;font-size:15px}
  .mobile-cards td[data-label="ملاحظات"], .mobile-cards td[data-label="الحالة"] {grid-column:1/-1}
  .mobile-cards tr.missing {border-color:var(--danger)}
  .mobile-cards tr.review {border-color:#c99b57}
}
@media (prefers-reduced-motion:no-preference) and (max-width:650px) {
  main, .wrap {animation:none!important}
}

/* Keep the identity and action cells visible while reviewing wide desktop tables. */
@media (min-width:651px) {
  .action-table th:first-child,.action-table td:first-child{position:sticky;right:0;z-index:2;min-width:145px;background:var(--panel2)}
  .action-table th:last-child,.action-table td:last-child{position:sticky;left:0;z-index:2;min-width:125px;background:var(--panel2);box-shadow:2px 0 9px #0004}
  .action-table thead th:first-child,.action-table thead th:last-child{z-index:4}
  .table-top-scroll{height:18px;overflow-x:auto;overflow-y:hidden;max-width:100%;direction:rtl;scrollbar-gutter:stable;margin:0 0 5px}
  .table-top-scroll>div{height:1px}
}
@media (max-width:650px){.table-top-scroll{display:none}.action-table th:first-child,.action-table td:first-child,.action-table th:last-child,.action-table td:last-child{position:static;min-width:0;box-shadow:none}}
