:root {
  --p8-ink: #171510;
  --p8-paper: #fffdf8;
  --p8-cream: #f5efe2;
  --p8-gold: #b38a36;
  --p8-line: rgba(37, 31, 20, 0.14);
  --p8-muted: #6f685b;
  --p8-success: #24704b;
  --p8-warning: #9a6817;
  --p8-danger: #9d3d35;
  --p8-shadow: 0 22px 60px rgba(24, 20, 12, 0.12);
}

.p8-public-banner {
  position: relative;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 44px;
  padding: .7rem 3.25rem .7rem 1rem;
  font-size: .92rem;
  font-weight: 650;
  text-align: center;
  border-bottom: 1px solid rgba(0,0,0,.12);
}
.p8-public-banner.p8-info { background: #eee5d3; color: #392d18; }
.p8-public-banner.p8-success { background: #dceee2; color: #1d5337; }
.p8-public-banner.p8-warning { background: #f5e4bf; color: #6d4709; }
.p8-public-banner.p8-urgent { background: #822f2b; color: white; }
.p8-public-banner button {
  position: absolute;
  right: .8rem;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1.25rem;
  cursor: pointer;
}
.p8-public-banner button:hover,
.p8-public-banner button:focus-visible { background: rgba(0,0,0,.08); }

.p8-connection-banner {
  position: fixed;
  z-index: 180;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  width: min(680px, calc(100% - 2rem));
  padding: .85rem 1rem;
  border-radius: 12px;
  background: #2e2921;
  color: white;
  box-shadow: var(--p8-shadow);
  text-align: center;
  font-size: .9rem;
  font-weight: 650;
}

.p8-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 10% 10%, rgba(179, 138, 54, .12), transparent 34%),
    linear-gradient(150deg, #f9f4e9, #fffdf8 55%, #f0e7d6);
  color: var(--p8-ink);
}
.p8-gate-card {
  width: min(680px, 100%);
  padding: clamp(1.6rem, 4vw, 3rem);
  border: 1px solid var(--p8-line);
  border-radius: 24px;
  background: rgba(255, 253, 248, .96);
  box-shadow: var(--p8-shadow);
  text-align: center;
}
.p8-brand {
  display: inline-flex;
  align-items: center;
  gap: .8rem;
  color: inherit;
  text-decoration: none;
  text-align: left;
}
.p8-brand img { width: 46px; height: 46px; object-fit: contain; }
.p8-brand span { display: grid; gap: .08rem; }
.p8-brand strong { font-family: Georgia, serif; font-size: 1.05rem; }
.p8-brand small { color: var(--p8-muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.p8-gate-icon {
  width: 72px;
  height: 72px;
  margin: 2rem auto 1.2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--p8-cream);
  color: var(--p8-gold);
  font-size: 2rem;
  border: 1px solid rgba(179,138,54,.22);
}
.p8-kicker {
  margin: 0 0 .45rem;
  color: var(--p8-gold);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.p8-gate-card h1 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 1.04;
}
.p8-gate-card > p:not(.p8-kicker) { max-width: 540px; margin: 1rem auto; color: var(--p8-muted); line-height: 1.7; }
.p8-gate-card > small { display: block; margin-top: 1.3rem; color: var(--p8-muted); }
.p8-gate-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem; margin-top: 1.5rem; }

.p8-admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  background: #f6f1e7;
  color: var(--p8-ink);
}
.p8-admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: #181611;
  color: #fffaf0;
  border-right: 1px solid rgba(255,255,255,.08);
}
.p8-admin-sidebar .p8-brand { color: #fffaf0; }
.p8-admin-sidebar .p8-brand small { color: rgba(255,255,255,.55); }
.p8-admin-sidebar nav { display: grid; gap: .35rem; }
.p8-admin-sidebar nav a,
.p8-injected-health-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  min-height: 44px;
  padding: .7rem .8rem;
  border-radius: 10px;
  color: rgba(255,255,255,.72);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 650;
}
.p8-admin-sidebar nav a:hover,
.p8-admin-sidebar nav a:focus-visible,
.p8-admin-sidebar nav a.active,
.p8-injected-health-link:hover,
.p8-injected-health-link:focus-visible { background: rgba(255,255,255,.08); color: white; }
.p8-admin-user { margin-top: auto; display: grid; gap: .2rem; padding: .9rem; border-top: 1px solid rgba(255,255,255,.1); }
.p8-admin-user span { color: rgba(255,255,255,.58); font-size: .8rem; }
.p8-admin-main { min-width: 0; padding: clamp(1.2rem, 3vw, 2.5rem); }
.p8-health-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; }
.p8-health-header h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(2rem, 4vw, 3.2rem); }
.p8-health-header p:not(.p8-kicker) { margin: .7rem 0 0; max-width: 700px; color: var(--p8-muted); line-height: 1.65; }
.p8-health-actions { display: flex; flex-wrap: wrap; gap: .65rem; }
.p8-health-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .8rem;
  margin: 1.7rem 0 1rem;
}
.p8-health-summary article,
.p8-health-meta,
.p8-check-list,
.p8-health-guidance {
  border: 1px solid var(--p8-line);
  border-radius: 16px;
  background: var(--p8-paper);
  box-shadow: 0 8px 28px rgba(24,20,12,.05);
}
.p8-health-summary article { padding: 1.05rem; display: grid; gap: .25rem; }
.p8-health-summary strong { font-family: Georgia, serif; font-size: 1.8rem; }
.p8-health-summary span { color: var(--p8-muted); font-size: .82rem; }
.p8-health-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-bottom: 1rem; }
.p8-health-meta div { padding: 1rem; display: grid; gap: .25rem; border-right: 1px solid var(--p8-line); }
.p8-health-meta div:last-child { border-right: 0; }
.p8-health-meta span { color: var(--p8-muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; }
.p8-health-meta strong { overflow-wrap: anywhere; }
.p8-check-list { padding: .55rem; display: grid; gap: .45rem; }
.p8-check {
  display: grid;
  grid-template-columns: 38px minmax(0,1fr);
  align-items: start;
  gap: .8rem;
  padding: .85rem;
  border-radius: 12px;
}
.p8-check:hover { background: rgba(179,138,54,.045); }
.p8-check-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; font-weight: 900; }
.p8-check.p8-success .p8-check-mark { background: rgba(36,112,75,.12); color: var(--p8-success); }
.p8-check.p8-warning .p8-check-mark { background: rgba(154,104,23,.13); color: var(--p8-warning); }
.p8-check.p8-danger .p8-check-mark { background: rgba(157,61,53,.12); color: var(--p8-danger); }
.p8-check strong { display: block; margin-bottom: .18rem; }
.p8-check p { margin: 0; color: var(--p8-muted); font-size: .88rem; line-height: 1.5; overflow-wrap: anywhere; }
.p8-empty { padding: 2rem; text-align: center; color: var(--p8-muted); }
.p8-health-guidance { margin-top: 1rem; padding: 1.2rem; }
.p8-health-guidance h2 { margin: 0; font-family: Georgia, serif; }
.p8-health-guidance p { color: var(--p8-muted); line-height: 1.6; }
.p8-health-guidance div { display: flex; flex-wrap: wrap; gap: .6rem; }

.p8-toast-region { position: fixed; z-index: 240; top: 1rem; right: 1rem; display: grid; gap: .55rem; width: min(390px, calc(100% - 2rem)); }
.p8-toast { padding: .9rem 1rem; border-radius: 12px; background: #1d1a15; color: white; box-shadow: var(--p8-shadow); font-size: .9rem; }
.p8-toast.p8-warning { background: #774e0c; }
.p8-error-panel {
  position: fixed;
  z-index: 250;
  right: 1rem;
  bottom: 1rem;
  width: min(520px, calc(100% - 2rem));
  display: grid;
  grid-template-columns: minmax(0,1fr) auto auto;
  align-items: start;
  gap: .7rem;
  padding: 1rem;
  border-radius: 14px;
  background: #33201e;
  color: white;
  box-shadow: var(--p8-shadow);
}
.p8-error-panel strong { display: block; margin-bottom: .25rem; }
.p8-error-panel p { margin: 0; color: rgba(255,255,255,.72); font-size: .82rem; line-height: 1.45; }
.p8-error-panel button { border: 1px solid rgba(255,255,255,.22); border-radius: 8px; background: transparent; color: white; padding: .45rem .65rem; cursor: pointer; }

@media (prefers-color-scheme: dark) {
  :root { --p8-ink: #f5eee0; --p8-paper: #211e18; --p8-cream: #29251d; --p8-line: rgba(255,255,255,.11); --p8-muted: #bdb4a4; }
  .p8-gate { background: radial-gradient(circle at 10% 10%, rgba(179,138,54,.13), transparent 32%), #14120f; }
  .p8-gate-card { background: rgba(31,28,22,.97); }
  .p8-admin-shell { background: #14120f; }
  .p8-health-summary article,
  .p8-health-meta,
  .p8-check-list,
  .p8-health-guidance { background: #211e18; }
  .p8-check:hover { background: rgba(255,255,255,.035); }
}

@media (max-width: 900px) {
  .p8-admin-shell { grid-template-columns: 1fr; }
  .p8-admin-sidebar { position: relative; height: auto; }
  .p8-admin-sidebar nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .p8-admin-user { margin-top: 0; }
  .p8-health-header { flex-direction: column; }
  .p8-health-summary,
  .p8-health-meta { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .p8-health-meta div:nth-child(2) { border-right: 0; }
  .p8-health-meta div:nth-child(-n+2) { border-bottom: 1px solid var(--p8-line); }
}

@media (max-width: 560px) {
  .p8-admin-sidebar nav,
  .p8-health-summary,
  .p8-health-meta { grid-template-columns: 1fr; }
  .p8-health-meta div { border-right: 0; border-bottom: 1px solid var(--p8-line); }
  .p8-health-meta div:last-child { border-bottom: 0; }
  .p8-health-actions,
  .p8-gate-actions { width: 100%; }
  .p8-health-actions .btn,
  .p8-gate-actions .btn { flex: 1 1 100%; }
  .p8-error-panel { grid-template-columns: 1fr auto; }
  .p8-error-panel div { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
