:root {
  --black: #070706;
  --black-soft: #10100e;
  --panel: rgba(22, 21, 18, .76);
  --panel-solid: #151411;
  --line: rgba(218, 186, 112, .22);
  --gold: #d8b86f;
  --gold-light: #f0d99b;
  --gold-dark: #8f7138;
  --ivory: #f4f0e7;
  --muted: #a9a398;
  --healthy: #77c496;
  --warning: #e1b85e;
  --critical: #e06d67;
  --neutral: #9ca1aa;
  --radius: 18px;
  --shadow: 0 30px 80px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--black); color: var(--ivory); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(216,184,111,.09), transparent 28rem),
    radial-gradient(circle at 88% 22%, rgba(216,184,111,.045), transparent 26rem),
    linear-gradient(145deg, #090908 0%, #050504 72%);
  letter-spacing: .01em;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}

.ambient { position: fixed; inset: 0; pointer-events: none; border: 1px solid rgba(216,184,111,.05); margin: 12px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .82rem; }

.topbar {
  position: relative;
  z-index: 2;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 39px; height: 39px; display: grid; place-items: center;
  border: 1px solid var(--gold); color: var(--gold-light); border-radius: 50%;
  font: italic 600 1.15rem Georgia, serif; box-shadow: inset 0 0 0 4px var(--black);
  background: linear-gradient(145deg, #2b261b, #0e0d0b);
}
.brand strong { display: block; font-size: .92rem; letter-spacing: .18em; }
.brand small { display: block; color: var(--muted); font-size: .63rem; margin-top: 3px; letter-spacing: .08em; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.live-pill {
  border: 1px solid var(--line); border-radius: 999px; padding: 9px 13px;
  color: #d6d1c7; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase;
  background: rgba(255,255,255,.025);
}
.live-pill i { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--healthy); box-shadow: 0 0 14px var(--healthy); }

main { position: relative; z-index: 1; width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
h1, h2, h3, p { margin-top: 0; }
h1 { font: 400 clamp(2.7rem, 7vw, 6.4rem)/.93 Georgia, "Times New Roman", serif; letter-spacing: -.045em; }
h1 em { color: var(--gold-light); font-weight: 400; }
h2 { font: 400 1.85rem/1.1 Georgia, serif; }
h3 { font: 400 1.25rem Georgia, serif; }
.eyebrow { color: var(--gold); font-size: .68rem; font-weight: 700; letter-spacing: .25em; margin-bottom: 22px; }
.lead { max-width: 600px; color: var(--muted); font-size: 1rem; line-height: 1.7; }

.auth-shell { min-height: calc(100vh - 155px); padding: 10vh 0 80px; max-width: 850px; }
.auth-shell.compact { display: grid; justify-items: start; align-content: center; padding-top: 4vh; }
.auth-card {
  position: relative; max-width: 520px; margin-top: 45px; padding: 32px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); backdrop-filter: blur(16px); box-shadow: var(--shadow);
}
.auth-card p { color: var(--muted); line-height: 1.6; }
.card-number { position: absolute; right: 24px; top: 23px; color: var(--gold-dark); font: 400 1.05rem Georgia, serif; letter-spacing: .16em; }
.message { min-height: 24px; color: var(--gold-light); margin-top: 18px; }

label, legend { color: #c9c3b8; font-size: .78rem; letter-spacing: .06em; }
input, select {
  width: 100%; margin-top: 9px; padding: 13px 14px; border: 1px solid rgba(216,184,111,.22); border-radius: 10px;
  color: var(--ivory); background: rgba(0,0,0,.35); outline: none; font: inherit;
}
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(216,184,111,.09); }
button { font: inherit; cursor: pointer; }
.gold-button {
  width: 100%; border: 0; border-radius: 10px; padding: 14px 18px; margin-top: 20px;
  color: #11100d; font-weight: 750; background: linear-gradient(120deg, var(--gold-dark), var(--gold-light) 48%, #b8934b);
  box-shadow: 0 12px 35px rgba(216,184,111,.13); transition: transform .2s, filter .2s;
}
.gold-button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.ghost { padding: 9px 13px; border: 1px solid var(--line); border-radius: 9px; color: var(--ivory); background: transparent; }
.ghost:hover { border-color: var(--gold); }

.dashboard { padding: 8vh 0 90px; }
.hero-row { display: flex; justify-content: space-between; align-items: end; gap: 40px; margin-bottom: 70px; }
.hero-row h1 { margin-bottom: 0; }
.metric-hero { min-width: 180px; padding: 22px 0 5px 28px; border-left: 1px solid var(--gold); }
.metric-hero span { display: block; color: var(--gold-light); font: 400 3.8rem/.9 Georgia, serif; }
.metric-hero small { color: var(--muted); }
.section-block { margin-top: 56px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; padding-bottom: 17px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.section-heading > div { display: flex; align-items: baseline; gap: 14px; }
.section-heading h2 { margin: 0; }
.section-index { color: var(--gold); font-size: .68rem; letter-spacing: .15em; }

.systems-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.system-card {
  overflow: hidden; border: 1px solid rgba(216,184,111,.16); border-radius: var(--radius); background: linear-gradient(145deg, rgba(24,23,20,.96), rgba(12,12,10,.9));
  box-shadow: var(--shadow);
}
.system-head { display: flex; justify-content: space-between; gap: 15px; padding: 23px; border-bottom: 1px solid rgba(216,184,111,.11); }
.system-head h3 { margin: 0 0 5px; }
.system-head small { color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: .68rem; letter-spacing: .11em; text-transform: uppercase; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 11px currentColor; }
.status.healthy { color: var(--healthy); }
.status.warning { color: var(--warning); }
.status.critical { color: var(--critical); }
.status.neutral { color: var(--neutral); }
.service { padding: 18px 23px; border-bottom: 1px solid rgba(255,255,255,.045); }
.service:last-child { border: 0; }
.service-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.service-title strong { font-size: .86rem; }
.sensors { display: grid; gap: 8px; }
.sensor { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; align-items: center; padding: 10px 0; }
.sensor + .sensor { border-top: 1px solid rgba(255,255,255,.04); }
.sensor-name { color: #d9d4ca; font-size: .8rem; }
.sensor-value { color: var(--ivory); font: 400 1rem Georgia, serif; text-align: right; }
.sensor-time, .sensor-message { color: #77736c; font-size: .67rem; }
.sensor-message { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.grant-layout { display: grid; grid-template-columns: minmax(280px, .75fr) minmax(340px, 1.25fr); gap: 24px; }
.grant-form, .new-link, .grant-row { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.grant-form { padding: 25px; }
.grant-form label { display: block; margin-top: 18px; }
.grant-form fieldset { border: 0; padding: 0; margin: 22px 0 0; }
.check-list { display: grid; gap: 8px; margin-top: 10px; }
.check-option { display: flex; gap: 9px; align-items: center; padding: 11px; border: 1px solid rgba(255,255,255,.07); border-radius: 9px; }
.check-option input { width: auto; margin: 0; accent-color: var(--gold); }
.new-link { padding: 20px; margin-bottom: 14px; }
.new-link span { color: var(--gold); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; }
.new-link code { display: block; margin: 13px 0; word-break: break-all; color: var(--gold-light); font-size: .75rem; }
.grant-list { display: grid; gap: 12px; }
.grant-row { padding: 19px; display: grid; grid-template-columns: 1fr auto; gap: 8px 15px; }
.grant-row h3 { margin: 0; }
.grant-meta { color: var(--muted); font-size: .72rem; }
.grant-row .ghost { align-self: center; grid-row: 1 / span 2; grid-column: 2; }

.pulse-ring { width: 44px; height: 44px; border: 1px solid var(--gold); border-radius: 50%; margin-bottom: 35px; position: relative; }
.pulse-ring::after { content: ""; position: absolute; inset: -1px; border: 1px solid var(--gold); border-radius: inherit; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { to { transform: scale(2.2); opacity: 0; } }

footer { position: relative; z-index: 1; width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 25px 0 34px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); color: #77736c; font-size: .68rem; letter-spacing: .13em; text-transform: uppercase; }

@media (max-width: 760px) {
  .topbar, main, footer { width: min(100% - 26px, 1180px); }
  .brand small { display: none; }
  .live-pill { padding: 8px 10px; }
  .auth-shell { padding-top: 9vh; }
  h1 { font-size: clamp(2.7rem, 15vw, 4.7rem); }
  .hero-row { align-items: start; flex-direction: column; margin-bottom: 45px; }
  .metric-hero { min-width: auto; }
  .systems-grid { grid-template-columns: 1fr; }
  .grant-layout { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; gap: 15px; }
  .section-heading .muted { display: none; }
  footer { flex-direction: column; gap: 8px; }
}

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

