/*
 * /microbuh workspace layout
 * Full-width desktop shell plus deliberate tablet/mobile reflow.
 * Loaded after the legacy page styles so the accounting behaviour stays intact.
 */

body.microbuh-page {
  overflow-x: hidden;
}

.microbuh-page .header {
  padding-inline: clamp(12px, 2vw, 32px);
}

.microbuh-page .header-inner,
.microbuh-page .hero-banner-inner,
.microbuh-page .main {
  width: 100%;
  max-width: none;
}

.microbuh-page .header-inner {
  gap: 12px;
}

.microbuh-page .hero-banner {
  padding: 30px clamp(12px, 2vw, 32px);
}

.microbuh-page .main {
  margin: 0 0 40px;
  padding: clamp(16px, 2vw, 32px) clamp(12px, 2vw, 32px);
}

.microbuh-page .nav {
  margin-inline: clamp(12px, 2vw, 32px);
}

.microbuh-page .mb-dashboard-scroll,
.microbuh-page .mb-table-scroll {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

.microbuh-page .mb-dashboard-table {
  min-width: 1160px;
}

.microbuh-page .mb-card-tabs,
.microbuh-page .cab-inner-tabs {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}

.microbuh-page .mb-card-tab,
.microbuh-page .cab-inner-tab {
  min-height: 44px;
}

.microbuh-page .modal-overlay,
.microbuh-page .cab-ovl,
.microbuh-page .cab-pre-overlay {
  padding: 16px;
}

.microbuh-page :where(input, select, textarea, button) {
  max-width: 100%;
}

.microbuh-page .mb-profile-card {
  border-top: 3px solid var(--blue-mid);
}

.microbuh-page .mb-profile-header {
  align-items: flex-start;
}

.microbuh-page .mb-profile-header p {
  margin-top: 4px;
  color: var(--text-sec);
  font-size: .82rem;
}

.microbuh-page .mb-profile-body {
  padding: 18px 20px;
}

.microbuh-page .mb-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.microbuh-page .mb-profile-field {
  min-width: 0;
}

.microbuh-page .mb-profile-field span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-sec);
  font-size: .76rem;
  font-weight: 700;
}

.microbuh-page .mb-profile-field :where(input, select) {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--dark);
  font: inherit;
  font-size: .86rem;
}

.microbuh-page .mb-profile-field input[readonly] {
  background: var(--light);
  color: var(--text-sec);
}

.microbuh-page .mb-profile-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
}

.microbuh-page .mb-profile-footer span,
.microbuh-page .mb-profile-error {
  color: var(--text-sec);
  font-size: .8rem;
}

.microbuh-page .mb-osv-context {
  margin: 0 20px 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--light);
}

.microbuh-page .mb-osv-context-ready {
  border-color: #A7F3D0;
  background: #ECFDF5;
}

.microbuh-page .mb-osv-context-review {
  border-color: #FDE68A;
  background: #FFFBEB;
}

.microbuh-page .mb-osv-context-head,
.microbuh-page .mb-osv-context-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.microbuh-page .mb-osv-context-head {
  justify-content: space-between;
  font-size: .82rem;
}

.microbuh-page .mb-osv-context-pills {
  margin-top: 9px;
}

.microbuh-page .mb-osv-context-pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .78);
  font-size: .75rem;
}

.microbuh-page .mb-osv-context-basis,
.microbuh-page .mb-osv-context-warning {
  margin-top: 8px;
  color: var(--text-sec);
  font-size: .76rem;
}

.microbuh-page .mb-osv-context-warning {
  color: #92400E;
  font-weight: 600;
}

@media (max-width: 1180px) {
  .microbuh-page .nav {
    gap: 2px;
    margin-inline: 10px;
  }

  .microbuh-page .nav a {
    padding-inline: 10px;
  }

  .microbuh-page .user-name {
    display: none;
  }

  .microbuh-page .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .microbuh-page .header {
    padding-inline: 12px;
  }

  .microbuh-page .header-inner {
    height: 56px;
  }

  .microbuh-page .hamburger {
    order: 2;
    display: inline-grid;
    width: 44px;
    height: 44px;
    place-items: center;
  }

  .microbuh-page .nav {
    top: 56px;
    max-height: calc(100dvh - 56px);
    overflow-y: auto;
    margin: 0;
  }

  .microbuh-page .nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .microbuh-page .header-right {
    order: 3;
    margin-left: 0;
  }

  .microbuh-page .hero-banner {
    padding-block: 22px;
  }

  .microbuh-page .hero-banner h1 {
    font-size: 1.45rem;
  }

  .microbuh-page .main {
    padding: 18px 14px;
  }

  .microbuh-page .card-header {
    align-items: stretch;
  }

  .microbuh-page #mb-search {
    width: min(100%, 360px) !important;
    min-height: 44px;
  }

  .microbuh-page .mb-osv-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .microbuh-page .gen-row2,
  .microbuh-page .cab-gen-row2 {
    grid-template-columns: 1fr;
  }

  .microbuh-page .mb-profile-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .microbuh-page .cab-chead,
  .microbuh-page .cab-toolbar,
  .microbuh-page .cab-draft {
    align-items: stretch;
  }

  .microbuh-page .cab-chk {
    margin-left: 0;
  }

  .microbuh-page .cab-btn,
  .microbuh-page .btn,
  .microbuh-page .btn-logout,
  .microbuh-page .btn-ghost,
  .microbuh-page .btn-primary-sm {
    min-height: 44px;
  }
}

@media (max-width: 700px) {
  .microbuh-page .logo-text {
    font-size: .78rem;
  }

  .microbuh-page .header-right .avatar,
  .microbuh-page .header-right .user-name {
    display: none;
  }

  .microbuh-page .btn-logout,
  .microbuh-page .header-right .btn-ghost,
  .microbuh-page .header-right .btn-primary-sm {
    padding-inline: 10px;
  }

  .microbuh-page .stats-grid {
    gap: 8px;
  }

  .microbuh-page .stat-card {
    min-width: 0;
    padding: 14px;
  }

  .microbuh-page .stat-card .label {
    font-size: .7rem;
  }

  .microbuh-page .stat-card .value {
    font-size: 1.35rem;
  }

  .microbuh-page .card-header {
    flex-direction: column;
  }

  .microbuh-page #mb-search {
    width: 100% !important;
  }

  /* Client list becomes a readable card list instead of a 12-column strip. */
  .microbuh-page .mb-dashboard-scroll {
    overflow: visible;
    padding: 10px;
    background: var(--light);
  }

  .microbuh-page .mb-dashboard-table,
  .microbuh-page .mb-dashboard-table tbody,
  .microbuh-page .mb-dashboard-table tr,
  .microbuh-page .mb-dashboard-table td {
    display: block;
    width: 100% !important;
    min-width: 0;
  }

  .microbuh-page .mb-dashboard-table {
    min-width: 0;
  }

  .microbuh-page .mb-dashboard-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .microbuh-page .mb-dashboard-table tbody {
    display: grid;
    gap: 12px;
  }

  .microbuh-page .mb-dashboard-table tbody tr {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--white);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
  }

  .microbuh-page .mb-dashboard-table tbody td {
    display: grid;
    grid-template-columns: minmax(92px, 35%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 9px 12px;
    border-top: 1px solid var(--border);
    overflow: visible;
    text-align: left !important;
  }

  .microbuh-page .mb-dashboard-table tbody td:first-child {
    border-top: 0;
  }

  .microbuh-page .mb-dashboard-table tbody td::before {
    content: attr(data-label);
    color: var(--text-sec);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
  }

  .microbuh-page .mb-dashboard-table tbody td[data-label="Клиент"] {
    background: var(--blue-pale);
  }

  .microbuh-page .mb-dashboard-table tbody td[data-label="Действия"] .btn {
    width: 100%;
    justify-content: center;
    font-size: .82rem;
  }

  .microbuh-page .mb-dashboard-table tbody td[data-label="Действия"] .btn::after {
    content: none;
  }

  .microbuh-page .mb-card-tabs {
    border-radius: 10px;
    padding-inline: 4px;
  }

  .microbuh-page .mb-card-tab {
    padding-inline: 14px;
  }

  .microbuh-page .mb-osv-summary,
  .microbuh-page .osv-totals-bar {
    grid-template-columns: 1fr;
  }

  .microbuh-page .osv-totals-cell {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .microbuh-page .osv-page-toolbar {
    align-items: stretch;
  }

  .microbuh-page .osv-page-toolbar .osv-sep {
    display: none;
  }

  .microbuh-page .osv-page-toolbar input,
  .microbuh-page .osv-page-toolbar select,
  .microbuh-page .osv-page-toolbar button {
    min-height: 44px;
  }

  .microbuh-page .modal-overlay,
  .microbuh-page .cab-ovl,
  .microbuh-page .cab-pre-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .microbuh-page .modal,
  .microbuh-page .gen-modal,
  .microbuh-page .cab-modal,
  .microbuh-page .cab-pre-modal {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
  }

  .microbuh-page .modal-footer,
  .microbuh-page .cab-mf {
    position: sticky;
    bottom: 0;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    background: var(--white);
  }

  .microbuh-page .modal-footer .btn,
  .microbuh-page .cab-mf .cab-btn {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .microbuh-page .logo-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    max-width: 40px;
    max-height: 40px;
  }

  .microbuh-page .hero-banner p {
    font-size: .84rem;
  }

  .microbuh-page .main {
    padding-inline: 8px;
  }

  .microbuh-page .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .microbuh-page *,
  .microbuh-page *::before,
  .microbuh-page *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Отчёты клиента: единый реестр готовых и ещё недоступных форм. */
.mb-report-catalog-card {
  overflow: hidden;
}

.mb-report-catalog-header {
  align-items: center;
  gap: 20px;
}

.mb-report-catalog-header p {
  margin: 5px 0 0;
  color: var(--text-sec);
  font-size: .84rem;
}

.mb-report-filter {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.mb-report-filter-btn {
  border: 0;
  border-radius: 7px;
  padding: 7px 11px;
  background: transparent;
  color: var(--text-sec);
  font: inherit;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
}

.mb-report-filter-btn.active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 1px 5px rgba(15, 23, 42, .1);
}

.mb-report-catalog-summary {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text-sec);
  font-size: .82rem;
}

.mb-report-catalog-summary strong { color: var(--text); }
.mb-report-catalog-summary span { color: #9a6700; }

.mb-report-drafts-section {
  margin: 16px 20px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #f8fafc;
}

.mb-report-drafts-heading,
.mb-report-draft-row,
.mb-archive-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mb-report-drafts-heading { justify-content: space-between; }
.mb-report-drafts-heading h3 { margin: 0; font-size: .9rem; }
.mb-report-drafts-heading p { margin: 3px 0 0; color: var(--text-sec); font-size: .75rem; }
.mb-report-drafts { display: grid; gap: 8px; margin-top: 10px; }

.mb-report-draft-row {
  min-width: 0;
  justify-content: space-between;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: .78rem;
}

.mb-report-draft-row > div { min-width: 0; flex: 1 1 auto; }
.mb-report-draft-row strong,
.mb-report-draft-row span { display: block; }
.mb-report-draft-row > div span { margin-top: 2px; color: var(--text-sec); }
.mb-report-draft-status { flex: 0 0 auto; color: #475569; font-weight: 700; }
.mb-report-draft-link { flex: 0 0 auto; color: var(--text-sec); }
.mb-report-drafts-empty { padding: 10px 0 2px; color: var(--text-sec); font-size: .78rem; }
.mb-archive-actions { justify-content: center; flex-wrap: wrap; }
.mb-archive-actions .btn { white-space: nowrap; }

.mb-report-catalog {
  display: grid;
  gap: 22px;
  padding: 20px;
}

.mb-report-group h3 {
  margin: 0 0 10px;
  font-size: .92rem;
}

.mb-report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 12px;
}

.mb-report-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 10px;
  padding: 15px;
  border: 1px solid var(--border);
  border-left: 4px solid #94a3b8;
  border-radius: 11px;
  background: #fff;
}

.mb-report-card.is-ready { border-left-color: #22a06b; }
.mb-report-card.is-warning { border-left-color: #d97706; }
.mb-report-card.is-unavailable { border-left-color: #dc2626; background: #fafafa; }
.mb-report-card.is-reference { border-left-color: #64748b; }

.mb-report-card-top,
.mb-report-card-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mb-report-card h4 {
  margin: 3px 0 0;
  font-size: .9rem;
  line-height: 1.35;
}

.mb-report-knd {
  color: var(--text-sec);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.mb-report-status {
  flex: 0 0 auto;
  max-width: 150px;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-sec);
  font-size: .68rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.mb-report-reason {
  color: #16734b;
  font-size: .75rem;
  font-weight: 700;
}

.mb-report-card p {
  flex: 1 1 auto;
  margin: 0;
  color: var(--text-sec);
  font-size: .78rem;
  line-height: 1.45;
}

.mb-report-card-footer { align-items: center; }
.mb-report-formats { display: flex; flex-wrap: wrap; gap: 5px; }
.mb-report-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.mb-report-format {
  padding: 3px 6px;
  border-radius: 5px;
  background: #eef2ff;
  color: #3447a8;
  font-size: .65rem;
  font-weight: 800;
}

.mb-report-empty {
  padding: 32px 20px;
  color: var(--text-sec);
  text-align: center;
}

.mb-report-catalog-notice {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #fff8e6;
  color: #725500;
  font-size: .77rem;
  line-height: 1.45;
}

@media (max-width: 720px) {
  .mb-report-catalog-header,
  .mb-report-card-top,
  .mb-report-card-footer {
    align-items: stretch;
    flex-direction: column;
  }
  .mb-report-filter { width: 100%; }
  .mb-report-filter-btn { flex: 1 1 50%; }
  .mb-report-status { align-self: flex-start; max-width: none; }
  .mb-report-card-footer .btn { width: 100%; text-align: center; }
  .mb-report-actions { width: 100%; }
  .mb-report-drafts-section { margin-inline: 12px; }
  .mb-report-draft-row { align-items: stretch; flex-direction: column; }
  .mb-report-draft-row .btn { width: 100%; }
}
