:root {
  --ink: #0d1f16;
  --muted: #5a6b61;
  --line: #d5e2da;
  --paper: #f3f7f4;
  --panel: #ffffff;
  --rail: #062412;
  --rail-mid: #0a3d24;
  --rail-ink: #e8f5ee;
  --accent: #116534;
  --accent-bright: #1a8a46;
  --accent-soft: #e6f4ec;
  --navy: #003566;
  --shadow: 0 16px 44px rgba(6, 36, 18, 0.09);
  --font-body: "DM Sans", sans-serif;
  --font-display: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(ellipse at top right, rgba(17, 101, 52, 0.07), transparent 42%),
    linear-gradient(180deg, #eaf3ee 0%, var(--paper) 28%);
  min-height: 100vh;
}

.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  background:
    linear-gradient(165deg, rgba(26, 138, 70, 0.22), transparent 42%),
    linear-gradient(195deg, var(--rail-mid), var(--rail));
  color: var(--rail-ink);
  padding: 1.25rem 0.85rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.rail::-webkit-scrollbar {
  width: 6px;
}

.rail::-webkit-scrollbar-track {
  background: transparent;
}

.rail::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 99px;
}

.rail::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.38);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  margin: 0 auto 0.7rem;
  border-radius: 50%;
  padding: 0.45rem;
  background: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.brand-mark:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
}

.brand-mark img {
  display: block;
  width: 70px;
  height: auto;
  object-fit: contain;
  border-radius: 0;
}

.brand-kicker {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.66rem;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 700;
  line-height: 1.4;
  max-width: 14rem;
}

.brand h1 {
  margin: 0.35rem 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.12;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.brand-copy {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.8rem;
  line-height: 1.4;
  max-width: 16rem;
}

.rail-label {
  margin: 0 0 0.45rem;
  font-size: 0.66rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
  font-weight: 700;
  text-align: left;
  padding-left: 0.35rem;
}

#portalNav {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
  padding: 0 0.1rem;
}

.nav-block {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 0.55rem 0.45rem 0.5rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.nav-block-title {
  margin: 0 0.4rem 0.4rem;
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(215, 240, 226, 0.72);
}

.nav-block-list {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.nav-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: rgba(232, 245, 238, 0.92);
  border-radius: 12px;
  padding: 0.55rem 0.6rem;
  border: 1px solid transparent;
  background: transparent;
  position: relative;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
  transform: translateX(2px);
}

.nav-item.is-active {
  background: linear-gradient(90deg, rgba(26, 138, 70, 0.35), rgba(255, 255, 255, 0.1));
  border-color: rgba(167, 220, 188, 0.28);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
  color: #fff;
}

.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 3px;
  border-radius: 99px;
  background: #7dffb0;
  box-shadow: 0 0 10px rgba(125, 255, 176, 0.55);
}

.nav-item-icon {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #d7f0e2;
  flex: 0 0 auto;
}

.nav-item.is-active .nav-item-icon {
  background: rgba(125, 255, 176, 0.18);
  color: #eafff2;
}

.nav-item-icon svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

.nav-item-body {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
}

.nav-item-label {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
}

.nav-hint {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(232, 245, 238, 0.58);
  line-height: 1.25;
}

.nav-item.is-active .nav-hint {
  color: rgba(232, 245, 238, 0.78);
}

.category-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.category-nav button,
.nav-link,
a.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  border-radius: 12px;
  padding: 0.72rem 0.85rem;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.category-nav button:hover,
.nav-link:hover,
a.nav-link:hover {
  background: rgba(255,255,255,0.08);
  transform: translateX(2px);
}

.category-nav button.active,
.nav-link.active,
a.nav-link.active {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.18);
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  flex: 0 0 auto;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #d7f0e2;
}

.nav-icon svg {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
}

/* Data domain filters on browser page — match nav cards */
.rail > div:has(#categoryNav) {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 0.55rem 0.45rem 0.5rem;
}

.rail > div:has(#categoryNav) .rail-label {
  margin: 0 0.4rem 0.4rem;
  padding-left: 0;
}

.rail-foot {
  margin-top: auto;
  font-size: 0.8rem;
  display: grid;
  gap: 0.7rem;
  flex: 0 0 auto;
  padding-top: 0.35rem;
}

.app-version {
  margin: 0;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: rgba(232, 245, 238, 0.55);
}

.auth-foot .app-version {
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.8rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.user-avatar {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #2f9d5c, #116534);
  color: #fff;
  font-weight: 750;
  font-size: 0.95rem;
  flex: 0 0 auto;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

.user-meta {
  min-width: 0;
}

.user-name {
  margin: 0;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  margin: 0.15rem 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-logout {
  width: 100%;
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 0.65rem;
  color: var(--rail-ink) !important;
  border-color: rgba(232, 245, 238, 0.28) !important;
  padding: 0.65rem 0.85rem;
  font-size: 0.84rem;
  border-radius: 12px;
  box-shadow: none;
}

.rail-logout .nav-icon {
  background: rgba(255, 255, 255, 0.08);
}

.topbar-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  margin-right: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 12px;
  background: #eef7f1;
  border: 1px solid var(--line);
}

.topbar-user span:first-child {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink);
}

.topbar-role {
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: capitalize;
  font-weight: 700;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 12% 18%, rgba(26, 138, 70, 0.22), transparent 38%),
    radial-gradient(circle at 88% 78%, rgba(0, 53, 102, 0.16), transparent 34%),
    linear-gradient(155deg, #e7f2eb, #f5f8f6 52%, #e4eee8);
}

.auth-shell {
  width: min(920px, calc(100% - 2rem));
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 0;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(6, 36, 18, 0.18);
  border: 1px solid rgba(213, 226, 218, 0.9);
  background: var(--panel);
  animation: authIn 280ms ease;
}

@keyframes authIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.auth-hero {
  position: relative;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.85rem;
  padding: 2.4rem 1.6rem;
  text-align: center;
  color: #eef7f1;
  background:
    linear-gradient(160deg, rgba(17, 101, 52, 0.92), rgba(6, 36, 18, 0.96)),
    var(--rail);
  overflow: hidden;
}

.auth-hero-glow {
  position: absolute;
  inset: auto -20% -30% auto;
  width: 70%;
  height: 70%;
  background: radial-gradient(circle, rgba(26, 138, 70, 0.45), transparent 70%);
  pointer-events: none;
  animation: glowPulse 4.5s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.08); }
}

.auth-hero-logo {
  position: relative;
  width: 150px;
  height: auto;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.28));
}

.auth-hero-org {
  position: relative;
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  opacity: 0.78;
}

.auth-hero-title {
  position: relative;
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 2.4vw, 1.95rem);
  font-weight: 700;
  line-height: 1.15;
  max-width: 16rem;
}

.auth-hero-sub {
  position: relative;
  margin: 0.35rem 0 0;
  opacity: 0.78;
  font-size: 0.9rem;
  line-height: 1.4;
  max-width: 16rem;
}

.auth-panel {
  background: var(--panel);
  padding: 1.8rem 1.6rem 1.4rem;
  display: flex;
  flex-direction: column;
}

.auth-panel-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.35rem;
}

.auth-panel-head img {
  width: 58px;
  height: auto;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
  padding: 0;
  border: 0;
}

.auth-kicker {
  color: var(--accent);
}

.auth-panel h1 {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  line-height: 1.15;
}

.auth-lead {
  margin: 0.55rem 0 1.15rem;
  color: var(--muted);
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 0.85rem;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.auth-foot {
  margin: 1.1rem 0 0;
  text-align: center;
  font-size: 0.85rem;
  display: grid;
  gap: 0.35rem;
  justify-items: center;
}

.auth-foot .app-version {
  display: block;
  color: var(--muted);
  margin: 0;
}

.auth-foot a {
  color: var(--navy);
  font-weight: 600;
  text-decoration: none;
}

.auth-foot a:hover {
  text-decoration: underline;
}

.captcha-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 0.75rem;
}

.captcha-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-height: 2.55rem;
}

.form-error {
  margin: 0;
  color: #9b2c2c;
  background: #fdecec;
  border: 1px solid #f3c1c1;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font-size: 0.88rem;
}

.banner-error {
  margin-bottom: 0.85rem;
}

.role-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: capitalize;
}

.role-pill.admin {
  background: var(--accent-soft);
  color: var(--accent);
}

.role-pill.user {
  background: #eef1f4;
  color: #44525b;
}

.status-pill.on {
  background: var(--accent-soft);
  color: #176b57;
}

.status-pill.off {
  background: #f3f0ea;
  color: #7a6550;
}

.actions-cell {
  white-space: nowrap;
}

button.compact {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  border-radius: 999px;
}

button.danger {
  color: #9b2c2c;
  border-color: #f3c1c1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.users-table-wrap {
  max-height: calc(100vh - 220px);
}

.auth-form .field span {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 650;
}

.main {
  padding: 1.35rem 1.55rem 2rem;
}

.analytics-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  gap: 0.85rem;
}

.analytics-topbar {
  flex-wrap: wrap;
}

.analytics-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.analytics-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.analytics-status::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

.analytics-status.is-loading {
  color: #8a6a12;
  background: #fff8e6;
  border-color: #f0dfae;
}

.analytics-status.is-loading::before {
  animation: analyticsPulse 1.1s ease-in-out infinite;
  background: #d4a017;
}

.analytics-status.is-ready {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: #b7dcc7;
}

.analytics-status.is-error {
  color: #8f1d1d;
  background: #fdeeee;
  border-color: #f0c4c4;
}

.analytics-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.analytics-tool-btn svg {
  width: 1rem;
  height: 1rem;
}

.analytics-tool-btn:hover {
  background: var(--accent-soft);
  border-color: #b7dcc7;
  transform: translateY(-1px);
}

.analytics-tool-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.analytics-tool-btn.primary:hover {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
}

.analytics-stage {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
  animation: analyticsRise 420ms ease both;
}

.analytics-stage-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0 0.15rem;
}

.analytics-stage-head h3 {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
}

.analytics-hint {
  margin: 0;
  max-width: 28rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  text-align: right;
}

.analytics-frame {
  position: relative;
  flex: 1;
  min-height: calc(100vh - 220px);
  border-radius: 20px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), #fff),
    radial-gradient(ellipse at top left, rgba(17, 101, 52, 0.08), transparent 55%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.analytics-embed {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 220px);
  background: transparent;
}

.analytics-embed iframe {
  border: 0;
}

.analytics-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.85rem;
  background:
    radial-gradient(circle at 30% 20%, rgba(26, 138, 70, 0.12), transparent 40%),
    rgba(243, 247, 244, 0.88);
  backdrop-filter: blur(4px);
  transition: opacity 280ms ease, visibility 280ms ease;
}

.analytics-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.analytics-overlay p {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.analytics-spinner {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 3px solid #cfe3d7;
  border-top-color: var(--accent);
  animation: analyticsSpin 0.8s linear infinite;
}

@keyframes analyticsSpin {
  to { transform: rotate(360deg); }
}

@keyframes analyticsPulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.05); }
}

@keyframes analyticsRise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.analytics-frame:fullscreen {
  border-radius: 0;
  min-height: 100vh;
  background: #fff;
}

.analytics-frame:fullscreen .analytics-embed {
  min-height: 100vh;
}

@media (max-width: 900px) {
  .analytics-hint {
    text-align: left;
    max-width: none;
  }

  .analytics-frame,
  .analytics-embed {
    min-height: 70vh;
  }
}

.topbar,
.main-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}

.topbar {
  align-items: center;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.topbar-brand img {
  width: 42px;
  height: auto;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
  border: 0;
  padding: 0;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
}

.topbar h2,
.main-head h2 {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2vw, 1.85rem);
  line-height: 1.15;
}

.head-actions,
.pager {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

button, select, input { font: inherit; }

button {
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(17, 101, 52, 0.18);
  transition: transform 140ms ease, filter 140ms ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}

.filters-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(17, 101, 52, 0.05), transparent),
    #fbfdfc;
}

.filters-kicker {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.68rem;
  font-weight: 700;
}

.filters-head h3 {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  padding: 1rem 1.1rem 1.15rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field span {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 650;
  letter-spacing: 0.01em;
}

.field-search {
  grid-column: span 1;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: end;
  flex-shrink: 0;
}

select, input {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.68rem 0.75rem;
  background: #fff;
  color: var(--ink);
  width: 100%;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 1.8rem;
}

select:hover, input:hover {
  border-color: #b7cec2;
}

select:focus, input:focus {
  outline: none;
  border-color: #6faf8f;
  box-shadow: 0 0 0 3px rgba(17, 101, 52, 0.12);
}

.table-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(17, 101, 52, 0.04), transparent),
    #fbfdfc;
}

.result-summary {
  margin: 0.15rem 0 0;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
}

.result-summary strong {
  color: var(--accent);
  font-weight: 750;
}

.page-indicator {
  min-width: 4.5rem;
  text-align: center;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 650;
}

.pager button {
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 330px);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.78rem 0.9rem;
  border-bottom: 1px solid #e6eee9;
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0f3d2a;
  color: #e8f5ee;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  border-bottom: 0;
  box-shadow: 0 1px 0 rgba(15, 61, 42, 0.35);
}

.data-table tbody tr {
  transition: background 120ms ease;
}

.data-table tbody tr:nth-child(even) {
  background: #f7fbf8;
}

.data-table tbody tr:hover {
  background: #e8f5ee;
}

.data-table td.num,
.data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.data-table th.ref-col,
.data-table td.ref-cell {
  text-align: center;
  width: 4.2rem;
}

.cell-pill {
  display: inline-flex;
  align-items: center;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 999px;
  padding: 0.22rem 0.65rem;
  background: var(--accent-soft);
  color: #0f4a31;
  font-size: 0.78rem;
  font-weight: 700;
}

.cell-pill.muted {
  background: #eef2f0;
  color: #4d5c55;
  font-weight: 650;
}

.cell-value {
  display: inline-block;
  min-width: 4.5rem;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  background: #eef8f2;
  color: var(--accent);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.cell-unit {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.view-ref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  box-shadow: none;
}

.view-ref:hover {
  background: var(--accent-soft);
  border-color: #9cc4b0;
  filter: none;
  transform: none;
}

.view-ref svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2.4rem 1rem !important;
  white-space: normal !important;
}

.modal[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 28, 18, 0.48);
}

.modal-panel {
  position: relative;
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(6, 36, 18, 0.24);
  overflow: hidden;
  animation: modalIn 160ms ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  padding: 1.1rem 1.2rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.icon-btn {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
  box-shadow: none;
}

.modal-body {
  padding: 1rem 1.2rem 1.25rem;
  display: grid;
  gap: 0.85rem;
}

.ref-field {
  display: grid;
  gap: 0.25rem;
}

.ref-field span {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.ref-field p {
  margin: 0;
  line-height: 1.45;
  word-break: break-word;
  white-space: normal;
  font-size: 0.95rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
}

.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-value {
  margin: 0.35rem 0 0.15rem;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--ink);
}

.stat-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}

.summary-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(17, 101, 52, 0.05), transparent),
    #fbfdfc;
}

.summary-panel-head h3 {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.muted-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.arch-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  padding: 1.1rem;
}

.arch-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  background: #f8fbf9;
  position: relative;
}

.arch-card.ready {
  border-color: #9cc4b0;
  background: linear-gradient(180deg, #eef8f2, #f8fbf9);
}

.arch-card.pending {
  opacity: 0.75;
}

.arch-step {
  margin: 0;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.arch-card h4 {
  margin: 0.35rem 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.arch-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.arch-metric {
  margin-top: 0.7rem !important;
  color: var(--accent) !important;
  font-weight: 750 !important;
}

.arch-outputs {
  margin-top: 0.35rem !important;
  font-size: 0.78rem !important;
}

.arch-notes {
  margin: 0;
  padding: 0 1.1rem 1.1rem 2.2rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.summary-columns {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1rem;
  align-items: start;
}

.summary-table-wrap {
  max-height: 420px;
}

.ingest-cards {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
}

.ingest-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  background: #f8fbf9;
}

.ingest-card header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 0.65rem;
}

.ingest-card h4 {
  margin: 0;
  font-size: 0.98rem;
}

.ingest-card header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.ingest-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 0.75rem;
}

.ingest-card dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.ingest-card dd {
  margin: 0.1rem 0 0;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.run-id {
  margin: 0.7rem 0 0.45rem;
  font-size: 0.74rem;
  color: var(--muted);
  word-break: break-all;
}

.qa-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.qa-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  background: #eef2f0;
  color: #4d5c55;
}

.qa-pill.pass,
.qa-pill.ok,
.qa-pill.success {
  background: var(--accent-soft);
  color: #176b57;
}

.qa-pill.warn,
.qa-pill.warning,
.qa-pill.info {
  background: #f3f0ea;
  color: #7a6550;
}

.qa-pill.fail,
.qa-pill.error {
  background: #fdecec;
  color: #9b2c2c;
}

.empty-block {
  margin: 0;
  padding: 1.4rem 1rem;
  text-align: center;
  color: var(--muted);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.65rem 1rem;
  font-weight: 700;
  box-shadow: none;
}

.button-link:hover {
  background: var(--accent-soft);
  border-color: #9cc4b0;
}

.arch-teaser {
  margin: 0;
  padding: 1rem 1.1rem 1.15rem;
  color: var(--muted);
  line-height: 1.5;
}

.arch-hero-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  background: #fff;
}

.arch-hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(26, 138, 70, 0.14), transparent 34%),
    radial-gradient(circle at 88% 12%, rgba(0, 53, 102, 0.08), transparent 28%),
    linear-gradient(180deg, #f4faf6 0%, #ffffff 46%, #f7fbf9 100%);
  pointer-events: none;
}

.arch-hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(17, 101, 52, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 101, 52, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, #000 20%, transparent 90%);
}

.arch-hero-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  padding: 1.25rem 1.25rem 0.35rem;
}

.arch-hero-head h3 {
  margin: 0.2rem 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2vw, 1.75rem);
}

.arch-hero-lead {
  margin: 0;
  max-width: 38rem;
  color: var(--muted);
  line-height: 1.5;
}

.arch-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.arch-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
}

.arch-legend .dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  display: inline-block;
}

.arch-legend .dot.source { background: #5aa67f; }
.arch-legend .dot.process { background: #116534; }
.arch-legend .dot.publish { background: #003566; }

.arch-canvas {
  position: relative;
  padding: 1rem 1rem 1.35rem;
  overflow-x: auto;
}

.arch-flow-row {
  min-width: 1100px;
  display: grid;
  grid-template-columns: 1.05fr auto 0.95fr auto 0.95fr auto 0.95fr auto 0.95fr;
  gap: 0.55rem;
  align-items: center;
}

.arch-stage-label {
  margin: 0 0 0.55rem;
  text-align: center;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.arch-stack {
  display: grid;
  gap: 0.55rem;
}

.flow-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: start;
  padding: 0.85rem 0.9rem;
  border-radius: 16px;
  border: 1px solid rgba(213, 226, 218, 0.95);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 30px rgba(6, 36, 18, 0.06);
  backdrop-filter: blur(6px);
  animation: flowIn 480ms ease both;
  animation-delay: calc(var(--d, 0) * 70ms);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.flow-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 36px rgba(6, 36, 18, 0.1);
}

.flow-card.tall {
  grid-template-columns: 1fr;
  min-height: 280px;
  padding: 1rem 1rem 1.05rem;
  background:
    linear-gradient(180deg, rgba(232, 245, 238, 0.95), rgba(255, 255, 255, 0.98));
  border-color: #9cc4b0;
}

.flow-card.source {
  border-color: #cfe3d8;
}

.flow-card.publish {
  border-color: #c5d4e4;
  background:
    linear-gradient(180deg, rgba(232, 240, 248, 0.9), rgba(255, 255, 255, 0.98));
}

.flow-card strong {
  display: block;
  font-size: 0.92rem;
  line-height: 1.25;
  color: var(--ink);
}

.flow-card span {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.flow-card.tall strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin-top: 0.35rem;
}

.flow-card.tall > span {
  margin-top: 0.4rem;
  font-size: 0.84rem;
}

.flow-card ul {
  margin: 0.85rem 0 0;
  padding-left: 1.05rem;
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.5;
}

.flow-step {
  position: absolute;
  top: 0.75rem;
  right: 0.8rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: rgba(17, 101, 52, 0.45);
}

.flow-icon {
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: 0 0 auto;
}

.flow-icon.large {
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 14px;
  background: linear-gradient(180deg, #1a8a46, #116534);
  color: #fff;
  box-shadow: 0 10px 22px rgba(17, 101, 52, 0.22);
}

.flow-icon svg {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}

.flow-icon.large svg {
  width: 1.2rem;
  height: 1.2rem;
}

.flow-card.publish .flow-icon {
  background: #e8f0f8;
  color: #003566;
}

.flow-connector {
  display: grid;
  place-items: center;
  align-self: center;
  width: 34px;
  position: relative;
}

.flow-line {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(156, 196, 176, 0.35), #116534);
  position: relative;
  overflow: hidden;
}

.flow-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  transform: translateX(-100%);
  animation: flowShine 2.2s ease-in-out infinite;
}

.flow-chevron {
  position: absolute;
  right: -1px;
  width: 8px;
  height: 8px;
  border-right: 2px solid #116534;
  border-top: 2px solid #116534;
  transform: rotate(45deg);
}

@keyframes flowIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes flowShine {
  0%, 100% { transform: translateX(-120%); }
  55% { transform: translateX(120%); }
}

.arch-explain {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  padding: 1.1rem;
}

.arch-explain article {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.05rem;
  background:
    linear-gradient(180deg, rgba(17, 101, 52, 0.04), transparent 40%),
    #f8fbf9;
}

.explain-num {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.arch-explain h4 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.arch-explain p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.9rem;
}

@media (max-width: 1100px) {
  .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-search { grid-column: 1 / -1; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .arch-flow,
  .summary-columns { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: relative;
    height: auto;
    max-height: none;
    overflow: visible;
  }
  .filters-head,
  .table-toolbar,
  .topbar,
  .main-head,
  .arch-hero-head {
    flex-direction: column;
    align-items: start;
  }
  .head-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .topbar-user {
    align-items: flex-start;
    margin-right: 0;
  }
  .filter-actions,
  .pager {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .captcha-row { grid-template-columns: 1fr; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { padding: 1.6rem 1.2rem; }
  .table-wrap { max-height: none; }
  .arch-nodes,
  .arch-explain {
    grid-template-columns: 1fr;
  }
  .arch-flow-row {
    min-width: 0;
    grid-template-columns: 1fr;
  }
  .flow-connector {
    width: 100%;
    height: 28px;
  }
  .flow-line {
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg, rgba(156, 196, 176, 0.35), #116534);
  }
  .flow-chevron {
    right: auto;
    bottom: -1px;
    transform: rotate(135deg);
  }
  .flow-card.tall { min-height: 0; }
}

@media (max-width: 640px) {
  .filters-grid { grid-template-columns: 1fr; }
}
