/* PUSK QA waves 2–3: responsive tables, tabs, filter sheets, typography helpers */

/* --- PUSK shell: off-canvas sidebar (PUSK-QA-003) --- */
@media (max-width: 768px) {
  body.pusk-today-shell .today-desktop.pusk-variant-a {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "top"
      "main" !important;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  body.pusk-today-shell .today-side {
    position: fixed;
    z-index: 120;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 88vw);
    max-width: 280px;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 32px rgba(20, 24, 28, 0.12);
    overflow-y: auto;
  }

  body.pusk-today-shell.pusk-nav-open .today-side {
    transform: translateX(0);
  }

  body.pusk-today-shell.pusk-nav-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(20, 24, 28, 0.45);
  }

  body.pusk-today-shell .pusk-nav-toggle {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-right: 4px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    cursor: pointer;
    flex: none;
  }

  body.pusk-today-shell .today-topbar {
    grid-area: top;
    min-width: 0;
    padding-left: 12px;
    padding-right: 12px;
  }

  body.pusk-today-shell .pusk-main-pane {
    grid-area: main;
    padding: 12px 12px 24px;
    min-width: 0;
    overflow-x: clip;
  }

  body.pusk-today-shell .add-sheet {
    width: calc(100vw - 16px) !important;
    left: 8px !important;
    right: 8px !important;
    top: 56px !important;
  }

  body.pusk-today-shell .add-sheet form {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (min-width: 769px) {
  body.pusk-today-shell .pusk-nav-toggle {
    display: none;
  }
}

/* --- Legacy mobile add sheet (PUSK-QA-001) --- */
@media (max-width: 480px) {
  .add-sheet {
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: calc(100vw - 24px);
    box-sizing: border-box;
  }

  .add-sheet form {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }

  .add-sheet form > div {
    min-width: 0 !important;
    width: 100% !important;
  }
}

/* --- Calendar list overflow (PUSK-QA-009) --- */
@media (max-width: 768px) {
  body.pusk-calendar-page .pusk-cal-center,
  body.pusk-calendar-page .pusk-cal-list,
  .ios-list,
  .ios-row {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  body.pusk-calendar-page main.pusk-main,
  body.pusk-today-page main.pusk-main {
    overflow-x: clip;
  }
}

/* --- Wide tables: scroll affordance (015, 021, 035, 038) --- */
.qa-table-scroll,
.pusk-events-table-wrap,
body.pusk-events-page .pusk-events-table-wrap,
.tbl-wrap.qa-scroll-hint,
table.zebra.qa-scroll-parent {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.qa-table-scroll::after,
.tbl-wrap.qa-scroll-hint::after {
  content: "Прокрутите таблицу →";
  display: block;
  font-size: 11px;
  color: var(--muted, #697680);
  padding: 4px 0 0;
}

@media (min-width: 1280px) {
  .qa-table-scroll::after,
  .tbl-wrap.qa-scroll-hint::after {
    display: none;
  }
}

/* --- Enforcement tabs (PUSK-QA-024) --- */
@media (max-width: 768px) {
  .tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 4px;
  }

  .tabs a {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

/* --- Mobile filter sheet pattern (027, 030, 034, 036) --- */
.qa-filter-sheet-trigger {
  display: none;
}

@media (max-width: 860px) {
  .qa-filter-sheet-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    margin-bottom: 10px;
    padding: 0 14px;
    border: 1px solid var(--line, #d8dfe3);
    border-radius: 10px;
    background: var(--card, #fff);
    font-weight: 600;
    cursor: pointer;
  }

  .qa-filter-panel-desktop {
    display: none;
  }

  .qa-filter-panel-desktop.is-sheet-open {
    display: block;
    position: fixed;
    z-index: 90;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 82vh;
    overflow: auto;
    padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
    background: var(--card, #fff);
    box-shadow: 0 -8px 28px rgba(20, 22, 26, 0.18);
  }

  body.qa-filter-sheet-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 85;
    background: rgba(20, 24, 28, 0.45);
  }
}

@media (min-width: 861px) {
  .qa-filter-panel-desktop {
    display: block;
  }
}

/* --- Economy mobile label gap (PUSK-QA-039) --- */
@media (max-width: 860px) {
  .economy-mob-row,
  .econ-kpi-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
  }

  .economy-mob-row .lbl,
  .econ-kpi-row .lbl {
    margin-right: 8px;
  }

  .economy-mob-row .val,
  .econ-kpi-row .val {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
}

/* --- Clients row density (PUSK-QA-028) --- */
table.zebra.clients-compact td {
  vertical-align: top;
  max-width: 280px;
}

table.zebra.clients-compact td .muted {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Engagement H1 (PUSK-QA-029) --- */
.engagement-title-h1 {
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  word-break: break-word;
  line-height: 1.2;
  max-width: 100%;
}

/* --- Money mobile headings (PUSK-QA-037) --- */
@media (max-width: 860px) {
  .money-mob .ios-subtitle,
  .money-mob h1.ios-title + h1 {
    display: none;
  }
}

/* --- Time empty state (PUSK-QA-042) --- */
.time-empty-state {
  margin: 12px 0 20px;
  padding: 16px;
  border: 1px dashed var(--line, #cbd3d7);
  border-radius: 10px;
  color: var(--muted, #697680);
}

.time-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.time-empty-actions .ghost {
  opacity: 0.85;
}

/* --- Contracts destructive spacing (PUSK-QA-031) --- */
.contracts-row-actions form[method="post"]:has(button.del) {
  margin-left: 8px;
}

.contracts-row-actions .del {
  font-size: 12px;
}
