/* Shared screen geometry. Loaded after feature styles; never used by PDF templates. */
/* A 320px viewport may have only 305px available beside a classic scrollbar.
   Let authenticated screens fit that space without clipping or horizontal scroll.
   Login, installer and standalone print/PDF layouts retain their own minimums. */
html:has(> body.app-page) { min-width: 0; }

body.app-page {
  --workspace-control-height: 50px;
  --workspace-control-radius: 14px;
  --workspace-dialog-padding: 24px;
}

/* The intermediate shell already uses the full viewport. Keep its sidebar
   off-canvas too, so it cannot cover headings and controls at 821–1080px.
   Phone geometry and the wide desktop sidebar remain unchanged. */
@media (min-width: 821px) and (max-width: 1080px) {
  body.app-page.sidebar-open { overflow: hidden; }
  body.app-page .sidebar {
    transform: translateX(-102%);
    transition: transform .22s ease;
  }
  body.app-page.sidebar-open .sidebar { transform: translateX(0); }
  body.app-page .sidebar-close { display: block; }
  body.app-page .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(12,29,42,.48);
  }
  body.app-page.sidebar-open .sidebar-overlay { display: block; }
  body.app-page .app-shell { padding-top: calc(72px + env(safe-area-inset-top)); }
  body.app-page .mobile-header {
    position: fixed;
    inset: calc(8px + env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) auto max(12px,env(safe-area-inset-left));
    z-index: 15;
    height: 56px;
    padding: 0 12px;
    display: grid;
    grid-template-columns: 44px minmax(0,1fr) 34px;
    align-items: center;
    gap: 9px;
    border: 1px solid rgba(255,255,255,.8);
    border-radius: 22px;
  }
  body.app-page .mobile-header strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
  }
}
@media (prefers-reduced-motion: reduce) {
  body.app-page .sidebar { transition: none; }
}

/* Home has its own motto/clock composition. */
body.app-page .content-shell > .page-header:not(.dashboard-header) {
  min-height: 0;
  margin-bottom: 24px;
  gap: 20px;
  align-items: center;
}
body.app-page .page-header:not(.dashboard-header) .eyebrow,
body.app-page :is(.panel-heading, .app-dialog .dialog-heading, .document-editor-heading) .section-kicker { display: none; }
body.app-page .page-header:not(.dashboard-header) h1 { margin: 0 0 8px; }
body.app-page .page-header:not(.dashboard-header) .page-description { margin: 0; }

/* Nested document headings use the same Korean-only hierarchy. Retain the
   guidance and actions, without leaving the old English label's height. */
body.app-page .document-editor-heading { min-height: 0; }
body.app-page .document-editor-heading > div { min-width: 0; }
body.app-page .content-shell:not(:has(> .dashboard-header)) .panel-heading > small,
body.app-page .document-editor-heading small {
  min-width: 0;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
@media (max-width: 560px) {
  body.app-page .document-editor-heading { gap: 8px; }
}

/* Search controls use the same size as ordinary form fields. Native special
   controls, document line items and metronome controls retain their own sizes. */
body.app-page :is(.sales-filter-form, .card-expense-filter-form, .schedule-filter-form,
  .knowledge-filter-form, .document-search-field, .unified-schedule-filters,
  .inline-filter, .month-selector, .daily-task-date-form, .weekly-date-form,
  .sales-year-filter, .field:not(.metro-settings .field))
  :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]):not([type=range]):not([type=color]), select) {
  min-width: 0;
  min-height: var(--workspace-control-height);
  border-radius: var(--workspace-control-radius);
  font-size: 17px;
  box-sizing: border-box;
}
body.app-page :is(.sales-filter-form, .card-expense-filter-form) :is(input, select) {
  border-color: rgba(60,60,67,.18);
  background: rgba(255,255,255,.82);
  box-shadow: inset 0 1px rgba(255,255,255,.94);
}
body.app-page :is(.sales-filter-form, .card-expense-filter-form) :is(input, select):focus {
  border-color: rgba(0,122,255,.52);
  box-shadow: 0 0 0 4px rgba(0,122,255,.11);
  outline: none;
}
/* Explicit geometry avoids Safari's compact native single-select painting.
   Only ordinary workspace fields/filters participate: list boxes, document
   line items, login/print pages and metronome controls keep their own sizing. */
body.app-page .knowledge-filter-form input[type="search"] {
  height: var(--workspace-control-height);
}
body.app-page :is(.sales-filter-form, .card-expense-filter-form, .schedule-filter-form,
  .knowledge-filter-form, .document-search-field, .unified-schedule-filters,
  .inline-filter, .month-selector, .daily-task-date-form, .weekly-date-form,
  .sales-year-filter, .field:not(.metro-settings .field))
  select:not([multiple]):not([size]):not(.document-item-table select) {
  height: var(--workspace-control-height);
  -webkit-appearance: none;
  appearance: none;
  padding: 0 36px 0 11px;
  line-height: 1.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='m4 6 4 4 4-4' stroke='%233a3a3c' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
}
@media (forced-colors: active) {
  body.app-page :is(.sales-filter-form, .card-expense-filter-form, .schedule-filter-form,
    .knowledge-filter-form, .document-search-field, .unified-schedule-filters,
    .inline-filter, .month-selector, .daily-task-date-form, .weekly-date-form,
    .sales-year-filter, .field:not(.metro-settings .field))
    select:not([multiple]):not([size]):not(.document-item-table select) {
    -webkit-appearance: auto;
    appearance: auto;
    background-image: none;
  }
}
/* Text links do not inherit a button's centered alignment. Normalize only
   note icon controls, retaining their existing sizes and accessible names. */
body.app-page :is(.knowledge-detail-close, .knowledge-checklist-edit-row > button,
  #knowledgeTableDialog .dialog-close) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
/* The toolbar and editor share one border. Keep the label gap in both rich
   editing and the no-JavaScript textarea fallback, not between those halves. */
body.app-page .knowledge-content-field { row-gap: 0; }
body.app-page .knowledge-content-field > #knowledgeContentLabel { margin-bottom: 7px; }
/* Fixed preview cards only. The full detail/editor content is never clamped. */
body.app-page .knowledge-note-card { height: 310px; display: flex; flex-direction: column; }
body.app-page .knowledge-note-card-main {
  flex: 1 1 auto; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; gap: 8px;
}
body.app-page .knowledge-note-card-top { flex-shrink: 0; min-height: 25px; }
body.app-page .knowledge-note-card-top .knowledge-category {
  min-width: 0; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
body.app-page .knowledge-note-card-top .knowledge-pin { flex-shrink: 0; }
body.app-page .knowledge-note-card h3 {
  flex-shrink: 0; min-height: 46px; max-height: 46px; overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
body.app-page .knowledge-card-excerpt {
  min-height: 0; max-height: 68px; overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
}
body.app-page .knowledge-card-checklist { min-height: 0; max-height: 70px; overflow: hidden; }
body.app-page .knowledge-card-labels { max-height: 25px; flex-wrap: nowrap; overflow: hidden; flex-shrink: 0; }
body.app-page .knowledge-card-labels small { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
body.app-page .knowledge-note-card-meta { margin-top: auto; flex-shrink: 0; }
body.app-page .knowledge-note-card-actions { flex: 0 0 50px; min-height: 50px; }
body.app-page .knowledge-card-lock-label { padding: 5px 9px; color: #636366; font-size: 12px; }
body.app-page .knowledge-password-settings { min-width: 0; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; display: grid; gap: 12px; }
body.app-page .knowledge-password-settings legend { padding: 0 6px; font-size: 13px; }
body.app-page .knowledge-password-settings small { font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
body.app-page .knowledge-password-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
body.app-page .knowledge-unlock-form { display: grid; gap: 14px; width: min(100%,440px); margin: auto; padding: 24px; }
body.app-page .knowledge-unlock-form p { margin: 0; }
body.app-page .knowledge-unlock-form small { font-size: 12px; }
body.app-page .knowledge-unlock-error { color: #b42318; }
body.app-page .knowledge-privacy-status { font-size: 12px; line-height: 1.5; }
@media (max-width: 560px) {
  body.app-page .knowledge-password-fields { grid-template-columns: minmax(0,1fr); }
}
body.app-page .knowledge-checklist-edit-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
}
/* The native radio remains keyboard-operable but invisible; draw its focus
   on the visible swatch, independently of the existing selected-color ring. */
body.app-page .knowledge-color-choice:has(input:focus-visible) {
  outline: 3px solid #007aff;
  outline-offset: 4px;
}
@media (forced-colors: active) {
  body.app-page .knowledge-color-choice:has(input:focus-visible) { outline-color: Highlight; }
}
body.app-page .field > :is(span, label) { font-size: 13px; }
body.app-page :is(.page-header:not(.dashboard-header), .sales-filter-form,
  .card-expense-filter-form, .schedule-filter-form, .knowledge-filter-form,
  .unified-schedule-filters, .document-search-bar, .daily-task-date-form,
  .weekly-date-form, .sales-year-filter, .app-dialog .dialog-actions) .button {
  min-height: var(--workspace-control-height);
}

/* A dialog's form must fill its frame, including To-Do's formerly narrow form. */
body.app-page .app-dialog > :is(form, .dialog-card) {
  width: 100%;
  min-width: 0;
  margin: 0;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  /* Native Tab/error focus must clear the sticky heading and action bar. */
  scroll-padding-block: 100px;
}
body.app-page .unified-schedule-dialog { width: min(680px, calc(100vw - 30px)); }
body.app-page .app-dialog .dialog-heading {
  min-height: 80px;
  padding: 20px var(--workspace-dialog-padding);
  gap: 16px;
}
body.app-page .app-dialog .dialog-heading h2 { margin: 0; font-size: 24px; }
body.app-page .app-dialog .dialog-heading > div { min-width: 0; }
body.app-page .app-dialog .dialog-close { flex-shrink: 0; }
body.app-page .app-dialog :is(.form-grid, .schedule-form-body) {
  padding: var(--workspace-dialog-padding);
  gap: 17px 13px;
}
body.app-page .app-dialog .dialog-actions { padding: 16px var(--workspace-dialog-padding); }
/* A frozen first column must not cover another field while editing a wide
   document table. Retain the normal horizontal scroller and PDF layout. */
body.app-page .document-dialog .mobile-horizontal-table:focus-within { scroll-behavior: auto; }
body.app-page .document-dialog .mobile-horizontal-table:focus-within table :is(th, td):first-child { position: static; }
body.app-page .card-receipt-upload-row:focus-within label.button {
  outline: 2px solid var(--primary, #0066d6); outline-offset: 3px;
}
@media (max-width: 1280px) {
  /* The desktop sidebar leaves too little room for the two preview minima. */
  body.app-page .design-studio-grid { grid-template-columns: minmax(0, 1fr); }
  body.app-page .design-preview-panel { position: static; }
  body.app-page .design-preview-stage svg { max-height: none; }
}
body.app-page :is(.workspace-section-tabs, .design-type-tabs) { margin-bottom: 20px; }
body.app-page :is(.workspace-section-tabs, .design-type-tabs) a {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.4;
}

/* Equal-width list columns must fit narrow desktops/tablets as well as phones.
   Scope wrapping to screen lists, never document entry grids or printed PDFs. */
body.app-page :is(.customer-master-table, .document-list-table,
  .document-trash-table, .equipment-installation-table) {
  width: 100%;
  min-width: 0;
}
body.app-page :is(.customer-master-table, .document-list-table,
  .document-trash-table, .equipment-installation-table) :is(th, td) {
  padding-inline: 6px;
  white-space: normal;
  overflow-wrap: anywhere;
}
body.app-page :is(.customer-master-table, .document-list-table,
  .document-trash-table, .equipment-installation-table) .row-actions {
  flex-wrap: wrap;
}
body.app-page :is(.customer-master-table, .document-list-table,
  .document-trash-table, .equipment-installation-table)
  :is(.row-actions > *, .table-action, .status-badge, .schedule-status, .customer-category-badge, .customer-contact-chip) {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  white-space: normal;
  overflow-wrap: anywhere;
}
body.app-page :is(.customer-master-table, .document-list-table,
  .document-trash-table, .equipment-installation-table)
  :is(.truncate-cell, .customer-address-cell, .customer-contact-chip) {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

/* Long equipment headings wrap within their existing equal-width columns. */
body.app-page .equipment-asset-table th { white-space: normal; }

/* Keep import actions readable instead of letting fixed field minima squeeze
   the button at intermediate widths. File names remain native input content. */
body.app-page .quotation-import-form {
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr) max-content;
}
body.app-page .quotation-import-form .field { min-width: 0; }
body.app-page .quotation-import-form .button { min-height: var(--workspace-control-height); }
body.app-page .quotation-import-file input[type="file"] {
  min-width: 0; max-width: 100%; height: 50px; padding: 5px 8px; box-sizing: border-box;
}
body.app-page .quotation-import-file input[type="file"]::file-selector-button {
  height: 36px; min-height: 36px; padding: 0 10px;
}
@media (max-width: 760px) {
  body.app-page .quotation-import-form { grid-template-columns: minmax(0, 1fr); }
  body.app-page .quotation-import-form .button { width: 100%; }
  body.app-page .quotation-import-panel .panel-heading { flex-direction: column; align-items: stretch; gap: 8px; }
}

/* Fit all thirteen equal-width ledger columns. Wrap descriptive text and
   action buttons instead of clipping them; phone cards retain their layout. */
body.app-page :is(.sales-ledger-panel, .card-expense-ledger-panel) { container-type: inline-size; }
body.app-page .sales-ledger-table { width: 100%; min-width: 0; }
body.app-page .sales-ledger-table :is(th, td) {
  padding-inline: 3px; white-space: normal; overflow-wrap: anywhere;
}
body.app-page .sales-ledger-table .sales-item-cell {
  min-width: 0; max-width: none; white-space: normal; overflow: visible; text-overflow: clip;
}
body.app-page .sales-ledger-table .row-actions { flex-wrap: wrap; }
body.app-page .sales-ledger-table .money-cell { padding-inline: 1px; font-size: 12px; white-space: nowrap; }
body.app-page .sales-ledger-table .status-badge { min-width: 0; max-width: 100%; white-space: normal; }
/* Card expenses keep every field, including receipts and the full accepted
   amount range. Use the same available-space transition as the sales ledger. */
body.app-page .card-expense-table { width: 100%; min-width: 0; }
body.app-page .card-expense-table :is(th, td) { padding-inline: 6px; overflow-wrap: anywhere; }
body.app-page .card-expense-table th { white-space: normal; }
body.app-page .card-expense-table .money-cell { font-size: 12px; white-space: nowrap; }
body.app-page .card-expense-table .money-cell strong { font-size: inherit; }
body.app-page .card-expense-table .row-actions { flex-wrap: wrap; }
/* A sidebar can leave less room than the viewport suggests. Use the existing
   card presentation when the ledger itself cannot fit readable amounts. */
@container (max-width: 1024px) {
  body.app-page :is(.sales-ledger-panel, .card-expense-ledger-panel) .table-wrap { overflow: visible; }
  body.app-page :is(.sales-ledger-table, .card-expense-table) { display: block; }
  body.app-page :is(.sales-ledger-table, .card-expense-table) thead {
    display: table-header-group; position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  body.app-page :is(.sales-ledger-table, .card-expense-table) tbody { display: grid; gap: 12px; }
  body.app-page :is(.sales-ledger-table, .card-expense-table) tbody tr {
    display: block; overflow: hidden; border: 1px solid var(--line);
    border-radius: 14px; background: #fff;
  }
  body.app-page :is(.sales-ledger-table, .card-expense-table) tbody td {
    display: block; width: auto !important; min-width: 0; max-width: none;
    min-height: 52px; padding: 10px 13px; border-bottom: 1px solid var(--line);
    font-size: 14px; line-height: 1.55;
  }
  body.app-page :is(.sales-ledger-table, .card-expense-table) tbody td:last-child { border-bottom: 0; }
  body.app-page :is(.sales-ledger-table, .card-expense-table) td.money-cell { padding-inline: 13px; font-size: 14px; }
  body.app-page :is(.sales-ledger-table, .card-expense-table) tbody td::before {
    content: attr(data-mobile-label); display: block; margin-bottom: 4px;
    color: var(--muted); font-size: 12px; font-weight: 700;
  }
  body.app-page :is(.sales-ledger-table, .card-expense-table) tbody td.mobile-card-empty { padding: 34px 20px; }
  body.app-page :is(.sales-ledger-table, .card-expense-table) tbody td.mobile-card-empty::before { display: none; }
  body.app-page :is(.sales-ledger-table, .card-expense-table) .table-action { min-height: 44px; padding: 8px 14px; }
}

/* Vehicle lists have only three/five columns: remove the unrelated shared
   table minimum and let long addresses/actions wrap within equal columns. */
body.app-page .vehicle-log-page .data-table { min-width: 0; }
body.app-page .vehicle-log-page .data-table :is(th, td) { padding-inline: 6px; }
body.app-page .vehicle-log-page .data-table th { white-space: normal; }
body.app-page .vehicle-log-page .row-actions { flex-wrap: wrap; }
body.app-page .vehicle-log-page .table-action { max-width: 100%; white-space: normal; }
@media (max-width: 760px) {
  body.app-page .vehicle-log-page .data-table thead {
    display: table-header-group; position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}

/* Show the whole stored filename when choosing attachments to remove.
   Even unbroken filenames must fit phones without shrinking the checkbox. */
body.app-page .knowledge-existing-files { min-width: 0; }
body.app-page .knowledge-existing-files label { align-items: start; }
body.app-page .knowledge-existing-files input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  margin: 0;
}
body.app-page .knowledge-existing-files strong {
  font-size: 13px;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

/* Read-only attachment cards follow the same filename sizing and wrapping
   as the editor. Keep preview, download and audio controls intact. */
body.app-page .knowledge-attachment-card > div:first-of-type strong {
  font-size: 13px;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

body.app-page .knowledge-attachment-card > div:first-of-type small {
  font-size: 12px;
  line-height: 1.5;
}
body.app-page .knowledge-file-actions { min-width: 0; gap: 8px; }
body.app-page .knowledge-file-actions a {
  min-width: 44px;
  min-height: 44px;
  max-width: 100%;
  padding: 6px 10px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}
/* Match the existing attachment-card mobile breakpoint. Giving actions the
   full bottom row keeps both touch targets clear of the filename column. */
@media (max-width: 560px) {
  body.app-page .knowledge-file-actions {
    grid-column: 1 / -1;
    flex-wrap: wrap;
  }
}

/* One mobile transition for all ordinary entry dialogs. Feature-specific
   receipt cropping, privacy and announcement dialogs are deliberately excluded. */
@media (max-width: 760px) {
  /* Desktop equipment column percentages must not narrow stacked cards. */
  body.app-page .equipment-asset-table.mobile-card-table tbody td { width: auto !important; }
  html:has(body.app-page .app-dialog[open]), body.app-page:has(.app-dialog[open]) { overflow: hidden; }
  body.app-page { --workspace-dialog-padding: 18px; }
  body.app-page .content-shell > .page-header:not(.dashboard-header) { flex-direction: column; align-items: stretch; }
  body.app-page .app-dialog {
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  body.app-page .app-dialog > :is(form, .dialog-card) { height: 100%; max-height: 100%; }
  body.app-page .app-dialog > .dialog-card { display: flex; flex-direction: column; }
  body.app-page .app-dialog > .dialog-card > * { flex-shrink: 0; }
  body.app-page .app-dialog > .dialog-card > .dialog-actions { margin-top: auto; }
  body.app-page .app-dialog .dialog-heading {
    padding-top: max(16px, env(safe-area-inset-top));
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
  }
  body.app-page .app-dialog :is(.form-grid, .schedule-form-grid) { grid-template-columns: minmax(0, 1fr); }
  body.app-page .app-dialog .dialog-actions {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  body.app-page .app-dialog .dialog-close { min-width: 44px; min-height: 44px; }
  body.app-page .app-dialog .dialog-actions .button { width: 100%; min-width: 0; }
  body.app-page .unified-schedule-dialog > form { display: flex; flex-direction: column; overflow: hidden; }
  body.app-page .unified-schedule-dialog .schedule-form-body { min-height: 0; overflow-y: auto; flex: 1; align-content: start; scroll-padding-block: 16px 100px; }
  body.app-page .unified-schedule-dialog :is(.dialog-heading, .dialog-actions) { flex-shrink: 0; }
  body.app-page .unified-schedule-dialog .dialog-actions { position: static; margin-top: 0; }
  body.app-page :is(.sales-filter-form, .card-expense-filter-form, .schedule-filter-form,
    .knowledge-filter-form, .document-search-field, .unified-schedule-filters,
    .inline-filter, .month-selector, .daily-task-date-form, .weekly-date-form,
    .sales-year-filter, .field:not(.metro-settings .field)) :is(input, select, textarea) { font-size: 16px; }
  body.app-page .app-dialog .field > :is(span, label) { font-size: 13px; }
  body.app-page :where(.content-shell:not(:has(> .dashboard-header))) :is(.button.compact, .table-action) { min-height: 44px; }
  body.app-page :is(.workspace-section-tabs, .design-type-tabs) { width: 100%; }
  body.app-page :is(.workspace-section-tabs, .design-type-tabs) a { flex: 1 1 0; min-width: 0; padding-inline: 8px; }
}
/* Note-type visibility must win over shared field grid/flex layout rules. */
.keep-notes-page .knowledge-editor-form [hidden] { display: none !important; }
/* Notes use ordinary links so paging also works without JavaScript and in PWA. */
body.app-page :is(.knowledge-pagination, .workspace-pagination) {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 8px; margin-top: 24px; min-width: 0;
}
body.app-page :is(.knowledge-pagination, .workspace-pagination) .button { min-width: 44px; padding-inline: 12px; }
body.app-page :is(.knowledge-pagination, .workspace-pagination) [aria-disabled="true"] { opacity: .5; cursor: default; }
body.app-page :is(.knowledge-page-position, .workspace-page-position) { padding: 8px; overflow-wrap: anywhere; }
body.app-page .document-trash-range { margin: 12px 0; font-size: 13px; }
body.app-page :is(#documentHistory, #documentTrash, #inventoryHistory, #equipmentHistory) { scroll-margin-top: 96px; }
/* Document cards are server-rendered, so their first paint does not depend on JS.
   Keep column headers available to assistive technology in the stacked layout. */
@media (max-width: 760px) {
  body.app-page :is(.document-list-table, .document-trash-table) thead {
    display: table-header-group;
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  body.app-page :is(.document-list-table, .document-trash-table) tbody td::before {
    font-size: 12px;
    line-height: 1.5;
    letter-spacing: normal;
  }
}
@media (max-width: 480px) {
  body.app-page :is(.knowledge-page-position, .workspace-page-position) { flex-basis: 100%; order: -1; text-align: center; }
}
/* Conflict recovery is shown only after a rejected stale edit. */
body.app-page [data-form-conflict-link][hidden] { display: none !important; }
body.app-page [data-form-conflict-link]:not([hidden]) { margin: 0 24px 16px; }
/* These page forms already provide their own padding and action gaps. */
body.app-page :is(.company-profile-form, .design-editor-form) [data-form-conflict-link]:not([hidden]) {
  margin: 0;
  max-width: 100%;
  justify-self: start;
}
body.app-page .preferences-form [data-form-conflict-link]:not([hidden]) {
  margin: 0;
  max-width: 100%;
  justify-self: start;
}
/* Shared .field grid styling must not reveal the other card type's fields. */
body.app-page .card-expense-dialog [data-card-expense-field][hidden] { display: none !important; }
/* Keep the week selector's two actions together when the toolbar wraps.
   A flex-basis on the date label previously stranded only the last button. */
body.app-page .weekly-date-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  width: 360px;
  max-width: 100%;
}
@media (max-width: 760px) {
  body.app-page .weekly-date-form {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  body.app-page .weekly-date-form > label { grid-column: 1 / -1; }
  body.app-page .weekly-date-form > .button { width: 100%; }
}
/* Registry rows retain every registration, independent of the selected day. */
.checklist-registry .panel-heading { padding: 20px; }
.checklist-registry .panel-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.checklist-registry-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, .5fr) auto; align-items: center; gap: 16px; padding: 18px 20px; border-top: 1px solid var(--line); }
.checklist-registry-content, .checklist-registry-dates { min-width: 0; overflow-wrap: anywhere; }
.checklist-registry-content > strong { display: block; font-size: 15px; }
.checklist-registry-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; color: var(--muted); font-size: 13px; }
.checklist-registry-dates { display: grid; gap: 6px; font-size: 13px; }
.checklist-registry-dates small { color: var(--muted); font-size: inherit; }
.checklist-registry-actions { justify-content: center; flex-wrap: wrap; }
@media (max-width: 760px) {
  .checklist-registry-item { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 16px; }
  .checklist-registry-actions { justify-content: flex-end; }
}

/* Data cleanup: explicit review, without squeezing destructive controls on mobile. */
.settings-hub-grid:has(> :nth-child(4)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.data-cleanup > .panel { margin-bottom: 20px; }
.cleanup-policy, .cleanup-preview-body { padding: 20px; }
.cleanup-policy h2, .cleanup-menu-list h3 { margin: 0; }
.cleanup-policy p, .cleanup-preview-body > p { line-height: 1.65; overflow-wrap: anywhere; }
.cleanup-policy p:last-child { margin-bottom: 0; }
.cleanup-menu-list, .cleanup-records { list-style: none; margin: 0; padding: 0; }
.cleanup-menu-list > li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-top: 1px solid var(--line); }
.cleanup-menu-list > li > div { min-width: 0; overflow-wrap: anywhere; }
.cleanup-menu-list h3 { font-size: 15px; }
.cleanup-menu-list p { margin: 7px 0; }
.cleanup-menu-list small, .cleanup-records small { color: var(--muted); font-size: 13px; line-height: 1.6; }
.cleanup-menu-list form { flex: 0 0 auto; }
.cleanup-records { border: 1px solid var(--line); border-radius: 14px; margin: 16px 0; }
.cleanup-records li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; }
.cleanup-records li + li { border-top: 1px solid var(--line); }
.cleanup-records li > span { min-width: 0; overflow-wrap: anywhere; }
.cleanup-records li > span > small { display: block; }
.cleanup-records li > small { flex: 0 0 auto; }
.cleanup-confirm-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cleanup-trash-check { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: 10px; line-height: 1.6; }
.cleanup-trash-check input { flex: 0 0 20px; width: 20px; height: 20px; margin: 3px 0 0; }
.cleanup-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
@media (max-width: 760px) {
  .settings-hub-grid:has(> :nth-child(4)) { grid-template-columns: minmax(0, 1fr); }
  .cleanup-policy, .cleanup-preview-body { padding: 16px; }
  .cleanup-menu-list > li { padding: 16px; align-items: stretch; flex-direction: column; gap: 10px; }
  .cleanup-menu-list form > button { width: 100%; }
  .cleanup-records li { align-items: flex-start; flex-direction: column; gap: 4px; padding: 12px; }
  .cleanup-confirm-form { grid-template-columns: minmax(0, 1fr); }
  .cleanup-actions > * { flex: 1 1 auto; min-width: 0; }
}
/* Optional instructions are expanded deliberately; status/error messages stay visible. */
.workspace-context-details { min-width: 0; }
.workspace-context-details > summary { cursor: pointer; padding-block: 10px; font-weight: 600; }
.workspace-context-details > summary:focus-visible { outline: 2px solid var(--accent, #006ee6); outline-offset: 3px; border-radius: 6px; }
.workspace-context-details[open] > summary { margin-bottom: 8px; }
.workspace-context-details p { overflow-wrap: anywhere; }
.knowledge-password-fields > small { grid-column: 1 / -1; }
.delivery-photo-convert-status:empty { display: none; }
.metro-storage-status:empty { display: none; }

/* The time portion is text, never an OS-dependent AM/PM picker. */
body.app-page input[data-time-24] { font-variant-numeric: tabular-nums; }
body.app-page .schedule-reminder-controls { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto; gap: 10px; min-width: 0; }
body.app-page .schedule-reminder-controls > input { width: 100%; min-width: 0; }
@media (max-width: 480px) {
  body.app-page .schedule-reminder-controls { grid-template-columns: minmax(0, 1fr) auto; }
  body.app-page .schedule-reminder-controls > [data-reminder-date] { grid-column: 1 / -1; }
}
/* Named searches remain compact without forcing fixed widths on mobile. */
.app-page .saved-searches { margin-block: 12px; min-width: 0; }
.app-page .sales-filter-panel > .saved-searches { margin-inline: 16px; }
.app-page .schedule-month-panel > .saved-searches { margin-inline: 20px; }
.app-page .saved-search-list { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.app-page .saved-search-item { display: flex; align-items: center; gap: 2px; max-width: 100%; min-width: 0; }
.app-page .saved-search-item > a { min-width: 0; white-space: normal; overflow-wrap: anywhere; text-align: left; }
.app-page .saved-search-item > form { flex: 0 0 auto; margin: 0; }
.app-page .saved-search-remove { width: 36px; height: 36px; min-width: 36px; padding: 0; display: grid; place-items: center; }
.app-page .saved-search-dialog { max-width: 480px; }
.app-page .saved-search-body { display: grid; gap: 12px; padding: var(--workspace-dialog-padding); }
@media (max-width: 760px) { .app-page .saved-search-dialog { max-width: none; } }
@media (max-width: 600px) { .app-page .schedule-month-panel > .saved-searches { margin-inline: 14px; } }
@media (max-width: 560px) { .app-page .sales-filter-panel > .saved-searches { margin-inline: 14px; } }

/* Optional controls expand in normal flow, including narrow screens and zoom. */
.app-page .knowledge-extra-settings { width: 100%; border-top: 1px solid var(--border, #d8dce2); padding-top: 6px; }
.app-page .knowledge-extra-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.app-page .knowledge-extra-fields > .field-wide { grid-column: 1 / -1; }
.app-page .workspace-settings-group { padding: 0; }
.app-page .workspace-settings-group > summary { padding: 20px; font-size: 17px; font-weight: 650; cursor: pointer; overflow-wrap: anywhere; }
.app-page .workspace-settings-group > summary small { display: block; margin-top: 6px; font-size: 13px; font-weight: 400; color: var(--muted, #596273); }
.app-page .workspace-settings-group[open] > summary { border-bottom: 1px solid var(--border, #d8dce2); }
.app-page .workspace-settings-group > .preferences-grid { margin: 0; gap: 0; }
.app-page .preference-section { min-width: 0; }
.app-page .workspace-item-more { min-width: 0; max-width: 100%; }
.app-page .workspace-item-more > summary { cursor: pointer; min-height: 36px; padding: 8px 12px; font-size: 13px; font-weight: 600; border: 1px solid var(--border, #d8dce2); border-radius: 12px; width: max-content; max-width: 100%; margin-left: auto; }
.app-page .workspace-item-more[open] > summary { margin-bottom: 10px; }
.app-page .workspace-item-more > div { display: flex; gap: 8px; flex-wrap: wrap; }
.app-page .workspace-item-more > div > form { margin: 0; }
.app-page .workspace-settings-group > summary:focus-visible,
.app-page .workspace-item-more > summary:focus-visible { outline: 2px solid var(--accent, #006ee6); outline-offset: -3px; }
.app-page .daily-task-more[open] { grid-column: 2 / -1; width: 100%; }
.app-page .daily-task-more .daily-task-actions { justify-content: flex-end !important; }
@media (max-width: 760px) {
  .app-page .knowledge-extra-fields { grid-template-columns: minmax(0, 1fr); }
  .app-page .workspace-settings-group > summary { padding: 16px; }
  .app-page .daily-task-item { grid-template-columns: 32px minmax(0, 1fr) auto; }
  .app-page .daily-task-more:not([open]) { grid-column: 3; }
  .app-page .workspace-item-more > summary { min-height: 44px; }
}
@media (max-width: 600px) {
  .app-page .daily-task-more { justify-self: end; }
  .app-page .workspace-item-more > div { justify-content: flex-end; }
}

/* Keep the primary workspace first; auxiliary tools expand in the document flow. */
.app-page .document-summary-panel > .document-metrics { padding: 20px; margin: 0; }
.app-page .income-tax-year-label { margin: 0 0 18px; color: var(--muted); line-height: 1.6; overflow-wrap: anywhere; }
.app-page .income-tax-year-label strong { color: var(--ink); }
.app-page .income-tax-columns { grid-template-columns: minmax(0, 1fr); }
.app-page .income-tax-breakdown-panel > .workspace-context-details { margin: 0 20px 18px; }
.app-page .settings-hub-icon > .nav-symbol { display: block; width: 22px; height: 22px; }
.app-page .mobile-bottom-nav .nav-symbol { display: block; width: 20px; height: 20px; }
@media (max-width: 760px) {
  .app-page .document-summary-panel > .document-metrics { padding: 16px; }
  .app-page .income-tax-breakdown-panel > .workspace-context-details { margin-inline: 16px; }
}
.app-page .todo-table { min-width: 0; }
.app-page .todo-table .row-actions { flex-wrap: wrap; }
.app-page .preference-display-name > strong { font-size: 17px; line-height: 1.5; overflow-wrap: anywhere; }
.app-page .preference-display-name .preference-display-help a { white-space: normal; overflow-wrap: anywhere; }
