/*
 * Native iOS safe-area contract.
 * AppWebView injects --app-native-safe-top / --app-native-safe-bottom on every
 * navigation. The env() fallbacks keep the same pages usable in Safari.
 */
:root {
  --app-native-safe-top: 0px;
  --app-native-safe-bottom: 0px;
  --app-safe-top: max(env(safe-area-inset-top, 0px), var(--app-native-safe-top, 0px));
  --app-safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--app-native-safe-bottom, 0px));
  --app-nav-height: 62px;
  --app-nav-side: 16px;
  --app-nav-gap: 8px;
  --app-nav-bottom: calc(var(--app-safe-bottom) + var(--app-nav-gap));
  --app-nav-clearance: calc(var(--app-nav-height) + var(--app-nav-bottom) + 18px);
  --bottom-nav-height: var(--app-nav-height);
  --bottom-nav-side: var(--app-nav-side);
  --bottom-nav-gap: var(--app-nav-gap);
  --bottom-nav-bottom: var(--app-nav-bottom);
  --bottom-nav-clearance: var(--app-nav-clearance);
}

html.app-safe-shell {
  min-height: 100%;
  background: #f5f6fa;
}

/* Home: keep the status area solid blue and move the search artwork below it. */
html.app-safe-shell body.page-shouye {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: #f6f7fb !important;
  background-image: linear-gradient(var(--header-blue), var(--header-blue)) !important;
  background-repeat: no-repeat !important;
  background-size: 100% var(--app-safe-top) !important;
}
html.app-safe-shell body.page-shouye .search-bar-wrapper {
  padding-top: var(--app-safe-top) !important;
  background-color: var(--header-blue) !important;
  background-image: none !important;
  background-size: auto !important;
}
html.app-safe-shell body.page-shouye .home-page {
  padding-top: calc(13.003115% + var(--app-safe-top) + 1px) !important;
  padding-bottom: calc(var(--app-nav-height) + var(--app-nav-bottom) + 24px) !important;
}
html.app-safe-shell body.page-shouye .search-panel {
  padding-top: calc(14px + var(--app-safe-top)) !important;
}

/* Income details form. */
html.app-safe-shell body.page-shuiming .header {
  padding-top: calc(12px + var(--app-safe-top)) !important;
  box-sizing: border-box !important;
}
html.app-safe-shell body.page-shuiming .content {
  padding-top: calc(44px + var(--app-safe-top)) !important;
}

/* Income details result: reserve the status bar above the fixed header/summary. */
html.app-safe-shell body.page-shuiming-result .header {
  height: calc(48px + var(--app-safe-top)) !important;
  padding-top: var(--app-safe-top) !important;
  box-sizing: border-box !important;
}
html.app-safe-shell body.page-shuiming-result .header .back-btn,
html.app-safe-shell body.page-shuiming-result .header .header-right {
  top: var(--app-safe-top) !important;
  height: 48px !important;
}
html.app-safe-shell body.page-shuiming-result .summary {
  top: calc(48px + var(--app-safe-top)) !important;
}
html.app-safe-shell body.page-shuiming-result .list {
  margin-top: calc(165px + var(--app-safe-top)) !important;
}

/* Other tab headers use the same native inset instead of a zero env() value. */
html.app-safe-shell body.page-daiban .daiban-header-builtin,
html.app-safe-shell body.page-bancha .bancha-header-builtin {
  padding-top: calc(10px + var(--app-safe-top)) !important;
}
html.app-safe-shell body.page-message .message-header-toolbar {
  padding-top: calc(12px + var(--app-safe-top)) !important;
}

/*
 * One stable bottom navigation geometry for every tab. This intentionally
 * overrides the device-class rules in nav.css, which can switch after load and
 * make the bar jump between full-width and floating layouts.
 */
html body .bottom-nav,
html body > .bottom-nav,
html body.page-shouye > .bottom-nav,
html body.page-daiban > .bottom-nav,
html body.page-bancha > .bottom-nav,
html body.page-message > .bottom-nav,
html body.page-mine > .bottom-nav,
html body .bottom-nav.ios-device {
  position: fixed !important;
  top: auto !important;
  right: var(--app-nav-side) !important;
  bottom: var(--app-nav-bottom) !important;
  left: var(--app-nav-side) !important;
  z-index: 10050 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-around !important;
  width: auto !important;
  max-width: none !important;
  height: var(--app-nav-height) !important;
  min-height: var(--app-nav-height) !important;
  max-height: var(--app-nav-height) !important;
  margin: 0 !important;
  padding: 8px 0 !important;
  border: 1px solid rgba(0, 0, 0, .04) !important;
  border-radius: 32px !important;
  background: rgba(255, 255, 255, .97) !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .08) !important;
  box-sizing: border-box !important;
  overflow: visible !important;
  transform: none !important;
  animation: none !important;
  -webkit-backdrop-filter: blur(8px) !important;
  backdrop-filter: blur(8px) !important;
}
html body .bottom-nav::before,
html body .bottom-nav::after,
html body .bottom-nav.ios-device::before,
html body .bottom-nav.ios-device::after {
  content: none !important;
  display: none !important;
}
html body .bottom-nav .nav-item {
  display: flex !important;
  flex: 1 1 0 !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  height: 100% !important;
  padding: 0 2px !important;
  color: #999 !important;
  font-size: 12px !important;
  line-height: 1.15 !important;
}
html body .bottom-nav .nav-item.active,
html body .bottom-nav .nav-item.active .nav-text,
html body .bottom-nav.ios-device .nav-item.active .nav-text {
  color: #1e6fff !important;
}
html body .bottom-nav .nav-icon {
  width: 24px !important;
  height: 24px !important;
  margin-bottom: 2px !important;
}
html body .bottom-nav .nav-icon img {
  width: 22px !important;
  height: 22px !important;
}
html body .bottom-nav .nav-text {
  height: 14px !important;
  color: inherit !important;
  font-size: 12px !important;
  line-height: 14px !important;
}

/* Keep the tab content and toasts clear of the stable floating nav. */
html body.page-daiban .daiban-content,
html body.page-bancha .bancha-content,
html body.page-message .message-list,
html body.page-mine .mine-e1-footer {
  padding-bottom: var(--app-nav-clearance) !important;
}
html body .toast {
  bottom: calc(var(--app-nav-clearance) + 4px) !important;
}

/* Reference-styled account pages: preserve their layouts while applying the
 * real iOS status-bar and home-indicator insets. */
html.app-safe-shell body.page-personal-info > .header,
html.app-safe-shell body.page-gerenxinxi > .header,
html.app-safe-shell body.page-renzhi > .header,
html.app-safe-shell body.page-yhk > .header,
html.app-safe-shell body.page-yhk-add > .header,
html.app-safe-shell body.page-tax-benefit > .header,
html.app-safe-shell body.page-other-id > .header {
  padding-top: calc(14px + var(--app-safe-top)) !important;
  box-sizing: border-box !important;
}
html.app-safe-shell body.page-yhk {
  padding-bottom: var(--app-safe-bottom) !important;
}
html.app-safe-shell body.page-yhk .footer,
html.app-safe-shell body.page-yhk-add .footer,
html.app-safe-shell body.page-tax-benefit .footer,
html.app-safe-shell body.page-other-id .footer {
  padding-bottom: calc(12px + var(--app-safe-bottom)) !important;
}

/* Annual declaration flow safe-area overrides. */
html.app-safe-shell body.page-zonghe .footer-link {
  padding-bottom: calc(28px + var(--app-safe-bottom)) !important;
}
html.app-safe-shell body.page-shenbao-jilu > .header,
html.app-safe-shell body.page-shenbao-detail .header {
  padding-top: calc(14px + var(--app-safe-top)) !important;
  box-sizing: border-box !important;
}
html.app-safe-shell body.page-shenbao-jilu #tabContent {
  padding-bottom: var(--app-safe-bottom) !important;
}
html.app-safe-shell body.page-shenbao-detail .detail-form-view {
  padding-bottom: calc(62px + var(--app-safe-bottom)) !important;
}
html.app-safe-shell body.page-shenbao-detail .footer-bar button {
  padding-bottom: calc(14px + var(--app-safe-bottom)) !important;
}

/* Tax-record issuance page. */
html.app-safe-shell body.page-najilu > .header {
  padding-top: var(--app-safe-top) !important;
}
html.app-safe-shell body.page-najilu .page-content {
  padding-bottom: calc(40px + var(--app-safe-bottom)) !important;
}
html.app-safe-shell body.page-najilu .preview-footer {
  padding-bottom: calc(12px + var(--app-safe-bottom)) !important;
}
html.app-safe-shell body.page-najilu .mp-sheet {
  padding-bottom: var(--app-safe-bottom) !important;
}
