/* Shared screen layout. Print sizing remains owned by checkout.css. */
@media screen {
  html { -webkit-text-size-adjust: 100%; }
  body { min-width: 0; }
  main, .card, .workspace > *, .checkout-grid > *, .plans-notes > *,
  .brand, .brand > div, .intro > *, .section-head > *, .estimate-result > * { min-width: 0; }
  .topbar { height: auto; min-height: 84px; padding-block: 14px; }
  .topbar > .row-actions, .plans-nav { flex-wrap: wrap; justify-content: flex-end; }
  button { max-width: 100%; white-space: normal; line-height: 1.5; touch-action: manipulation; }
  a, input, select, textarea, summary { touch-action: manipulation; }
  input, select, textarea { max-width: 100%; scroll-margin-block: 80px; }
  img, canvas, svg { max-width: 100%; }
  .brand small, .hint, .notice, .warning-text, .page-footer, .claim-head strong,
  .claim-details span, .section-head h2, .summary-table td, .raw-item,
  .estimate-result p, #order-ref, #slip-status { overflow-wrap: anywhere; }
  .claim-time, .claim-details strong { flex-shrink: 0; }
  .table-wrap { min-width: 0; max-width: 100%; margin-inline: 0; }
  .summary-table { table-layout: fixed; }
  .summary-table th:nth-child(2), .summary-table td:nth-child(2) { width: 15%; text-align: center; }
  .summary-table th:last-child, .summary-table td:last-child { width: 30%; }
  .summary-total, .checkout-totals p { flex-wrap: wrap; }
  .summary-total strong, .grand-total strong { max-width: 100%; overflow-wrap: anywhere; }
  dialog {
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: auto;
  }
  dialog .section-head { align-items: flex-start; }
  dialog .section-head h2 { overflow-wrap: anywhere; }
  dialog .section-head > button { flex-shrink: 0; min-width: 44px; min-height: 44px; }
  body:has(dialog[open]) { overflow: hidden; }
  .qr-save { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px; margin: 8px 0 12px; border-radius: 9px; text-decoration: none; }
  input[type="file"] { padding: 8px; }
  input[type="file"]::file-selector-button { min-height: 38px; padding: 7px 12px; margin-right: 10px; border: 1px solid var(--line); border-radius: 6px; background: #edf4ef; color: var(--ink); font: inherit; }
}

@media screen and (max-width: 850px) {
  .topbar { flex-wrap: wrap; gap: 6px 16px; }
  .topbar > .row-actions, .topbar > .plans-nav { margin-left: auto; }
}

/* Tablet widths and touch devices also need comfortable inputs and hit areas. */
@media screen and (max-width: 1050px), screen and (pointer: coarse) {
  input, select, textarea, .field input, .field select,
  .product-table input, .demo-form input { font-size: 16px; min-height: 44px; line-height: 1.5; }
  button, .primary, .secondary, .ghost, .danger-link,
  .segmented button, .filters button, .section-head .row-actions button,
  .claim-bottom button { min-height: 44px; font-size: 14px; }
  .topbar a.source-link, .plans-nav a { display: inline-flex; align-items: center; min-height: 44px; font-size: 13px; }
  .hint, .warning-text, .package-note { font-size: 12px; }
}

@media screen and (max-width: 700px) {
  :root { font-size: 14px; }
  .topbar {
    min-height: 72px;
    padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  }
  main { padding: 22px max(14px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  .brand { gap: 9px; }
  .brandmark { flex-shrink: 0; }
  .brand strong { font-size: 17px; }
  .brand small { font-size: 11px; line-height: 1.5; }
  .topbar > .row-actions { gap: 4px 12px; }
  .topbar a.source-link, .plans-nav a { display: inline-flex; align-items: center; min-height: 44px; font-size: 13px; padding: 6px 0; }
  .topbar .prototype { font-size: 10px; }
  h1, .intro h1 { font-size: clamp(25px, 6.3vw, 33px); }
  h2 { font-size: 19px; }
  .intro { display: block; }
  .intro p { font-size: 14px; }
  .eyebrow, .step { font-size: 11px; }
  .local-badge { margin-top: 10px; white-space: normal; font-size: 12px; }
  .card { padding: 19px 16px; }
  .section-head { flex-wrap: wrap; align-items: flex-start; gap: 10px; }
  .badge { white-space: normal; font-size: 12px; }
  .hint, .notice, .warning-text, .package-note, .page-footer,
  .demo-tools p, .queue-toolbar .hint, .queue-footer .hint { font-size: 12px; line-height: 1.8; }
  .notice { padding: 12px; }
  .field { font-size: 13px; }
  input, select, textarea, .field input, .field select,
  .product-table input, .demo-form input { font-size: 16px; min-height: 44px; line-height: 1.5; padding: 10px; }
  button, .primary, .secondary, .ghost, .danger-link,
  .segmented button, .filters button, .section-head .row-actions button,
  .claim-bottom button { font-size: 14px; min-height: 44px; padding: 10px 12px; }
  .row-actions { gap: 8px; }
  .row-actions > button { flex: 1 1 auto; }
  .toolbar { display: flex; flex-wrap: wrap; }
  .segmented { flex: 1 1 100%; }
  .segmented button { flex: 1 1 0; min-width: 0; }
  .toolbar > .ghost { margin: 0; padding: 8px 12px; }
  .package-picker { grid-template-columns: 1fr; gap: 10px; }
  .package-option { padding: 17px; }
  .package-option strong { font-size: 18px; padding-right: 75px; }
  .package-option > span:not(.package-tag) { font-size: 14px; }
  .package-option small { font-size: 12px; }
  .package-tag { top: 20px; right: 17px; font-size: 10px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metrics article { padding: 14px 12px; }
  .metrics strong { font-size: clamp(18px, 4.8vw, 28px); overflow-wrap: anywhere; }
  .metrics article span, .metrics small { font-size: 11px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 18px; }

  /* Catalogue rows become labelled forms instead of five tiny columns. */
  .product-table, .product-table tbody { display: block; width: 100%; }
  .product-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .product-table tbody { display: grid; gap: 12px; }
  .product-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
  .product-table td { display: block; min-width: 0; padding: 0; }
  .product-table td::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
  .product-table td:nth-child(2) { grid-column: 1 / -1; grid-row: 1; }
  .product-table td:nth-child(1) { grid-column: 1; grid-row: 2; }
  .product-table td:nth-child(3) { grid-column: 2; grid-row: 2; }
  .product-table td:nth-child(4) { grid-column: 1; grid-row: 3; }
  .product-table td:last-child { grid-column: 2; grid-row: 3; align-self: end; }
  .product-table td:last-child::before, .product-table td[colspan]::before { display: none; }
  .product-table td[colspan] { grid-column: 1 / -1; }
  .product-table .delete-row { min-width: 44px; width: 100%; min-height: 44px; border: 1px solid #efd8d5; background: #fff7f6; font-size: 20px; padding: 5px 12px; }
  .demo-tools { padding: 15px; }
  .demo-tools strong { font-size: 14px; }
  .demo-tools-top { display: block; }
  .demo-tools-top button { margin-top: 10px; }
  .demo-form { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .demo-form button { grid-column: auto; }
  .filters { display: flex; flex-wrap: wrap; gap: 4px; }
  .claim { padding: 15px; }
  .claim-head { flex-wrap: wrap; align-items: flex-start; }
  .claim-head strong, .claim-text { font-size: 14px; }
  .claim-time { font-size: 11px; }
  .claim-details { flex-wrap: wrap; align-items: flex-start; font-size: 13px; }
  .claim-details strong { font-size: 17px; max-width: 100%; overflow-wrap: anywhere; }
  .claim-bottom { gap: 10px; }
  .claim-bottom > .row-actions:last-child { width: 100%; }
  .claim-bottom .source-link { min-height: 44px; display: inline-flex; align-items: center; padding-inline: 8px; font-size: 12px; }
  .status-badge { font-size: 12px; }
  .raw-section summary { font-size: 13px; min-height: 44px; padding-block: 10px; }
  .raw-item, .raw-item small { font-size: 12px; }
  .queue-footer { align-items: flex-start; }
  .summary-dialog, dialog { padding: 18px; width: calc(100vw - 24px); }
  .summary-table { font-size: 13px; }
  .summary-table th, .summary-table td { padding: 9px 5px; }
  .summary-total { align-items: flex-start; }
  .summary-total strong { font-size: 26px; }
  textarea { min-height: 150px; }
  .toast { bottom: max(16px, env(safe-area-inset-bottom)); font-size: 13px; }

  #plan-calculator { grid-template-columns: minmax(0, 1fr); }
  #plan-calculator > label:first-child, #plan-calculator button { grid-column: auto; }
  #plan-calculator button { height: auto; }
  .plans-nav { gap: 14px; }
  .plans-table, .plans-table tbody { display: block; width: 100%; white-space: normal; }
  .plans-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .plans-table tbody { display: grid; gap: 14px; }
  .plans-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
  .plans-table tbody tr.recommended { border-color: #80b59b; background: #eef7ef; }
  .plans-table tr[data-plan="business-24h"] td, .plans-table td { border: 0; }
  .plans-table td, .plans-table td:nth-child(n+3) { display: block; min-width: 0; padding: 0; text-align: left; font-size: 14px; overflow-wrap: anywhere; }
  .plans-table td::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-bottom: 3px; }
  .plans-table .recommended td { background: transparent; }
  .plans-table .recommended td:first-child { box-shadow: none; }
  .plans-table .plan-price { font-size: 20px; }
  .plans-notes ul, .prototype-note p, .estimate-result p { font-size: 13px; }
  .estimate-result strong { font-size: 27px; overflow-wrap: anywhere; }
  .checkout-grid, .checkout-fields { grid-template-columns: minmax(0, 1fr); }
  .checkout-fields .full-width { grid-column: auto; }
  .checkout-totals p { font-size: 14px; }
  #qr-recipient { font-size: 14px; }
  .merchant-settings summary { min-height: 44px; font-size: 14px; }
  .merchant-settings summary .hint { display: block; }
  .merchant-settings .row-actions > button { flex-basis: 100%; }
  .address-card .section-head { display: block; }
  .address-card .section-head > button { margin-top: 12px; width: 100%; }
  #save-address { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
