/* ==========================================================================
   devices.css : loaded LAST. One responsive layer for every screen.
   Phones (Android / iPhone, incl. small and flip/fold cover screens), tablets
   and iPad (portrait + landscape), laptops, desktop monitors, ultrawide, TV.
   Same theme, same icons, same components: only spacing, columns and sizes
   adapt. Nothing here changes colour or style.
   Breakpoints: 300 / 380 / 560 / 700 / 900 / 1100 / 1600 / 1920 / 2560
   ========================================================================== */

/* ---- 0. Foundations ------------------------------------------------------ */
:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; }
body { min-height: 100vh; min-height: 100dvh; overflow-wrap: break-word; -webkit-font-smoothing: antialiased; }
img, svg, video, canvas { max-width: 100%; }
img { height: auto; }
table { max-width: 100%; }
button, a, summary, label, select { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--green-600, #12904A); outline-offset: 3px; border-radius: 6px; }
.side :focus-visible, .c-top :focus-visible, .c-foot :focus-visible, .action-bar :focus-visible { outline-color: var(--yellow, #FAE100); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 0; }

/* ---- 1. Notches, rounded corners, home bars (iPhone, Android, flip/fold) -- */
.c-top .in, .c-hero .in, .c-foot .in, main.wrap, .wrap {
  padding-left: max(var(--gutter), var(--safe-l));
  padding-right: max(var(--gutter), var(--safe-r));
}
.c-top { padding-top: var(--safe-t); }
.c-foot { padding-bottom: var(--safe-b); }
body.pg-login-index main.wrap, body.pg-login-register main.wrap {
  padding-left: max(24px, var(--safe-l)); padding-right: max(24px, var(--safe-r)); padding-bottom: max(56px, calc(24px + var(--safe-b)));
}
.s-app .s-main {
  padding-left: max(clamp(16px, 3vw, 40px), var(--safe-l));
  padding-right: max(clamp(16px, 3vw, 40px), var(--safe-r));
  padding-bottom: calc(60px + var(--safe-b));
}
.s-app .action-bar { bottom: calc(16px + var(--safe-b)); }
.toasts { bottom: calc(var(--s-5, 24px) + var(--safe-b)); }
.s-app .side { padding-top: calc(22px + var(--safe-t)); padding-left: max(16px, var(--safe-l)); }

/* ---- 2. Dialogs and the product modal never exceed the screen -------------- */
dialog { max-width: calc(100vw - 24px); }
dialog.dlg, dialog.cmdk { max-height: calc(100dvh - 24px); }
.modal2 { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }

/* ---- 3. Touch devices: 44px targets, no iOS zoom-on-focus, no sticky hover - */
@media (pointer: coarse) {
  .btn, .c-nav a, .c-nav .navbtn, .s-app .side nav a, .tabs a, .icon-btn, .kebab-item, .signout, .pw-toggle { min-height: 44px; }
  .icon-btn, .signout, .pw-toggle { min-width: 44px; }
  .s-app .icon-btn { width: 44px; height: 44px; }
  .s-app .toggle { position: relative; }
  .s-app .toggle::before { content: ""; position: absolute; inset: -8px -6px; }
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px !important; }
  .s-app .cmdk-btn kbd { display: none; }
  .row-actions { opacity: 1 !important; }
}
@media (hover: none) {
  .btn:hover, .s-app .btn:hover, .c-cats .c-cat:hover, .prod:hover, .size-card:hover, .oc:hover { transform: none; }
  .c-cats .c-cat:hover img { transform: none !important; }
}

/* ---- 4. Phones, small: 380 and below, and fold/flip cover screens ---------- */
@media (max-width: 380px) {
  :root { --gutter: 14px; }
  .btn { padding: 0 var(--s-4); font-size: 14px; }
  .c-top .in { gap: 8px; }
  .c-nav a, .c-nav .navbtn { padding: 0 10px; font-size: 13px; }
  .c-cats .c-cat .t { font-size: 22px; }
  .auth-shell .auth-form, body.pg-login-index .auth-form, body.pg-login-register .auth-form { padding: 22px 16px; }
  .track { font-size: 11px; }
}
@media (max-width: 300px) {
  .grid { grid-template-columns: 1fr; }
  .c-nav a, .c-nav .navbtn { padding: 0 8px; }
  .c-cats .c-cat:nth-child(n) { height: 150px; min-height: 150px; padding: 16px; }
  .s-app .s-main { padding-left: max(12px, var(--safe-l)); padding-right: max(12px, var(--safe-r)); }
}

/* ---- 5. Phones: up to 560 ------------------------------------------------- */
@media (max-width: 560px) {
  .c-top .in { height: 64px; }
  .c-top .logo { height: 44px; }
  .c-nav { min-width: 0; overflow-x: auto; scrollbar-width: none; justify-content: flex-end; }
  .c-nav::-webkit-scrollbar { display: none; }
  .c-nav a, .c-nav .navbtn { flex: none; }
  .c-hero h1 { font-size: clamp(34px, 11vw, 52px); }
  .c-hero .cta .btn { flex: 1 1 auto; }
  .grid2, .grid2.names, .row2, .grid3, .pay-grid, .panels, .panels.even { grid-template-columns: 1fr; }
  .report-range .field, .filters .field { flex: 1 1 100%; min-width: 0; }
  input[type=date], input[type=time] { min-width: 0; width: 100%; }
  .searchbox { min-width: 0; width: 100%; max-width: none !important; }
  .s-app .s-top .btn { flex: 1 1 auto; }
  .s-app .action-bar { padding: 10px 12px; gap: 8px; border-radius: 16px; }
  .s-app .action-bar .btn { flex: 1 1 auto; }
  .s-app .action-bar .edited { flex-basis: 100%; }
  .s-app .section-card { padding: 20px 18px; }
  .s-app th, .s-app td { padding-left: 14px; padding-right: 14px; }
  .glance { gap: 16px 22px; }
  dialog.dlg { width: calc(100vw - 24px); }
}

/* ---- 6. Staff shell: phone + small tablet = compact top bar (up to 900) ---- */
@media (max-width: 900px) {
  .s-app { grid-template-columns: minmax(0, 1fr); }
  .s-app .side {
    position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; gap: 8px;
    padding: calc(8px + var(--safe-t)) max(10px, var(--safe-r)) 8px max(10px, var(--safe-l));
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .s-app .side::-webkit-scrollbar { display: none; }
  .s-app .side::after { display: none; }
  .s-app .side .logo-link { margin: 0 6px 0 0; flex: none; }
  .s-app .side .logo { height: 34px; width: auto; }
  .s-app .side nav { flex-direction: row; gap: 4px; flex: none; }
  .s-app .side nav a { flex: none; white-space: nowrap; padding: 10px 14px; }
  .s-app .side nav .div, .s-app .side nav .small, .s-app .side .who .wt { display: none; }
  .s-app .side .who { margin: 0 0 0 auto; padding: 6px; flex: none; }
  .s-app .s-main { padding-top: 20px; }
  .s-app .s-top h1 { font-size: clamp(24px, 6vw, 30px); }
  .panels, .panels.even, .walkin, .two { grid-template-columns: minmax(0, 1fr); }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }
  .table-wrap > table { min-width: 620px; }
}
/* phones: only the active staff link shows its label, the rest are icons */
@media (max-width: 560px) {
  .s-app .side nav a { font-size: 0; padding: 10px 12px; gap: 0; }
  .s-app .side nav a.on { font-size: 13px; gap: 8px; }
}

/* ---- 7. Tablet landscape / iPad / small laptop (901 to 1100): icon rail ---- */
@media (min-width: 901px) and (max-width: 1100px) {
  .s-app { grid-template-columns: 76px minmax(0, 1fr); }
  .s-app .side { padding: calc(18px + var(--safe-t)) 10px 18px max(10px, var(--safe-l)); align-items: center; }
  .s-app .side .logo-link { margin: 0 0 18px; }
  .s-app .side .logo { width: 52px; height: auto; }
  .s-app .side nav { width: 100%; align-items: stretch; }
  .s-app .side nav a { font-size: 0; gap: 0; justify-content: center; padding: 12px 0; }
  .s-app .side nav a .ic { width: 20px; height: 20px; }
  .s-app .side nav .small, .s-app .side .who .wt { display: none; }
  .s-app .side nav .div { margin: 8px 6px; }
  .s-app .side .who { flex-direction: column; padding: 10px 6px; gap: 6px; }
  .s-app .s-main { padding-top: 24px; }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats, .stats.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- 8. Customer: tablet portrait to small laptop ------------------------- */
@media (max-width: 980px) {
  .c-hero .in { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 701px) and (max-width: 900px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-5); }
}

/* ---- 9. Landscape phones / short screens ---------------------------------- */
@media (max-height: 520px) and (orientation: landscape) {
  .c-hero .in { padding-top: var(--s-5); }
  .c-top .in { height: 56px; }
  .c-top .logo { height: 38px; }
  .s-app .side { max-height: 100dvh; }
  body.pg-login-index main.wrap, body.pg-login-register main.wrap { min-height: 0; align-items: flex-start; padding-top: 20px; }
  .auth-shell { margin-block: 0; }
}

/* ---- 10. Large screens: 1600+ (desktop monitors) ---------------------------- */
@media (min-width: 1600px) {
  .wrap, .c-top .in, .c-hero .in, .c-foot .in { max-width: 1360px; }
  .s-app .s-main { max-width: 1560px; width: 100%; margin-inline: auto; }
  .auth-shell { max-width: 1040px; }
  .auth-shell.wide { max-width: 1120px; }
}

/* ---- 11. Full HD TV / big monitor: 1920+ ----------------------------------- */
@media (min-width: 1920px) {
  :root { --fs-xs: 13.5px; --fs-sm: 16px; --fs-md: 18px; --fs-lg: 21px; --field-h: 54px; }
  .wrap, .c-top .in, .c-hero .in, .c-foot .in { max-width: 1560px; }
  .s-app { grid-template-columns: 280px minmax(0, 1fr); }
  .s-app .s-main { max-width: 1760px; }
  .s-app .side nav a { font-size: 16px; padding: 13px 14px; }
  .s-app .s-top h1 { font-size: 40px; }
  .c-cats .c-cat:nth-child(n) { height: 270px; min-height: 270px; }
  .c-cats .c-cat .t { font-size: 32px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .btn { min-height: 52px; }
  :focus-visible { outline-width: 4px; }       /* clear focus ring for TV remotes / d-pad */
}

/* ---- 12. 4K / 5K / TV at native resolution: 2560+ -------------------------- */
@media (min-width: 2560px) {
  :root { --fs-xs: 16px; --fs-sm: 19px; --fs-md: 21px; --fs-lg: 25px; --field-h: 62px; --gutter: 48px; }
  .wrap, .c-top .in, .c-hero .in, .c-foot .in { max-width: 1960px; }
  .s-app { grid-template-columns: 330px minmax(0, 1fr); }
  .s-app .s-main { max-width: 2160px; }
  .s-app .side nav a { font-size: 19px; padding: 16px 18px; }
  .s-app .s-top h1 { font-size: 52px; }
  .c-top .in { height: 96px; }
  .c-top .logo { height: 68px; }
  .c-cats .c-cat:nth-child(n) { height: 340px; min-height: 340px; }
  .c-cats .c-cat .t { font-size: 42px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .btn { min-height: 62px; padding: 0 36px; }
}

/* ---- 13. Ultrawide: keep line lengths sane ---------------------------------- */
@media (min-aspect-ratio: 21/9) and (min-width: 2000px) {
  .wrap, .c-top .in, .c-hero .in, .c-foot .in { max-width: 1760px; }
}

/* ---- 14. Preferences ----------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .s-app .action-bar::before { animation: none; }
}
@media (prefers-contrast: more) {
  .s-app .card, .card { box-shadow: 0 0 0 1.5px var(--ink, #14241B); }
}
@media print {
  .s-app { display: block; }
  .s-app .side, .action-bar, .c-top, .c-foot, .toasts { display: none !important; }
  .s-app .s-main { max-width: none; padding: 0; }
}
