#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.app-header {
  height: auto;
  min-height: 64px;
  padding: 8px 16px 4px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  background-color: var(--header-bg, var(--panel-bg));
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border-bottom: 1px solid var(--header-border, var(--border));
  z-index: 20;
  position: relative;
  box-sizing: border-box;
}
.app-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--tape-stripe);
  opacity: var(--tape-opacity);
  pointer-events: none;
}

.header-back-slot {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.header-back-slot:empty {
  display: none;
}

.header-back-btn {
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 24px;
  background: var(--btn2-bg);
  border: 1.5px solid var(--btn2-border);
  box-shadow: var(--btn2-shadow);
  color: var(--hero-acc, var(--btn2-text));
  line-height: 0;
  cursor: pointer;
  user-select: none;
}
.header-back-btn svg {
  display: block;
}
.header-back-btn:active {
  background: var(--btn2-bg-active);
  transform: scale(0.95);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.is-hidden-badge {
  display: none !important;
}

.header-row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 8px;
  row-gap: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.header-section-icon {
  display: none;
}

.header-main-title {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.3px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.app-header > h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  flex: 1;
  min-width: 0;
}

/* Строка-пояснение под шапкой: часть контента, без рамки и подложки */
.screen-hint-wrap {
  flex-shrink: 0;
  overflow: hidden;
  max-height: 160px;
  padding: 8px 16px 0;
  box-sizing: border-box;
  transition: max-height 0.2s ease, padding 0.2s ease, opacity 0.2s ease;
}
.screen-hint-wrap.is-empty {
  display: none;
}
.screen-hint-wrap.collapsed {
  max-height: 0;
  padding-top: 0;
  opacity: 0;
}
.screen-hint {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.4;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px calc(148px + env(safe-area-inset-bottom, 0px));
}
.content-no-sticky {
  padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)) !important;
}

/* Нижняя панель навигации */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 640px;
  margin: 0 auto;
  min-height: 64px;
  padding: 0 4px env(safe-area-inset-bottom, 0px);
  display: flex;
  background-color: var(--panel-bg);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border-top: 1px solid var(--border);
  z-index: 999;
  pointer-events: auto;
}
.nav-btn {
  flex: 1;
  min-width: 0;
  min-height: var(--btn-min-h, 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 2px;
  gap: 3px;
  position: relative;
}
.nav-btn .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  position: relative;
}
.nav-btn .label {
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}
.nav-btn.active {
  color: var(--sec-color);
}
.nav-btn.active .label {
  font-weight: 700;
}
/* Активный пункт меню: медная черта сверху */
.nav-btn:not(.nav-btn-plus).active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 28px;
  height: 3px;
  margin-left: -14px;
  border-radius: 0 0 3px 3px;
  background: var(--copper, var(--accent-fill));
}

.nav-btn-plus {
  padding: 0 4px;
}
.nav-plus-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--btn1-bg, var(--accent-fill));
  color: var(--accent-on);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  transform: translateY(-10px);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.nav-btn-plus:active .nav-plus-circle {
  transform: translateY(-10px) scale(0.96);
}
.nav-btn-plus.active .nav-plus-circle {
  box-shadow: 0 0 0 3px var(--accent-border), 0 6px 16px rgba(0, 0, 0, 0.18);
}

/* Значок «черн.» на правом верхнем краю круга «+» */
.nav-draft-dot {
  position: absolute;
  top: -8px;
  left: calc(50% + 10px);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  background: var(--status-draft-bg);
  color: var(--status-draft-text);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}

body.in-estimate .bottom-nav {
  display: none;
}
body.in-estimate .content {
  padding-bottom: calc(116px + env(safe-area-inset-bottom, 0px));
}
body.in-estimate .content-no-sticky {
  padding-bottom: calc(36px + env(safe-area-inset-bottom, 0px)) !important;
}

.sticky-total-bar {
  position: fixed;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
  max-width: 640px;
  margin: 0 auto;
  height: auto;
  min-height: 64px;
  background-color: var(--panel-bg);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
  z-index: 900;
  box-sizing: border-box;
}
body.in-estimate .sticky-total-bar {
  bottom: 0;
  height: auto;
  min-height: 76px;
  max-height: none;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
}
.sticky-total-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}
.sticky-total-label {
  font-size: 17px;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
}
.sticky-total-sum {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
#final-total-display {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .app-header,
  .bottom-nav,
  .sticky-total-bar {
    background-color: var(--surface-2);
  }
}
/* Путь «Главная › Сметы» над заголовком */
.header-crumb {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  color: var(--text-muted);
  min-width: 0;
}
.header-crumb[hidden] { display: none; }
.header-crumb-home {
  background: none;
  border: none;
  padding: 0;
  min-height: 24px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-ink);
  cursor: pointer;
}
.header-crumb-here {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-row-title .header-main-title { flex: 1 1 auto; min-width: 0; }
