.app-m4 {
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}

.m4-topbar {
  align-items: center;
}

.app-view {
  display: none;
}

.app-view.active {
  display: block;
}

.hero-card,
.section-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 18px;
  padding: 15px;
  margin-bottom: 12px;
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #111;
  color: #fff;
}

.hero-card h2 {
  font-size: 24px;
  line-height: 1.05;
}

.hero-card p:not(.eyebrow) {
  margin: 7px 0 0;
  color: #c9c9c9;
  font-size: 12px;
  line-height: 1.35;
}

.hero-card .eyebrow {
  color: #aaa;
}

.hero-scan {
  flex: 0 0 auto;
  background: #fff;
  color: #111;
  padding-inline: 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 12px;
}

.kpi-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 16px;
  padding: 13px;
}

.kpi-card span,
.kpi-card small {
  display: block;
  color: #777;
  font-size: 10px;
}

.kpi-card strong {
  display: block;
  margin: 4px 0 2px;
  font-size: 28px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head h2 {
  font-size: 19px;
}

.section-head .eyebrow {
  margin-bottom: 3px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.quick-action {
  min-height: 78px;
  padding: 12px;
  text-align: left;
  background: #f3f3f3;
  color: #111;
  border: 1px solid #e7e7e7;
}

.quick-action b,
.quick-action span {
  display: block;
}

.quick-action b {
  font-size: 14px;
}

.quick-action span {
  margin-top: 4px;
  color: #777;
  font-size: 10px;
  line-height: 1.25;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #efefef;
  color: #444;
  font-size: 11px;
  font-weight: 800;
}

.m4-list {
  border-top: 1px solid #ececec;
}

.m4-empty {
  padding: 18px 2px 10px;
  color: #888;
  font-size: 12px;
}

.m4-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 2px;
  border: 0;
  border-bottom: 1px solid #ececec;
  border-radius: 0;
  background: transparent;
  color: #111;
  text-align: left;
}

.m4-row:last-child {
  border-bottom: 0;
}

.m4-row-main {
  min-width: 0;
  flex: 1;
}

.m4-row-main b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  line-height: 1.25;
}

.m4-row-main small {
  display: block;
  margin-top: 4px;
  color: #777;
  font-size: 10px;
  line-height: 1.3;
}

.m4-row-side {
  flex: 0 0 auto;
  text-align: right;
}

.m4-row-side b,
.m4-row-side small {
  display: block;
}

.m4-row-side b {
  font-size: 13px;
}

.m4-row-side small {
  margin-top: 3px;
  color: #888;
  font-size: 9px;
}

.catalog-card {
  padding-bottom: 8px;
}

.doc-filter-row {
  margin-bottom: 8px;
}

#documentSearch {
  width: 100%;
  border: 1px solid #d9d9d9;
  background: #fafafa;
  color: #111;
  border-radius: 13px;
  padding: 13px 14px;
  outline: none;
  font-size: 16px;
}

#documentSearch:focus {
  border-color: #111;
  background: #fff;
}

.document-card {
  padding: 13px 2px;
  border-bottom: 1px solid #ececec;
}

.document-card:last-child {
  border-bottom: 0;
}

.document-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.document-number {
  font-size: 14px;
  font-weight: 900;
}

.document-meta {
  margin-top: 4px;
  color: #777;
  font-size: 10px;
  line-height: 1.35;
}

.document-items {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px dashed #e2e2e2;
}

.document-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  font-size: 11px;
}

.document-item span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-item span:last-child {
  flex: 0 0 auto;
  color: #666;
  font-variant-numeric: tabular-nums;
}

.m4-shared-result {
  margin-top: 12px;
}

.bottom-nav {
  position: fixed;
  z-index: 8000;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 7px max(8px, env(safe-area-inset-left)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  background: rgba(255,255,255,.96);
  border-top: 1px solid #dedede;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 54px;
  padding: 5px 3px;
  border-radius: 12px;
  background: transparent;
  color: #777;
  font-size: 10px;
}

.nav-item.active {
  background: #111;
  color: #fff;
}

.nav-icon {
  font-size: 20px;
  line-height: 1;
}

@media (min-width: 640px) {
  .kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 390px) {
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .quick-action {
    min-height: 58px;
  }
}
