/* R13 additive runtime styles.
 *
 * These rules are PURELY ADDITIVE: they must never override a declaration that
 * design-r3.css already defines, so the running product stays pixel-aligned
 * with the Owner-approved Admin Design R3 authority. Earlier revisions
 * re-declared .statebox/.skeleton/.actions/#result/button[disabled], which
 * silently shifted the rendered layout away from the authority; those
 * overrides were removed in R13.
 */

#result.ok { background: var(--light); color: #005f62; }
#result.err { background: var(--errorbg); color: var(--error); }

.qa-console { margin-top: 18px; }
.qa-console h3 { font-size: 15px; margin: 18px 0 8px; }
.qa-console table { font-size: 13px; }
.qa-console table th { width: 210px; text-align: left; }
.qa-console code { font: 12px/1.6 ui-monospace, SFMono-Regular, monospace; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ *
 * R14 hierarchical navigation (Owner-approved UX override, section 4)
 *
 * Authority split: the main content area stays bound to frozen Admin
 * Design R3; only the navigation/chrome region is reorganised. Every rule
 * below is scoped to the sidebar, the nav tree, the breadcrumb or the
 * drawer so the R3 content area keeps its original declarations.
 * ------------------------------------------------------------------ */

.admin-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  max-height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-head h2 { margin: 0; }
.nav-collapse-toggle {
  border: 0;
  background: transparent;
  color: #bbd0e3;
  min-height: 40px;
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-collapse-toggle:hover { background: #ffffff1a; border-color: transparent; }
.nav-collapse-toggle .nav-icon svg { width: 20px; height: 20px; }

.nav-surface {
  font-size: 11px;
  color: #b9c9d7;
  margin: 18px 8px 6px;
  text-transform: uppercase;
  letter-spacing: .1em;
}
.nav-hierarchy { margin: 4px 0 24px; }
.nav-group { margin: 2px 0; }
.nav-group-toggle {
  display: grid;
  grid-template-columns: 28px 1fr auto 14px;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #d9e5ee;
  font-size: 14px;
  padding: 9px 8px;
  border-radius: 8px;
  min-height: 44px;
}
.nav-group-toggle:hover { background: #ffffff14; border-color: transparent; }
.nav-group.active > .nav-group-toggle,
.nav-group.open > .nav-group-toggle { background: #0b3b52; color: #fff; }
.nav-icon { display: inline-flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 22px; height: 22px; display: block; }
.nav-group-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
  font-size: 11px;
  color: #cfe0ec;
  background: #ffffff1f;
  border-radius: 10px;
  padding: 1px 7px;
}
.nav-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .15s ease;
  opacity: .85;
}
.nav-group.open .nav-chevron { transform: rotate(45deg); }
.nav-sections { display: none; padding: 2px 0 8px 14px; margin-left: 12px; border-left: 1px solid #ffffff1f; }
.nav-group.open .nav-sections { display: block; }
.nav-section[hidden], .nav-group[hidden], .nav-item[hidden] { display: none !important; }
.nav-section { margin: 6px 0 2px; }
.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #9fb6c8;
  margin: 10px 8px 4px;
}
.nav-section.active > .nav-section-title { color: #eaf3f8; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list li { margin: 0; }
.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  margin: 1px 0;
  border: 0;
  background: transparent;
  color: #d9e5ee;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 6px;
  min-height: 40px;
}
.nav-item:hover { background: #ffffff14; border-color: transparent; }
.nav-item.active { background: var(--teal); color: #fff; }
.nav-item[data-nav-level="3"] { padding-left: 12px; }
.nav-item small { display: block; color: inherit; font-size: 10px; overflow-wrap: anywhere; }

/* Current-location breadcrumb (navigation chrome only). */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 14px; flex: 1; min-width: 0; }
.breadcrumb .crumb-sep { color: var(--muted); }
.breadcrumb .crumb-current { font-weight: 600; }

/* R12 first/second-level clarity: a labelled formal-navigation block with a
   visible parent/child guide rail, kept strictly separate from quick access. */
.nav-block-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #9fb6c8;
  margin: 14px 8px 4px;
}
.admin-sidebar [hidden] { display: none !important; }
.nav-drawer-toggle { display: none; min-height: 44px; }
.nav-backdrop { position: fixed; inset: 0; background: #142b4373; z-index: 40; }
.nav-backdrop[hidden] { display: none; }

/* Collapsed icon rail (desktop only). Labels stay in the DOM for screen
   readers; only their visual presentation is hidden. */
@media (min-width: 1025px) {
  .app.nav-collapsed { grid-template-columns: 76px minmax(0, 1fr); }
  .app.nav-collapsed .admin-sidebar { padding: 20px 10px; }
  .app.nav-collapsed .brand-sub,
  .app.nav-collapsed .nav-surface,
  .app.nav-collapsed .nav-group-label,
  .app.nav-collapsed .nav-count,
  .app.nav-collapsed .nav-chevron,
  .app.nav-collapsed .nav-sections { display: none; }
  .app.nav-collapsed .nav-group-toggle { grid-template-columns: 1fr; place-items: center; padding: 8px; }
  .app.nav-collapsed .sidebar-head { flex-direction: column; gap: 10px; }
  .app.nav-collapsed .sidebar-head h2 { display: none; }
  .app.nav-collapsed .nav-collapse-toggle .nav-icon svg { transform: rotate(180deg); }
  .app.nav-collapsed .nav-group.active > .nav-group-toggle { background: var(--teal); }
  .nav-backdrop { display: none !important; }
}

/* R8 ADMIN_BREAKPOINT OPT-A: the Owner-approved design authority keeps the
   side-by-side layout at the 1024px breakpoint (its real
   @media(max-width:1024px) sets grid-template-columns: 200px minmax(0,1fr))
   and only switches to a single column and hides the aside at 768px.
   The R14 off-canvas drawer is therefore a <=768px behaviour, never a tablet
   behaviour: at 769-1024px the sidebar stays in-flow and the design layout
   applies verbatim. The redundant .app override is removed so design-r3.css
   owns the tablet grid. */
@media (max-width: 768px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 86vw);
    z-index: 50;
    transform: translateX(-102%);
    transition: transform .2s ease;
    max-height: none;
    overflow-y: auto;
    box-shadow: 0 20px 60px #142b4366;
  }
  .app.nav-open .admin-sidebar { transform: none; }
  .nav-drawer-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .nav-collapse-toggle { display: none; }
  html.nav-locked { overflow: hidden; }
  .topbar { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .admin-sidebar, .nav-chevron { transition: none; }
}

/* R14 live list pagination (server-backed, real projection rows only). */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 14px; }
.pager-link {
  color: var(--teal);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.pager-link:hover { border-color: var(--teal); }
.pager-link.disabled { color: var(--muted); opacity: .55; cursor: not-allowed; }

/* ------------------------------------------------------------------ *
 * R15 navigation search + quick access (sidebar-scoped, additive)
 * ------------------------------------------------------------------ */
.nav-search { margin: 2px 8px 10px; display: block; }
.nav-search-field { position: relative; display: flex; align-items: center; }
.nav-search input {
  width: 100%;
  border: 1px solid #ffffff2e;
  background: #ffffff12;
  color: #eaf3f8;
  border-radius: 8px;
  padding: 8px 34px 8px 10px;
  min-height: 38px;
  font-size: 13px;
}
.nav-search input::placeholder { color: #b9c9d7; }
.nav-search-clear {
  position: absolute;
  right: 4px;
  border: 0;
  background: transparent;
  color: #d9e5ee;
  font-size: 16px;
  line-height: 1;
  min-width: 28px;
  min-height: 28px;
  border-radius: 6px;
  cursor: pointer;
}
.nav-search-clear:hover { background: #ffffff1a; }
.nav-search-clear:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.nav-search-status { display: block; color: #ffd9a8; font-size: 12px; margin: 6px 2px 0; }
.nav-search-status[hidden] { display: none; }
.nav-search-empty { display: none; }
.nav-quick { margin: 6px 8px 12px; border-bottom: 1px solid #ffffff1f; padding-bottom: 10px; }
.nav-quick-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #9fb6c8;
  margin: 8px 4px 4px;
}
.nav-recent { margin-top: 6px; }
.nav-quick-item { font-size: 13px; min-height: 38px; }
.app.nav-collapsed .nav-search,
.app.nav-collapsed .nav-quick { display: none; }



/* ------------------------------------------------------------------ *
 * R16 favourites (additive navigation UX; the 6-group / 33-section
 * structure and the R3 content area are unchanged).
 * ------------------------------------------------------------------ */
.nav-list li { display: flex; align-items: stretch; gap: 2px; }
.nav-list li > .nav-item { flex: 1 1 auto; min-width: 0; }
.nav-fav-toggle {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: #8aa4b8;
  cursor: pointer;
  border-radius: 6px;
  min-width: 30px;
  font-size: 14px;
  line-height: 1;
  padding: 0 4px;
}
.nav-fav-toggle:hover { background: #ffffff14; color: #ffd98a; }
.nav-fav-toggle:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.nav-fav-toggle.active { color: #ffd98a; }
.nav-favs { margin-top: 6px; }
.app.nav-collapsed .nav-fav-toggle { display: none; }
@media (prefers-reduced-motion: reduce) {
  .nav-fav-toggle { transition: none; }
}
