:root {
  color-scheme: dark;
  --ink: #e9e2d3;
  --muted: #9e9a90;
  --night: #080b0d;
  --panel: rgba(17, 21, 22, 0.92);
  --panel-strong: #121719;
  --line: rgba(223, 199, 143, 0.16);
  --gold: #d8b56a;
  --gold-bright: #f1d28a;
  --green: #63c58b;
  --red: #e06f6f;
  --amber: #e7b85f;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--night); }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 72% 8%, rgba(117, 85, 38, 0.13), transparent 32rem),
    linear-gradient(150deg, #0c1113 0%, #070a0b 55%, #0d0f0e 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

button, input { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.1;
  pointer-events: none;
}
.ambient-one { top: -12rem; right: -10rem; background: #d09b42; }
.ambient-two { bottom: -16rem; left: -12rem; background: #436d55; }

.topbar {
  position: relative;
  z-index: 2;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 42px;
  height: 46px;
  display: grid;
  place-items: center;
  color: #101312;
  background: linear-gradient(145deg, var(--gold-bright), #a77a34);
  font-family: Georgia, serif;
  font-weight: 900;
  font-size: 24px;
  clip-path: polygon(50% 0, 92% 18%, 83% 81%, 50% 100%, 17% 81%, 8% 18%);
}
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 19px; letter-spacing: .02em; }
.brand small { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .16em; }

.ghost-button, .admin-actions button, .command-form button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
  border-radius: 8px;
  padding: 10px 15px;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.ghost-button:hover, .admin-actions button:hover, .command-form button:hover { border-color: rgba(216,181,106,.55); background: rgba(216,181,106,.08); }
button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, pre:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }

main { position: relative; z-index: 1; width: min(1180px, calc(100% - 40px)); margin: 24px auto 60px; display: grid; gap: 20px; }

.command-deck, .console-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0,0,0,.34);
}
.command-deck { padding: clamp(22px, 4vw, 42px); position: relative; overflow: hidden; }
.command-deck::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 190px;
  height: 190px;
  border-top: 1px solid rgba(216,181,106,.22);
  border-right: 1px solid rgba(216,181,106,.22);
  transform: translate(80px,-80px) rotate(45deg);
}

.eyebrow { margin: 0 0 5px; color: var(--gold); font-size: 12px; font-weight: 800; letter-spacing: .2em; }
h1, h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; line-height: 1.1; }
h1 { font-size: clamp(34px, 6vw, 58px); font-weight: 600; letter-spacing: -.025em; }
h2 { font-size: clamp(23px, 3vw, 31px); font-weight: 600; }

.status-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; }
.address { display: inline-flex; gap: 9px; align-items: center; margin: 14px 0 0; padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; }
.address:hover { color: var(--gold-bright); }
.status-seal { min-width: 176px; display: flex; align-items: center; gap: 12px; padding: 13px 16px; border: 1px solid var(--line); background: rgba(0,0,0,.22); }
.status-seal small, .status-seal strong { display: block; }
.status-seal small { color: var(--muted); font-size: 11px; letter-spacing: .14em; }
.status-seal strong { font-size: 16px; }
.pulse { width: 11px; height: 11px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 6px rgba(231,184,95,.1); }
.status-seal.online .pulse { background: var(--green); box-shadow: 0 0 0 6px rgba(99,197,139,.1), 0 0 20px rgba(99,197,139,.35); }
.status-seal.offline .pulse { background: var(--red); box-shadow: 0 0 0 6px rgba(224,111,111,.1); }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 34px; }
.metric-card { min-height: 132px; padding: 20px; border: 1px solid rgba(255,255,255,.065); background: rgba(255,255,255,.02); }
.metric-card > span { color: var(--muted); font-size: 13px; }
.metric-card strong { display: block; margin-top: 12px; font-family: Georgia, serif; font-size: clamp(21px, 3vw, 29px); font-weight: 500; }
.metric-card small { display: block; margin-top: 9px; color: var(--muted); }
.meter { height: 3px; margin-top: 16px; overflow: hidden; background: rgba(255,255,255,.07); }
.meter i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #8c713d, var(--gold-bright)); transition: width .45s ease; }

.recovery-panel { margin-top: 16px; padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 25px; border: 1px solid rgba(216,181,106,.2); background: linear-gradient(100deg, rgba(216,181,106,.075), rgba(216,181,106,.015)); }
.recovery-panel h2 { font-family: inherit; font-size: 17px; font-weight: 700; }
.recovery-panel p { max-width: 650px; margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 45px; padding: 11px 18px; border: 1px solid #efd18c; border-radius: 6px; color: #16130d; background: linear-gradient(150deg, #eed18e, #bd8d3e); box-shadow: 0 8px 30px rgba(173,123,45,.12); font-weight: 800; cursor: pointer; }
.primary-button:hover { filter: brightness(1.08); }
.primary-button:disabled { opacity: .48; cursor: wait; }
.wide { width: 100%; margin-top: 15px; }
.notice { min-height: 24px; margin: 13px 0 -8px; color: var(--gold-bright); font-size: 14px; }
.notice.error, .form-message.error { color: #ff9191; }

.console-card { overflow: hidden; }
.console-header { padding: 22px 25px 17px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.console-header h2 { font-size: 24px; }
.live-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.live-label span { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }
pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
#publicLogs, .admin-logs { min-height: 260px; max-height: 420px; overflow: auto; padding: 22px 25px; color: #c7d2c8; background: #090d0e; font: 13px/1.65 "Cascadia Code", "SFMono-Regular", Consolas, monospace; scrollbar-color: #665434 #101415; }
.console-note { margin: 0; padding: 11px 25px 14px; border-top: 1px solid rgba(255,255,255,.04); color: #777d79; background: #0c1011; font-size: 12px; }

.admin-dialog { width: min(900px, calc(100% - 30px)); max-height: calc(100vh - 30px); padding: 0; border: 1px solid rgba(216,181,106,.25); color: var(--ink); background: #101516; box-shadow: 0 30px 100px rgba(0,0,0,.7); }
.admin-dialog::backdrop { background: rgba(2,4,5,.82); backdrop-filter: blur(8px); }
.dialog-shell { position: relative; padding: clamp(25px, 4vw, 40px); }
.dialog-close { position: absolute; top: 13px; right: 15px; width: 38px; height: 38px; border: 0; color: var(--muted); background: none; font-size: 28px; cursor: pointer; }
#loginView { max-width: 430px; margin: 10px auto; }
#loginView > p:not(.eyebrow) { color: var(--muted); }
label { display: block; margin: 20px 0 7px; color: var(--muted); font-size: 14px; }
input { width: 100%; min-height: 46px; border: 1px solid rgba(255,255,255,.12); border-radius: 6px; padding: 10px 12px; color: var(--ink); background: #080c0d; }
.form-message { min-height: 23px; color: var(--gold-bright); font-size: 14px; }
.admin-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.admin-actions { display: flex; gap: 9px; margin: 24px 0 18px; }
.admin-actions .danger { color: #ff9999; border-color: rgba(224,111,111,.3); }
.command-form { margin-bottom: 12px; }
.command-form > div { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding-left: 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 7px; background: #080c0d; }
.command-form input { min-width: 0; border: 0; padding-left: 0; }
.command-form input:focus-visible { outline: 0; }
.command-form button { border-width: 0 0 0 1px; border-radius: 0; }
.admin-logs { min-height: 300px; border: 1px solid rgba(255,255,255,.08); }

@media (max-width: 720px) {
  .topbar, main { width: min(100% - 24px, 1180px); }
  .topbar { padding-top: 16px; }
  .brand small { display: none; }
  .ghost-button { padding: 9px 11px; }
  main { margin-top: 10px; }
  .status-heading, .recovery-panel { align-items: stretch; flex-direction: column; }
  .status-seal { width: 100%; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 105px; }
  .primary-button { width: 100%; }
  .console-header { padding: 18px; }
  #publicLogs, .admin-logs { padding: 18px; font-size: 12px; }
  .admin-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .admin-actions .danger { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
