/* Keep grid tracks and form controls within their containing card. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-width: 0; }
.container, .topbar-inner, .workspace-grid, .users-grid, .stat-grid,
.workspace-grid > *, .users-grid > *, .stat-grid > *, .card,
.stack, .stack > *, .scan-method, .scan-method > *, .scan-launch,
.scan-actions, .section-heading > *, label, fieldset, .field-type {
  min-width: 0;
}
.workspace-grid > *, .users-grid > *, .stat-grid > *, .entry-card,
.scan-method, .scan-launch, .scan-actions, .type-options,
input:not([type=checkbox]), select, textarea { max-width: 100%; }
fieldset { min-inline-size: 0; }
.entry-card { width: 100%; }
.entry-card .stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
select { width: 100%; min-width: 0; text-overflow: ellipsis; }
.remember-choice { align-items: flex-start; white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
.remember-choice > span { min-width: 0; flex: 1; }
.remember-choice input { margin-top: 2px; }
.btn { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.scan-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
.scan-actions #quick-capture { grid-column: 1 / -1; }
.scan-actions .btn { width: 100%; padding-inline: 8px; }
.scan-launch { text-align: center; }
.scan-launch strong, .scan-launch p, .checker-line { max-width: 100%; overflow-wrap: anywhere; }
.field-type { display: flex; flex-direction: column; gap: 7px; }
.field-label-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0; }
.field-label-row > label { display: inline; }
.link-btn { border: 0; padding: 4px 0; background: transparent; color: var(--blue); font-size: 11px; font-weight: 650; flex-shrink: 0; }
.field-type .type-options { margin-top: 0; }
.manual-type-dialog { max-width: 470px; }
.manual-type-dialog .form-actions { flex-wrap: wrap; }
.manual-type-dialog .form-actions .btn { flex: 1 1 150px; }
.action-label { display: none; }
.table-wrap { min-width: 0; max-width: 100%; }
.pagination, .heading-actions, .section-heading { flex-wrap: wrap; }
.account-menu { max-width: calc(100vw - 28px); }
@media (max-width: 820px) {
  .workspace-grid, .users-grid { grid-template-columns: minmax(0, 1fr); }
  .entry-card .stack { display: flex; flex-direction: column; }
  .criteria { display: flex; flex-direction: column; }
  .entry-card .stack > * { width: 100%; }
  .entry-card .stack > input[type=hidden] { display: none; }
  input:not([type=checkbox]):not([type=hidden]), textarea, select { font-size: 16px !important; }
  .entry-card { padding: 18px; }
  .scan-method .remember-choice { font-size: 11px; line-height: 1.65; }
  .scan-launch { padding: 18px 12px; }
  .scan-actions .btn { min-height: 44px; font-size: 12px; }
  .stat-card { padding: 13px 10px; min-height: 112px; }
  .stat-card strong { font-size: 27px; }
  .stat-label { font-size: 10px; line-height: 1.5; min-height: 30px; }
  .stat-card small { font-size: 9px; line-height: 1.5; overflow-wrap: anywhere; }
  .filter-form .filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-dates .btn { grid-column: 1 / -1; justify-self: end; }
  .main-nav { padding-inline: 10px; }
  .main-nav a { min-width: 0; max-width: 150px; }
  .footer { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  dialog { max-width: calc(100vw - 24px); }
}
@media (max-width: 600px) {
  .devices-table { display: block; min-width: 0; width: 100%; }
  .devices-table thead { display: none; }
  .devices-table tbody { display: grid; gap: 12px; padding: 0 14px 12px; }
  .devices-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 12px; padding: 6px; min-width: 0; }
  .devices-table td { display: block; border: 0; padding: 8px !important; min-width: 0; max-width: none; }
  .devices-table td:first-child, .devices-table td:nth-child(4), .devices-table td:nth-child(5), .devices-table td:last-child { grid-column: 1 / -1; }
  .devices-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 400; }
  .devices-table td:first-child strong { font-size: 14px; }
  .devices-table .type-label { font-size: 10px; }
  .devices-table .serial-value { font-size: 13px; }
  .devices-table .checker-name, .devices-table .note-cell { font-size: 12px; }
  .devices-table .time-cell { font-size: 11px; }
  .devices-table .badge { font-size: 11px; white-space: normal; }
  .devices-table .row-actions { justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
  .devices-table .icon-btn { width: auto; min-height: 40px; gap: 6px; padding: 9px 12px; border: 1px solid var(--border); font-size: 12px; }
  .devices-table .icon-btn.delete { color: #b34348; border-color: #f0d6d8; background: #fff7f7; }
  .devices-table .action-label { display: inline; }
  .report-filters .filter-row { grid-template-columns: minmax(0, 1fr); }
  .page-heading { gap: 12px; }
  .heading-actions { padding-top: 0; }
}
@media (max-width: 360px) {
  .page-heading { flex-wrap: wrap; }
  .heading-actions { width: 100%; }
  .heading-actions .btn { margin-left: auto; }
  .stat-grid { gap: 6px; }
  .stat-card strong { font-size: 23px; }
}
@media print {
  .devices-table, .devices-table tbody { display: table; }
  .devices-table thead { display: table-header-group; }
  .devices-table tr { display: table-row; }
  .devices-table td { display: table-cell; }
  .devices-table td::before, .row-actions, .link-btn { display: none !important; }
}

.photo-set { min-width:0; max-width:100%; padding:14px; border:1px solid var(--border); border-radius:12px; margin-bottom:18px; background:#f9fbfe; }
.photo-set .section-heading { margin-bottom:8px; }
.photo-set strong { font-size:12px; }
.photo-set>.field-help { margin-bottom:12px; }
.photo-list { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; margin-bottom:12px; }
.photo-list figure { position:relative; min-width:0; margin:0; border:1px solid #dbe5ef; border-radius:9px; padding:5px; background:#fff; }
.photo-list img { display:block; width:100%; aspect-ratio:1; object-fit:cover; border-radius:5px; }
.photo-list figcaption { font-size:10px; padding-top:5px; color:var(--muted); }
.photo-list button { position:absolute; right:7px; top:7px; border:0; padding:4px 7px; border-radius:5px; background:#fff; color:#a43d43; font-size:10px; box-shadow:0 1px 5px #0002; }
@media(max-width:360px) { .photo-list { grid-template-columns:repeat(2,minmax(0,1fr)); } .photo-set .form-actions { flex-wrap:wrap; } }

.brand>span:last-child{min-width:0;overflow-wrap:anywhere}.brand small{display:block}.pwa-install{margin:8px auto;max-width:calc(100% - 32px)}
.brand{flex-shrink:1;min-width:0}.brand-mark{flex-shrink:0}@media(max-width:480px){.brand{font-size:15px;gap:9px}.topbar-inner{gap:10px}.brand>span:last-child{line-height:1.25}.brand small{line-height:1.3}}
.unit-field{position:relative;min-width:0}.unit-options{display:block;background:#fff;border:1px solid #cbd8e7;border-radius:10px;max-height:210px;overflow:auto;padding:4px;margin-top:4px;box-shadow:0 6px 16px #17385a12}.unit-options[hidden]{display:none}.unit-options button{display:block;width:100%;text-align:left;border:0;background:transparent;padding:10px;border-radius:6px;color:#172c47;white-space:normal;overflow-wrap:anywhere;cursor:pointer}.unit-options button:hover,.unit-options button[aria-selected=true]{background:#eaf2fb}.unit-cell{min-width:120px;max-width:240px;white-space:normal;overflow-wrap:anywhere}@media(max-width:600px){.unit-cell{min-width:0;max-width:none}}
.api-profile{padding:16px 0;border-bottom:1px solid var(--border);min-width:0;overflow-wrap:anywhere}.api-profile:last-child{border-bottom:0}.api-profile .form-actions{flex-wrap:wrap;gap:8px}.api-profile form{margin:0;min-width:0}.api-delete{margin-top:12px;font-size:12px}.api-delete summary{cursor:pointer;color:#a03838}.api-editor{margin-top:20px}.api-profiles .section-heading{flex-wrap:wrap}
