/* One set of records/inputs: a table on desktop and person cards on phones. */
.metric-label, .mobile-label, .mobile-year, .mobile-savebar { display: none; }

@media (max-width: 800px) {
  html { scroll-padding-top: 100px; scroll-padding-bottom: 130px; }
  .shell { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .topbar-inner { min-height: 64px; gap: 8px; }
  .brand { font-size: 13px; gap: 8px; min-width: 0; }
  .brand > span:last-child { min-width: 0; }
  .brand-mark { width: 32px; height: 32px; line-height: 32px; font-size: 22px; flex-shrink: 0; }
  .brand small { font-size: 10px; letter-spacing: 1px; }
  .topbar nav { gap: 2px; }
  .button { min-height: 44px; padding: 9px 12px; font-size: 14px; }
  .desktop-only, .desktop-label { display: none; }
  .mobile-label, .mobile-year { display: inline; }
  .page-heading { flex-direction: row; align-items: center; padding-top: 20px; padding-bottom: 20px; gap: 8px; }
  .page-heading .eyebrow, .page-heading .description { display: none; }
  .page-heading h1 { font-size: 24px; letter-spacing: -.6px; }
  .live-label { font-size: 12px; gap: 6px; padding: 0; }

  /* Only the date of the day being read sticks; history stays collapsible. */
  .day-card, .day-card.today {
    overflow: visible; border: 0; background: transparent; box-shadow: none;
    border-radius: 0; margin-bottom: 12px;
  }
  .day-card[open] { margin-bottom: 24px; }
  .day-card > summary {
    display: grid; grid-template-columns: minmax(0, 1fr) 18px;
    gap: 4px 10px; padding: 12px 14px; background: #fff;
    border: 1px solid var(--line); border-radius: 10px; min-height: 76px;
  }
  .day-card.today > summary { border-color: #bacbe1; }
  .day-card[open] > summary {
    position: sticky; top: 0; z-index: 20; margin-bottom: 12px;
    box-shadow: 0 4px 14px #20385f0b;
  }
  .day-title { grid-column: 1; grid-row: 1; align-items: flex-start; gap: 8px; min-width: 0; }
  .day-title > div { min-width: 0; }
  .day-year { display: none; }
  .day-date, .day-card.today .day-date { font-size: 19px; line-height: 1.4; letter-spacing: -.5px; }
  .weekday { display: block; font-size: 12px; margin: 2px 0 0; line-height: 1.5; }
  .day-tag { margin-top: 3px; padding: 2px 7px; font-size: 12px; }
  .day-meta { display: contents; font-size: 12px; }
  .day-meta .row-count { display: inline; grid-column: 1; grid-row: 2; }
  .day-meta .updated { grid-column: 1; grid-row: 2; justify-self: end; }
  .day-meta .chevron { grid-column: 2; grid-row: 1 / 3; align-self: center; justify-self: end; }

  /* Keep native table markup/headers; visually reflow each record into a card. */
  .table-scroll { overflow: visible; min-width: 0; }
  .report-table, .staff-table { display: block; min-width: 0; width: 100%; table-layout: auto; border-spacing: 0; }
  .report-table thead, .staff-table thead {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .report-table tbody, .staff-table tbody { display: grid; gap: 12px; }
  .report-table tbody tr, .report-table tbody tr:nth-child(even), .report-table tbody tr:hover {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 14px; padding: 16px; border: 1px solid var(--line);
    border-radius: 12px; background: #fff; min-width: 0;
  }
  .report-table td, .report-table td:first-child, .report-table td:last-child,
  .report-table tbody tr:nth-child(even) td:first-child,
  .edit-table td, .edit-table td:first-child, .edit-table td:last-child {
    display: block; position: static; width: auto; min-width: 0;
    padding: 0; border: 0; background: transparent; text-align: left;
    white-space: normal; color: var(--ink); font-weight: 400;
  }
  .report-table td.person-name {
    grid-column: 1 / -1; font-size: 18px; font-weight: 650; line-height: 1.5;
    color: var(--navy); padding-bottom: 10px; border-bottom: 1px solid #edf0f5;
    overflow-wrap: anywhere;
  }
  .metric-label { display: block; font-size: 13px; line-height: 1.6; color: #68788d; margin-bottom: 3px; overflow-wrap: anywhere; }
  .metric-value { display: block; font-size: 21px; line-height: 1.5; font-weight: 550; font-variant-numeric: tabular-nums; white-space: pre-wrap; overflow-wrap: anywhere; }
  .metric-value.blank-value { color: #9ba8b8; font-weight: 400; }
  .report-table td.metric-videos, .report-table td.metric-visits { border-top: 1px solid #edf0f5; padding-top: 10px; }
  .report-table td.metric-notes { grid-column: 1 / -1; border-top: 1px solid #edf0f5; padding-top: 10px; }
  .metric-notes .metric-value { font-size: 15px; font-weight: 400; line-height: 1.8; color: #495a70; }
  .metric-notes .blank-value { color: #9ba8b8; }
  .table-caption { padding: 12px 3px 0; border: 0; font-size: 12px; flex-wrap: wrap; gap: 3px 12px; }
  .table-caption span:last-child { display: inline; }
  .empty { padding: 32px 14px; line-height: 1.8; background: #fff; border-radius: 10px; }
  .footer { font-size: 12px; gap: 4px; margin-top: 30px; flex-direction: column; }
  .notice { font-size: 14px; overflow-wrap: anywhere; scroll-margin-top: 12px; }
  .notice a { display: inline-block; padding: 9px 0; min-height: 44px; }

  /* Editing cards share the desktop inputs, so rotating never loses changes. */
  body[data-page="manage"] { padding-bottom: calc(130px + env(safe-area-inset-bottom)); }
  .manage-heading { padding-top: 20px; padding-bottom: 14px; }
  .manage-heading > .save-status { display: none; }
  .manage-heading .description { display: block; font-size: 13px; margin-top: 6px; }
  .workspace-tabs { display: flex; gap: 0; margin-bottom: 18px; }
  .workspace-tab { flex: 1; min-width: 0; min-height: 48px; text-align: center; padding: 12px 4px; font-size: 15px; }
  .editor-toolbar { flex-wrap: nowrap; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
  .date-control { flex: 1; min-width: 0; gap: 8px; }
  .date-control label { display: none; }
  .date-control .field { flex: 1; width: 0; min-width: 130px; max-width: 100%; padding: 8px; min-height: 44px; font-size: 16px; }
  .date-control .button { padding: 8px 10px; min-width: 48px; }
  .date-control #history-tag { order: 3; }
  .toolbar-actions { flex-shrink: 0; width: auto; gap: 0; }
  .toolbar-actions .button { padding: 8px 10px; font-size: 13px; }
  #save-all { display: none; }
  .editor-heading { position: sticky; top: 0; z-index: 20; background: var(--bg); margin-bottom: 12px; padding: 10px 0; font-size: 16px; box-shadow: 0 4px 5px #f5f7fa; }
  .table-panel { border: 0; border-radius: 0; overflow: visible; background: transparent; }
  .cell-input, .field { font-size: 16px; min-height: 46px; }
  .cell-input { padding: 10px; text-align: left; border-radius: 7px; scroll-margin-top: 90px; scroll-margin-bottom: 130px; }
  .cell-notes { min-height: 94px; line-height: 1.65; resize: vertical; }
  .editor-help { font-size: 12px; line-height: 1.8; gap: 4px; margin: 14px 2px 0; }
  .mobile-savebar {
    display: flex; position: fixed; z-index: 40; bottom: var(--keyboard-offset, 0px);
    left: 0; right: 0; align-items: center; justify-content: space-between; gap: 12px;
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 20px #20385f08;
    padding: 10px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  .mobile-save-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  #mobile-edit-date { font-size: 12px; color: var(--muted); }
  .mobile-savebar .save-status { display: block; padding: 0; border: 0; background: transparent; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
  #mobile-save-detail { font-size: 13px; color: var(--red); text-decoration: underline; min-height: 44px; padding: 10px 0; }
  #mobile-save-all { flex-shrink: 0; min-height: 46px; padding: 10px 18px; }

  /* Roster management and audit history have no sideways scrolling either. */
  .section-title { align-items: flex-start; gap: 12px; margin-top: 20px; }
  .section-title h2 { font-size: 20px; }
  .section-title .quiet { font-size: 13px; line-height: 1.8; }
  .section-title .button { flex-shrink: 0; }
  .add-staff { display: grid; grid-template-columns: minmax(0, 1fr) 100px; gap: 12px; padding: 16px; border-radius: 12px; }
  .add-staff label, .add-staff label:first-child, .add-staff label:nth-child(2) { width: auto; min-width: 0; font-size: 13px; }
  .add-staff .button { grid-column: 1 / -1; width: 100%; }
  .staff-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
  .staff-table td, .staff-table td:nth-child(2), .staff-table td:nth-child(3), .staff-table td:last-child { width: auto; min-width: 0; padding: 0; border: 0; }
  .staff-table td:first-child, .staff-table td:last-child { grid-column: 1 / -1; }
  .staff-table .metric-label { margin-bottom: 6px; }
  .staff-table .field { min-width: 0; }
  .staff-enabled { display: flex; align-items: center; gap: 8px; min-height: 46px; font-size: 15px; }
  .staff-enabled input { width: 20px; height: 20px; margin: 0; }
  .staff-table td:last-child .button { width: 100%; }
  .audit-item summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 16px; font-size: 14px; overflow-wrap: anywhere; }
  .audit-item summary .quiet { grid-column: 1 / -1; margin: 0; width: auto; font-size: 12px; }
  .audit-changes { padding: 0 16px 16px; font-size: 14px; line-height: 1.8; }

  .login-layout { display: block; margin: 26px auto 32px; }
  .login-copy { margin-bottom: 20px; }
  .login-copy .eyebrow, .login-decoration { display: none; }
  .login-copy h1 { font-size: 27px; line-height: 1.5; }
  .login-copy .description { font-size: 14px; margin-top: 8px; }
  .login-card { padding: 22px; }
  .login-card h2 { font-size: 24px; }
  .login-card .quiet, .field-label { font-size: 14px; }
  .login-note { font-size: 12px; line-height: 1.8; }
}
