/**
 * Nanban desk UX 2026 — stay-on-tab + scroll + shell polish
 * Loads last among app CSS so it wins specificity fights.
 */

/* Stable document scroll after login */
html.nanban-authed,
html.nanban-authed body.nanban-pro-app {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
}

@media (prefers-reduced-motion: reduce) {
  html.nanban-authed {
    scroll-behavior: auto;
  }
  body.nanban-pro-app #nbAppMain > .section-content.active-section {
    animation: none !important;
  }
}

/* Only one menu panel visible */
body.nanban-pro-app #nbAppMain > .section-content:not(.active-section) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

body.nanban-pro-app #nbAppMain > .section-content.active-section {
  display: block !important;
  visibility: visible !important;
  pointer-events: auto !important;
  height: auto !important;
  min-height: min-content !important;
  overflow: visible !important;
  animation: nbDeskPaneIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes nbDeskPaneIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header — clearer glass strip */
body.nanban-pro-app #mainApp .top-bar.nb-app-header {
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset, 0 8px 24px rgba(15, 23, 42, 0.04);
}

body.nanban-pro-app #mainApp .nb-top-logo {
  letter-spacing: 0.04em;
  font-weight: 800;
}

body.nanban-pro-app #mainApp .nb-top-logo span {
  color: #dc2626;
}

body.nanban-pro-app.esevai-mode #mainApp .nb-top-logo span {
  color: #059669;
}

/* Mode switch — cleaner pill */
body.nanban-pro-app #mainApp .nb-pill-toggle {
  background: rgba(15, 23, 42, 0.06);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

body.nanban-pro-app #mainApp .nb-pill-toggle .btn-biz {
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  padding: 7px 14px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

body.nanban-pro-app #mainApp .nb-pill-toggle .btn-biz.active {
  background: #0f172a;
  color: #fff;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18);
}

body.nanban-pro-app.esevai-mode #mainApp .nb-pill-toggle .btn-biz.active {
  background: #047857;
}

/* Sidebar nav — denser, clearer active */
@media (min-width: 769px) {
  body.nanban-pro-app #mainApp .nb-app-sidebar,
  body.nanban-pro-app #mainApp .tabs-wrapper.nb-pro-dock {
    position: sticky !important;
    top: 0 !important;
    align-self: flex-start !important;
    max-height: 100dvh !important;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
    border-right: 1px solid rgba(15, 23, 42, 0.08) !important;
  }
}

body.nanban-pro-app #mainApp .nb-nav-item {
  border-radius: 12px !important;
  margin: 1px 0 !important;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease !important;
}

body.nanban-pro-app #mainApp .nb-nav-item:hover {
  background: rgba(15, 23, 42, 0.05) !important;
  transform: translateX(2px);
}

body.nanban-pro-app #mainApp .nb-nav-item.active {
  background: #0f172a !important;
  color: #fff !important;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16) !important;
}

body.nanban-pro-app #mainApp .nb-nav-item.active .nb-nav-ico,
body.nanban-pro-app #mainApp .nb-nav-item.active .nb-nav-en,
body.nanban-pro-app #mainApp .nb-nav-item.active .nb-nav-ta {
  color: #fff !important;
}

body.nanban-pro-app.esevai-mode #mainApp .nb-nav-item.active {
  background: #047857 !important;
  box-shadow: 0 10px 28px rgba(4, 120, 87, 0.22) !important;
}

body.nanban-pro-app #mainApp .nb-nav-ico {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

body.nanban-pro-app #mainApp .nb-nav-ico svg {
  width: 18px;
  height: 18px;
}

/* Main canvas */
body.nanban-pro-app #mainApp #nbAppMain.nb-app-main {
  background:
    radial-gradient(ellipse 70% 40% at 0% 0%, rgba(220, 38, 38, 0.04), transparent 55%),
    radial-gradient(ellipse 50% 35% at 100% 0%, rgba(15, 23, 42, 0.03), transparent 50%),
    #f4f6f8;
}

body.nanban-pro-app.esevai-mode #mainApp #nbAppMain.nb-app-main {
  background:
    radial-gradient(ellipse 70% 40% at 100% 0%, rgba(16, 185, 129, 0.08), transparent 55%),
    #f0fdf6;
}

/* Dashboard KPI cards */
body.nanban-pro-app #dashSection .metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

body.nanban-pro-app #dashSection .metric-card {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 12px 28px rgba(15, 23, 42, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

body.nanban-pro-app #dashSection .metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
}

body.nanban-pro-app #dashSection .metric-card h3 {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #334155;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

body.nanban-pro-app #dashSection .nb-dash-ico {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.05);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.nanban-pro-app #dashSection .nb-dash-ico svg {
  width: 15px;
  height: 15px;
}

body.nanban-pro-app #dashSection .stat-val {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Desktop scroll: body owns the wheel */
@media (min-width: 769px) {
  html.nanban-authed,
  html.nanban-authed body.nanban-pro-app {
    overflow-y: auto !important;
    height: auto !important;
    max-height: none !important;
  }

  body.nanban-pro-app #mainApp #nbAppBody,
  body.nanban-pro-app #mainApp #nbAppMain {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
  }
}

/* Mobile: one finger scroll on main */
@media (max-width: 768px) {
  body.nanban-pro-app #mainApp #nbAppMain {
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain;
    touch-action: pan-y !important;
  }
}
