:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e7eaf0;
  --muted: #98a2b3;
  --brand: #2f6df6;
  --brand-2: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
}

a { color: #8ab4ff; }

h1 { font-size: 1.6rem; margin: 0 0 .4rem; letter-spacing: -.01em; }
h2.card-title { font-size: 1.02rem; margin: 0 0 .7rem; }
.section-title { margin: 1.6rem 0 .4rem; font-size: 1.1rem; }

code, pre, .secret { font-family: var(--mono); }
code { background: #0b0d12; padding: .1rem .35rem; border-radius: 5px; font-size: .86em; }

pre.code, pre.code-block {
  background: #0b0d12;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .8rem 1rem;
  overflow: auto;
  font-size: .82rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.checks { display: flex; gap: 1rem; margin-top: .25rem; }
label.check { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; }
ol.steps { margin: .2rem 0; padding-left: 1.3rem; }
ol.steps li { margin: .5rem 0; line-height: 1.45; }
details.reveal { margin-top: .6rem; }
details.reveal summary { cursor: pointer; font-size: .88rem; color: var(--muted); }
details.reveal code { display: inline-block; margin-top: .4rem; word-break: break-all; }

/* ------------------------------------------------------------ chrome ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .8rem 1.4rem;
  background: linear-gradient(180deg, #12151c, #0f1115);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand-mark { font-weight: 700; letter-spacing: .12em; font-size: .82rem; color: #fff; }
.brand-sub { font-size: .74rem; color: var(--muted); letter-spacing: .06em; }
.who { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.who-name { font-weight: 600; font-size: .9rem; }
.inline.inline { display: inline; }
.inline form, form.inline { display: inline; }

.nav {
  display: flex; gap: .25rem; flex-wrap: wrap;
  padding: .5rem 1.2rem; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.nav-link {
  color: var(--muted); text-decoration: none; font-size: .88rem;
  padding: .38rem .7rem; border-radius: 8px;
}
.nav-link:hover { color: var(--text); background: var(--panel-2); }
.nav-link.active { color: #fff; background: #232936; }

.main { max-width: 1120px; margin: 0 auto; padding: 1.4rem 1.2rem 3rem; }
.footer { color: #5b6474; font-size: .78rem; text-align: center; padding: 1.5rem; }

/* ------------------------------------------------------------- cards ---- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.05rem 1.15rem;
  margin: 1rem 0;
}
.card-blocked { border-color: #6b1d1d; background: #1b1416; }
.card-title { color: #fff; }

.hero { padding: 2.4rem 0 1rem; max-width: 720px; }
.lead { color: var(--muted); font-size: 1.02rem; margin: .2rem 0 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.crumbs a { text-decoration: none; font-size: .86rem; }

/* ------------------------------------------------------------ tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .52rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover { background: #1a1e27; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: .2rem 0 .9rem; }
dl.kv dt { color: var(--muted); font-size: .85rem; }
dl.kv dd { margin: 0; }

/* ------------------------------------------------------------ badges ---- */
.badge {
  display: inline-block; padding: .06rem .45rem; border-radius: 999px;
  font-size: .74rem; font-weight: 600; letter-spacing: .02em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-ok { background: #0d2c1b; color: #4ade80; border-color: #14532d; }
.badge-off { background: #2a2f3a; color: #94a3b8; }
.badge-warn { background: #33230a; color: #fbbf24; border-color: #78350f; }
.badge-denied { background: #331414; color: #fca5a5; border-color: #7f1d1d; }
.badge-role { background: #122a52; color: #93c5fd; border-color: #1e40af; }
.badge-neutral { background: #22262f; color: #b6bfcd; }

/* ------------------------------------------------------------- forms ---- */
.field { display: flex; flex-direction: column; gap: .3rem; margin: .45rem 0; }
.field > span { font-size: .82rem; color: var(--muted); }
.field small { color: #6b7280; font-size: .76rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 1rem; }
.stack > * + * { margin-top: .5rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .7rem; }

input[type=text], input[type=password], select {
  background: #0b0d12; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .5rem .6rem; font-size: .9rem; width: 100%;
}
input:focus, select:focus { outline: 2px solid #1e40af; outline-offset: 1px; }

.btn {
  display: inline-block; border: 1px solid var(--line); border-radius: 8px;
  padding: .48rem .9rem; font-size: .88rem; font-weight: 600;
  cursor: pointer; text-decoration: none; color: var(--text);
  background: var(--panel-2);
}
.btn:hover { filter: brightness(1.15); }
.btn-primary { background: var(--brand); border-color: var(--brand-2); color: #fff; }
.btn-danger { background: var(--danger); border-color: #991b1b; color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-lg { padding: .7rem 1.3rem; font-size: 1rem; }

/* ------------------------------------------------------------ flash ----- */
.flash { border-radius: 10px; padding: .7rem .9rem; margin: .8rem 0; font-size: .9rem; border: 1px solid; }
.flash-ok { background: #0d2c1b; border-color: #14532d; color: #bbf7d0; }
.flash-error { background: #331414; border-color: #7f1d1d; color: #fecaca; }
.flash-warn { background: #33230a; border-color: #78350f; color: #fde68a; }

/* ------------------------------------------------------------ stats ----- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin: 1rem 0; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .8rem; }

/* --------------------------------------------------------- enrolment ---- */
.enrol-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
img.qr { background: #fff; padding: .5rem; border-radius: 10px; display: block; max-width: 260px; }
.secret { display: block; background: #0b0d12; border: 1px dashed var(--line); padding: .6rem; border-radius: 8px; letter-spacing: .12em; word-break: break-all; }

ul.codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .4rem; list-style: none; padding: 0; }
ul.codes code { display: block; padding: .45rem .6rem; font-size: .95rem; letter-spacing: .08em; }

details.muted summary { cursor: pointer; font-size: .85rem; }

/* ======================================================================== */
/*  CTTD EPEACE brand sign-in stage                                         */
/*  An animated, self-contained aurora background in the house palette      */
/*  (lavender / blue / pink / mint on a near-black ink). No third-party      */
/*  asset, font or pixel — just CSS. Switched off under reduced-motion.      */
/* ======================================================================== */
.auth-body { background: #0d0d17; }

.auth-stage {
  position: relative; min-height: 100vh;
  display: grid; place-items: center;
  padding: 2.4rem 1.1rem; overflow: hidden; isolation: isolate;
}

.auth-bg { position: absolute; inset: -12%; z-index: 0; overflow: hidden; pointer-events: none; }
.auth-bg .orb {
  position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%;
  filter: blur(64px); opacity: .55; will-change: transform;
}
.orb-1 { background: radial-gradient(circle, #cba6f7, transparent 62%); top: -14%; left: -10%; animation: orb-a 22s ease-in-out infinite; }
.orb-2 { background: radial-gradient(circle, #89b4fa, transparent 62%); top: -8%; right: -14%; animation: orb-b 27s ease-in-out infinite; }
.orb-3 { background: radial-gradient(circle, #f38ba8, transparent 62%); bottom: -20%; left: 16%; animation: orb-c 31s ease-in-out infinite; }
.orb-4 { background: radial-gradient(circle, #a6e3a1, transparent 66%); bottom: -16%; right: 4%; opacity: .3; animation: orb-b 36s ease-in-out infinite reverse; }

.aurora-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(205,214,244,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(205,214,244,.055) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 42%, #000 0%, transparent 72%);
  mask-image: radial-gradient(ellipse at 50% 42%, #000 0%, transparent 72%);
}

/* Particle / mesh layer: above the aurora orbs, below the sign-in card. */
.auth-particles {
  position: absolute; inset: 0; z-index: 0;
  width: 100%; height: 100%; pointer-events: none;
}

@keyframes orb-a { 0%,100% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(9vmax,7vmax,0) scale(1.14); } }
@keyframes orb-b { 0%,100% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(-8vmax,6vmax,0) scale(1.1); } }
@keyframes orb-c { 0%,100% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(7vmax,-8vmax,0) scale(1.12); } }

.auth-card {
  position: relative; z-index: 1; width: 100%; max-width: 430px;
  background: rgba(30,30,46,.72);
  backdrop-filter: blur(22px) saturate(135%);
  -webkit-backdrop-filter: blur(22px) saturate(135%);
  border: 1px solid rgba(203,166,247,.2);
  border-radius: 20px;
  padding: 1.9rem 1.7rem 1.5rem;
  color: var(--text);
  box-shadow: 0 30px 90px rgba(0,0,0,.62), 0 0 90px rgba(203,166,247,.08);
  animation: auth-in .55s cubic-bezier(.22,1,.36,1) both;
}
.auth-card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px; border-radius: 20px 20px 0 0;
  background: linear-gradient(90deg, transparent, rgba(203,166,247,.85), rgba(137,180,250,.7), transparent);
  opacity: .8;
}
@keyframes auth-in { from { opacity: 0; transform: translateY(22px) scale(.97); } to { opacity: 1; transform: none; } }

.auth-head { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.15rem; }
.brand-glyph { flex: 0 0 auto; filter: drop-shadow(0 6px 18px rgba(203,166,247,.38)); }
.auth-id { display: flex; flex-direction: column; line-height: 1.22; min-width: 0; }
.auth-id-name { font-weight: 800; font-size: .98rem; color: #fff; letter-spacing: .015em; }
.auth-id-sub { font-size: .68rem; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }
.auth-app-chip {
  margin-left: auto; font-family: var(--mono); font-size: .68rem; color: #e2d7ff;
  background: rgba(203,166,247,.14); border: 1px solid rgba(203,166,247,.32);
  border-radius: 999px; padding: .18rem .55rem;
  max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.auth-title { font-size: 1.5rem; margin: 0 0 .3rem; letter-spacing: -.02em; color: #fff; }
.auth-lead { color: var(--muted); font-size: .92rem; margin: 0 0 1.15rem; }
.auth-lead strong { color: #fff; }

.auth-panel { margin: 0; background: transparent; border: 0; padding: 0; }
.auth-panel .auth-links { margin-top: .7rem; }
.auth-divider { display: flex; align-items: center; gap: .7rem; margin: 1.1rem 0; color: var(--muted);
  font-size: .68rem; text-transform: uppercase; letter-spacing: .16em; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(203,166,247,.35), transparent); }
.auth-panel-alt p { margin: 0 0 .6rem; }

.auth-body .btn { border-radius: 10px; }
.auth-body .btn-primary {
  background: linear-gradient(135deg, #cba6f7, #89b4fa);
  border-color: transparent; color: #15121f; font-weight: 800;
  box-shadow: 0 10px 26px rgba(137,180,250,.28);
}
.auth-body .btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.auth-body .btn-ghost { border-color: rgba(205,214,244,.2); }

.ms-btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  background: rgba(205,214,244,.07); border: 1px solid rgba(205,214,244,.2); color: #eef1f8; font-weight: 600; }
.ms-btn:hover { background: rgba(205,214,244,.14); transform: translateY(-1px); }
.google-btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18); color: #eef1f8; font-weight: 600; }
.google-btn:hover { background: rgba(255,255,255,.12); transform: translateY(-1px); }

.auth-body .field > span { color: #c3c9d6; }
.auth-body input[type=text], .auth-body input[type=email], .auth-body input[type=password] {
  background: rgba(15,15,24,.72); border-color: rgba(205,214,244,.16); color: #eef1f8;
  padding: .58rem .7rem; transition: border-color .2s, box-shadow .2s;
}
.auth-body input:focus { outline: none; border-color: #cba6f7; box-shadow: 0 0 0 3px rgba(203,166,247,.18); }

.auth-links { font-size: .85rem; margin: .6rem 0 0; }
.auth-links a { color: #cba6f7; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

.auth-foot { margin: 1.25rem 0 0; text-align: center; font-size: .76rem; color: #7f879c; }
.auth-foot strong { color: #cba6f7; font-weight: 700; }

@media (max-width: 460px) {
  .auth-card { padding: 1.5rem 1.2rem 1.25rem; border-radius: 16px; }
  .auth-title { font-size: 1.32rem; }
  .auth-app-chip { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-bg .orb { animation: none; }
  .auth-card { animation: none; }
  .auth-body .btn-primary:hover, .ms-btn:hover { transform: none; }
}

/* ======================================================================== */
/*  Sign-in appearance — five per-user themes, all CSS-only except the two   */
/*  canvas layers. `data-theme` is set on <html> before first paint from the */
/*  `cegc_theme` cookie, so there is no flash between designs. Only the auth */
/*  stage changes; console pages are untouched.                              */
/* ======================================================================== */

/* The three CSS-only layers stay hidden until their theme is selected. */
.auth-mesh, .auth-rings, .auth-coderain { display: none; }

.auth-mesh { position: absolute; inset: 0; z-index: 0; filter: blur(60px); opacity: .7; }
.auth-mesh span { position: absolute; border-radius: 50%; animation: mesh-drift 14s ease-in-out infinite; }
.auth-mesh .m1 { width: 52vmax; height: 52vmax; background: #cba6f7; top: -14%; left: -10%; }
.auth-mesh .m2 { width: 46vmax; height: 46vmax; background: #89b4fa; bottom: -18%; right: -12%; animation-delay: -4s; }
.auth-mesh .m3 { width: 38vmax; height: 38vmax; background: #f38ba8; top: 38%; left: 38%; animation-delay: -8s; }
.auth-mesh .m4 { width: 32vmax; height: 32vmax; background: #a6e3a1; bottom: 6%; left: 18%; animation-delay: -2s; opacity: .5; }
@keyframes mesh-drift { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(40px,-30px) scale(1.1); } }

.auth-rings { position: absolute; inset: 0; z-index: 0; }
.auth-rings .ring {
  position: absolute; left: 50%; top: 50%; border-radius: 50%;
  border: 1.5px solid; animation: ring-spin 18s linear infinite;
}
.auth-rings .r1 { width: 520px; height: 520px; margin: -260px 0 0 -260px; border-color: rgba(203,166,247,.35); animation-duration: 20s; }
.auth-rings .r2 { width: 380px; height: 380px; margin: -190px 0 0 -190px; border-color: rgba(137,180,250,.4); animation-duration: 14s; animation-direction: reverse; }
.auth-rings .r3 { width: 240px; height: 240px; margin: -120px 0 0 -120px; border-color: rgba(243,139,168,.45); animation-duration: 10s; }
.auth-rings .r4 { width: 660px; height: 660px; margin: -330px 0 0 -330px; border-color: rgba(166,227,161,.2); animation-duration: 26s; animation-direction: reverse; }
@keyframes ring-spin { to { transform: rotate(360deg); } }

.auth-coderain { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; opacity: .4; }

/* Layer visibility per theme. */
html[data-theme="mesh"] .auth-mesh { display: block; }
html[data-theme="rings"] .auth-rings { display: block; }
html[data-theme="coderain"] .auth-coderain { display: block; }

html[data-theme="mesh"] .orb, html[data-theme="rings"] .orb,
html[data-theme="coderain"] .orb, html[data-theme="particles"] .orb,
html[data-theme="mesh"] .aurora-grid, html[data-theme="rings"] .aurora-grid,
html[data-theme="coderain"] .aurora-grid, html[data-theme="particles"] .aurora-grid { display: none; }

html[data-theme="mesh"] .auth-particles, html[data-theme="rings"] .auth-particles,
html[data-theme="coderain"] .auth-particles { display: none; }

html[data-theme="coderain"] .auth-body { background: #0a0a14; }

@media (prefers-reduced-motion: reduce) {
  .auth-mesh span { animation: none; }
  .auth-rings .ring { animation: none; }
}

/* ------------------------------------------------- appearance picker ----- */
.auth-themes { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin: .5rem 0 0; }
.auth-themes-label { font-size: .74rem; color: var(--muted); letter-spacing: .04em; }

.auth-themes .theme-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .28rem .6rem; border-radius: 999px; font-size: .78rem;
  color: var(--text); text-decoration: none; cursor: pointer;
  border: 1px solid rgba(205,214,244,.2); background: rgba(255,255,255,.03);
  transition: border-color .18s, background .18s, transform .18s;
}
.auth-themes .theme-chip:hover { background: rgba(203,166,247,.12); border-color: rgba(203,166,247,.5); transform: translateY(-1px); }
.auth-themes .theme-chip.active { border-color: rgba(203,166,247,.85); background: rgba(203,166,247,.16); color: #fff; }

.theme-dot { width: 13px; height: 13px; border-radius: 50%; flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.theme-chip-aurora .theme-dot    { background: linear-gradient(135deg, #cba6f7, #89b4fa); }
.theme-chip-mesh .theme-dot      { background: linear-gradient(135deg, #cba6f7, #f38ba8); }
.theme-chip-rings .theme-dot     { background: radial-gradient(circle at 32% 30%, #89b4fa, #f38ba8); }
.theme-chip-coderain .theme-dot  { background: linear-gradient(135deg, #a6e3a1, #1e1e2e); }
.theme-chip-particles .theme-dot { background: radial-gradient(circle, #cba6f7, #0f0f1a); }

/* On the sign-in stage the picker floats at the bottom of the viewport. */
.auth-themes-float {
  position: absolute; left: 50%; bottom: 1.1rem; transform: translateX(-50%);
  z-index: 2; margin: 0; gap: .35rem;
}
.auth-themes-float .auth-themes-label { display: none; }
.auth-themes-float .theme-chip {
  padding: .32rem; border-radius: 999px;
  background: rgba(20,20,32,.5); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-color: rgba(205,214,244,.18); color: #eef1f8;
}
@media (max-width: 420px) { .auth-themes-float { bottom: .7rem; } }

/* ------------------------------------------------------------ analytics -- */
.bars { display: flex; flex-direction: column; gap: .25rem; }
.bar-row { display: grid; grid-template-columns: 58px 1fr 44px; align-items: center; gap: .5rem; font-size: .78rem; }
.bar-day { color: var(--muted); font-family: var(--mono); }
.bar-track { background: var(--panel-2); border-radius: 4px; height: 12px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--brand); border-radius: 4px; min-width: 2px; }
.bar-val { text-align: right; color: var(--muted); }
.toplist { list-style: none; margin: 0; padding: 0; }
.toplist li { display: flex; justify-content: space-between; gap: .75rem; padding: .3rem 0;
  border-bottom: 1px solid var(--line); font-size: .85rem; }
.toplist li:last-child { border-bottom: 0; }
.top-key { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- tabs --- */
.tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin: 1rem 0 0;
  border-bottom: 1px solid var(--line); }
.tab { padding: .5rem .9rem; border-radius: 10px 10px 0 0; color: var(--muted);
  text-decoration: none; font-size: .9rem; border: 1px solid transparent; border-bottom: none; }
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { color: var(--text); background: var(--panel); border-color: var(--line); font-weight: 600; }
.tabpane { padding-top: 1rem; }
.tabpane[hidden] { display: none; }

/* ------------------------------------------------------------ notices ---- */
.mailbox-warning p { margin: .5rem 0 0; }

@media print {
  .topbar, .nav, .footer, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  ul.codes code { border: 1px solid #999; }
}
