/* TPC $ web — additions to the Windows look: the phone layout (one pane at a time), touch sizes, safe areas. */
#app { height: 100vh; height: 100dvh; }
#signin { height: 100vh; height: 100dvh; padding: 16px; }
.si-box { max-width: 100%; }
@media (min-width: 901px) { #mBack { display: none !important; } }

/* touch screens: bigger targets, no keyboard hints */
@media (hover: none) and (pointer: coarse) {
  .btn { height: 40px; padding: 0 14px; }
  .icon { width: 40px; height: 40px; }
  .chip { height: 32px; padding: 0 12px; }
  .nav { min-height: 44px; }
  .pin { width: 36px; height: 36px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  .nav kbd, .menu kbd, #status .hk { display: none; }
  .card:has(.keys) { display: none; }
  .menu button { padding: 11px 12px; }
}

/* phone */
@media (max-width: 900px) {
  html, body { font-size: 15px; }
  input[type=text], input[type=search], input[type=url], select, textarea, .pt input.price { font-size: 16px; }   /* no zoom-in when a field is tapped */
  #top { height: 54px; gap: 4px; padding: 0 6px; padding-top: env(safe-area-inset-top); height: calc(54px + env(safe-area-inset-top)); }
  #top .brand { width: auto; } #top .brand .bname { display: none; }
  #top .search { flex: 1 1 auto; }
  #top .grow { display: none; }
  #importBtn, #exportBtn, #themeBtn { display: none; }
  #saveAll { padding: 0 10px; }
  #body { display: block; position: relative; }
  #body > * { position: absolute; inset: 0; border: 0; }
  body[data-pane=side] #list, body[data-pane=side] #detail,
  body[data-pane=list] #side, body[data-pane=list] #detail,
  body[data-pane=detail] #side, body[data-pane=detail] #list { display: none; }
  #dBack { display: none !important; }
  #side { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .nav { width: calc(100% - 16px); margin: 1px 8px; }
  .li { padding: 12px 14px; }
  #listHead { padding: 10px 12px 8px; }
  #dHead { padding: 8px 12px; min-height: 52px; flex-wrap: wrap; }
  #dHead h2 { font-size: 16px; white-space: normal; }
  #dTools { flex-wrap: wrap; }
  #dBar { flex-wrap: wrap; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  #dBar > .small { flex-basis: 100%; }
  #dBar .grow { display: none; }
  #dBar .btn { flex: 1 1 auto; }
  #status { height: auto; min-height: 26px; padding: 3px 10px calc(3px + env(safe-area-inset-bottom)); }
  #status > span:nth-child(n+2):not(.err) { display: none; }
  #status > span.err { margin-left: auto; }
  .legend span:has(kbd) { display: none; }
  .toolbar { padding: 8px 10px 0; }
  .opts { padding: 6px 10px 0; }
  .opt { align-items: flex-start; }
  .opt .l { width: 64px; padding-top: 7px; }
  .card { margin: 10px 8px 0; }
  .dash { grid-template-columns: minmax(0, 1fr); }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .methods { grid-template-columns: minmax(0, 1fr); padding: 4px 10px 12px; }
  .stat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tier { grid-template-columns: minmax(0, 1fr) 110px 36px; }
  .prow { grid-template-columns: 22px minmax(0, 1fr) auto; padding: 8px 12px; }
  .prow .mg { grid-column: 2 / 4; text-align: left; }
  .grid { margin: 8px 8px 0; overflow-x: auto; }
  .legend { padding: 8px 10px 0; }

  /* dialogs come up from the bottom */
  .sheet { align-items: flex-end; }
  .sheet-box, .sheet-box.wide { width: 100%; max-width: 100%; max-height: 88vh; border-radius: 16px 16px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
  .sheet-btns .btn { flex: 1 1 auto; height: 44px; }
  .snack { left: 10px; right: 10px; transform: none; top: calc(62px + env(safe-area-inset-top)); bottom: auto; max-width: none; }   /* at the top: never over the Save buttons */
  .menu { min-width: 250px; }
}

/* small laptops and tablets on their side: three narrower panes */
@media (min-width: 901px) and (max-width: 1100px) {
  #body { grid-template-columns: 200px 260px minmax(0, 1fr); }
  #top .brand { width: auto; }
  #importBtn .lbl, #exportBtn .lbl { display: none; }
}

/* phone (narrow): the price list as cards — name, price and pin on one line; wholesale and margin under it; warnings last */
@media (max-width: 600px) {
  table.pt:not(.mx), .pt:not(.mx) tbody { display: block; }
  .pt:not(.mx) thead { display: none; }
  .pt:not(.mx) tr { display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr) 112px 38px; column-gap: 8px; row-gap: 2px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
  .pt:not(.mx) tr:last-child { border-bottom: 0; }
  .pt:not(.mx) td { display: block; border: 0; height: auto; padding: 0; text-align: left; background: none !important; white-space: normal; }
  .pt:not(.mx) td.k { grid-column: 1; grid-row: 1 / span 3; align-self: center; width: auto; }
  .pt:not(.mx) td.q { grid-column: 2 / 4; grid-row: 1; }
  .pt:not(.mx) td.p { grid-column: 4; grid-row: 1; width: auto; }
  .pt:not(.mx) td:nth-child(7) { grid-column: 5; grid-row: 1; }
  .pt:not(.mx) td.w { grid-column: 2 / 4; grid-row: 2; font-size: 13px; }
  .pt:not(.mx) td.w::before { content: "Wholesale "; }
  .pt:not(.mx) td.m { grid-column: 4 / 6; grid-row: 2; font-size: 13px; text-align: right; padding-right: 2px; }
  .pt:not(.mx) td.m::before { content: "Margin "; color: var(--muted); font-weight: 400; }
  /* an edited price shows what it was, next to the quantity */
  .pt:not(.mx) tr:has(td.was:not(:empty)) td.q { grid-column: 2; }
  .pt:not(.mx) td.was { grid-column: 3; grid-row: 1; text-align: right; }
  .pt:not(.mx) td.was:empty, .pt:not(.mx) td.note:empty { display: none; }
  .pt:not(.mx) td.note { grid-column: 2 / 6; grid-row: 3; min-width: 0; }
  .pt:not(.mx) input.price { width: 100%; height: 40px; }
  .pt:not(.mx) tr.badrow { background: var(--bad-soft); } .pt:not(.mx) tr.warnrow { background: var(--warn-soft); }
  .pt:not(.mx) tr.sel { background: var(--sel); }
  .pt:not(.mx) td[colspan] { grid-column: 1 / -1; }

}
/* a table wider than its pane scrolls sideways instead of being cut off */
.grid { overflow-x: auto; }
