/* crAIready Mission Control — "Orbital Mission Control" deep-space HUD.
   Palette is multi-signal on purpose: this is an ops console where colour
   encodes state (cyan=primary, green=ok, amber=warn, red=down, violet=data). */

:root {
  --void: #070b14;
  --deep: #0b1120;
  --panel: #0e1726;
  --panel-2: #122036;
  --line: #1c2a44;
  --line-bright: #294063;
  --cyan: #4de2f0;
  --cyan-soft: rgba(77, 226, 240, 0.14);
  --cyan-line: rgba(77, 226, 240, 0.35);
  --amber: #ffb454;
  --green: #46e5a0;
  --red: #ff5c7a;
  --violet: #8b7bf0;
  --text: #c7d4e8;
  --muted: #6b7c99;
  --bright: #eaf2ff;

  --display: "Chakra Petch", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --body: "Inter", system-ui, sans-serif;

  --radius: 4px;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--body);
  color: var(--text);
  background: var(--void);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(77, 226, 240, 0.08), transparent 70%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(139, 123, 240, 0.07), transparent 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* faint grid + scanline atmosphere over everything */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: 0.18;
  mask-image: radial-gradient(ellipse 90% 90% at 50% 30%, #000 40%, transparent 95%);
}
@media (prefers-reduced-motion: reduce) {
  .boot__glyph, .pulse, .live-dot { animation: none !important; }
}

a { color: var(--cyan); text-decoration: none; }
button { font-family: var(--body); cursor: pointer; }
::selection { background: var(--cyan); color: var(--void); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-bright); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------------ boot */
.boot {
  position: fixed; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
}
.boot__glyph {
  width: 64px; height: 64px; border-radius: 50%;
  border: 2px solid var(--cyan); border-top-color: transparent;
  box-shadow: 0 0 24px var(--cyan-line), inset 0 0 18px var(--cyan-soft);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot__label {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.28em; color: var(--muted);
}

/* ------------------------------------------------------------------ login */
.login {
  position: fixed; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login__card {
  position: relative; z-index: 2;
  width: 100%; max-width: 400px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-bright);
  padding: 40px 34px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(77, 226, 240, 0.05);
}
.login__brand {
  font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: 0.04em;
  color: var(--bright); margin-bottom: 4px;
}
.login__brand b { color: var(--cyan); }
.login__sub {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.24em; color: var(--muted);
  margin-bottom: 30px;
}
.login__err {
  display: none; margin-top: 14px; padding: 10px 12px;
  background: rgba(255, 92, 122, 0.1); border: 1px solid rgba(255, 92, 122, 0.4);
  color: var(--red); font-size: 13px;
}

/* ------------------------------------------------------------------ shell */
.shell { position: relative; z-index: 2; display: flex; height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, rgba(14, 23, 38, 0.9), rgba(11, 17, 32, 0.9));
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  backdrop-filter: blur(8px);
}
.sidebar__brand {
  padding: 22px 22px 18px; border-bottom: 1px solid var(--line);
}
.sidebar__brand h1 {
  font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: 0.03em; color: var(--bright);
}
.sidebar__brand h1 b { color: var(--cyan); }
.sidebar__brand span {
  display: block; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.26em; color: var(--muted); margin-top: 3px;
}
.nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav__group { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.22em; color: var(--muted); padding: 16px 12px 8px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; margin-bottom: 2px; border-radius: var(--radius);
  color: var(--text); font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent; transition: all 0.14s;
}
.nav a:hover { background: var(--cyan-soft); color: var(--bright); }
.nav a.active {
  background: linear-gradient(90deg, var(--cyan-soft), transparent);
  border-color: var(--cyan-line); color: var(--bright);
  box-shadow: inset 2px 0 0 var(--cyan);
}
.nav a .ico { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav a.active .ico { color: var(--cyan); opacity: 1; }
.nav__count { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.sidebar__foot { padding: 14px 18px; border-top: 1px solid var(--line); font-size: 12px; }
.sidebar__user { color: var(--bright); font-weight: 500; }
.sidebar__role { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; color: var(--cyan); }

/* main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; flex-shrink: 0; display: flex; align-items: center; gap: 24px;
  padding: 0 28px; border-bottom: 1px solid var(--line);
  background: rgba(11, 17, 32, 0.6); backdrop-filter: blur(8px);
}
.topbar h2 { font-family: var(--display); font-weight: 600; font-size: 17px; letter-spacing: 0.02em; color: var(--bright); }
.topbar__crumb { font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; color: var(--muted); }
.topbar__telemetry { margin-left: auto; display: flex; gap: 22px; align-items: center; }
.tele { display: flex; flex-direction: column; align-items: flex-end; }
.tele b { font-family: var(--mono); font-size: 14px; color: var(--bright); }
.tele span { font-family: var(--mono); font-size: 9px; letter-spacing: 0.18em; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

.view { flex: 1; overflow-y: auto; padding: 28px; }

/* ------------------------------------------------------------------ panels */
.panel {
  position: relative; background: linear-gradient(160deg, rgba(18, 32, 54, 0.6), rgba(14, 23, 38, 0.6));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.panel--bracket::before, .panel--bracket::after {
  content: ""; position: absolute; width: 14px; height: 14px; border: 1.5px solid var(--cyan-line); pointer-events: none;
}
.panel--bracket::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel--bracket::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.panel__head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.panel__head h3 { font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: 0.04em; color: var(--bright); text-transform: uppercase; }
.panel__head .tag { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: var(--muted); }
.panel__head .spacer { margin-left: auto; }

.grid { display: grid; gap: 18px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--2 { grid-template-columns: 1.6fr 1fr; }
.grid--main { grid-template-columns: 1fr; }
@media (max-width: 1100px) { .grid--2 { grid-template-columns: 1fr; } }

/* stat tile */
.stat { position: relative; overflow: hidden; }
.stat__label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; color: var(--muted); text-transform: uppercase; }
.stat__value { font-family: var(--display); font-weight: 700; font-size: 34px; color: var(--bright); line-height: 1.1; margin-top: 8px; }
.stat__value .unit { font-size: 16px; color: var(--muted); margin-left: 4px; }
.stat__foot { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 6px; }
.stat__spark { position: absolute; right: 0; bottom: 0; width: 60%; height: 42px; opacity: 0.5; }
.stat--cyan .stat__value { color: var(--cyan); text-shadow: 0 0 18px var(--cyan-line); }
.stat--green .stat__value { color: var(--green); }
.stat--amber .stat__value { color: var(--amber); }
.stat--violet .stat__value { color: var(--violet); }

/* ------------------------------------------------------------------ fleet map */
.fleet { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 6px; min-height: 220px; }
.fleet__empty { width: 100%; text-align: center; color: var(--muted); font-family: var(--mono); font-size: 12px; padding: 40px; }
.node {
  flex: 0 0 240px; background: var(--deep); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.node--off { opacity: 0.55; }
.node__top { display: flex; align-items: center; gap: 8px; }
.node__name { font-family: var(--display); font-weight: 600; font-size: 14px; color: var(--bright); }
.node__host { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.node__status { margin-left: auto; font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; padding: 3px 7px; border-radius: 3px; }
.node__rings { display: flex; gap: 14px; }
.node__cells { display: grid; grid-template-columns: repeat(auto-fill, 16px); gap: 5px; }
.cell { width: 16px; height: 16px; border-radius: 2px; background: var(--line); border: 1px solid var(--line-bright); }
.cell--running { background: var(--green); box-shadow: 0 0 7px rgba(70, 229, 160, 0.6); border-color: var(--green); }
.cell--provisioning { background: var(--amber); animation: pulse 1.4s infinite; border-color: var(--amber); }
.cell--updating { background: var(--cyan); animation: pulse 1.4s infinite; border-color: var(--cyan); }
.cell--error { background: var(--red); box-shadow: 0 0 7px rgba(255, 92, 122, 0.6); border-color: var(--red); }
.cell--stopped { background: var(--muted); }
.cell--free { background: transparent; }
.node__cap { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.node__cap b { color: var(--text); }

/* radial gauge */
.gauge { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gauge__ring {
  width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(closest-side, var(--deep) 72%, transparent 73%),
    conic-gradient(var(--g-color) calc(var(--g) * 1%), var(--line) 0);
}
.gauge__val { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--bright); }
.gauge__label { font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; color: var(--muted); }

/* ------------------------------------------------------------------ tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid rgba(28, 42, 68, 0.5); font-size: 13.5px; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(77, 226, 240, 0.04); }
td .mono, .mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
td .primary { color: var(--bright); font-weight: 500; }
.empty-row td { text-align: center; color: var(--muted); font-family: var(--mono); padding: 36px; font-size: 12px; }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 3px; border: 1px solid currentColor;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok, .badge--running, .badge--active, .badge--online { color: var(--green); background: rgba(70, 229, 160, 0.08); }
.badge--warn, .badge--provisioning, .badge--updating, .badge--trialing, .badge--past_due, .badge--paused, .badge--suspended { color: var(--amber); background: rgba(255, 180, 84, 0.08); }
.badge--error, .badge--down, .badge--cancelled, .badge--offline, .badge--suspended { color: var(--red); background: rgba(255, 92, 122, 0.08); }
.badge--stopped, .badge--unknown, .badge--neutral { color: var(--muted); background: rgba(107, 124, 153, 0.08); }
.badge--info { color: var(--cyan); background: var(--cyan-soft); }

/* ------------------------------------------------------------------ buttons + forms */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em;
  padding: 9px 16px; border-radius: var(--radius);
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line-bright);
  transition: all 0.14s;
}
.btn:hover { border-color: var(--cyan-line); color: var(--bright); box-shadow: 0 0 14px var(--cyan-soft); }
.btn--primary { background: linear-gradient(180deg, rgba(77, 226, 240, 0.18), rgba(77, 226, 240, 0.05)); border-color: var(--cyan); color: var(--cyan); }
.btn--primary:hover { background: var(--cyan); color: var(--void); }
.btn--danger:hover { border-color: var(--red); color: var(--red); box-shadow: 0 0 14px rgba(255, 92, 122, 0.2); }
.btn--sm { padding: 6px 11px; font-size: 11px; }
.btn--ghost { background: transparent; border-color: var(--line); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.field { margin-bottom: 16px; }
.field label { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }
.input, .select, textarea.input {
  width: 100%; padding: 11px 13px; font-family: var(--body); font-size: 14px;
  color: var(--bright); background: var(--void); border: 1px solid var(--line-bright); border-radius: var(--radius);
  transition: border 0.14s;
}
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-soft); }
.field__row { display: flex; gap: 14px; }
.field__row > * { flex: 1; }
.hint { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 6px; }

/* ------------------------------------------------------------------ modal + toast */
.modal-bg {
  position: fixed; inset: 0; z-index: 40; display: none;
  background: rgba(4, 7, 14, 0.7); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 24px;
}
.modal-bg.open { display: flex; }
.modal {
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-bright); border-radius: var(--radius);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
}
.modal__head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal__head h3 { font-family: var(--display); font-weight: 600; font-size: 15px; letter-spacing: 0.03em; color: var(--bright); text-transform: uppercase; }
.modal__close { margin-left: auto; background: transparent; border: 0; color: var(--muted); font-size: 22px; line-height: 1; }
.modal__close:hover { color: var(--red); }
.modal__body { padding: 22px; }
.modal__foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--line); }

#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast {
  font-family: var(--mono); font-size: 12px; padding: 13px 16px; min-width: 240px; max-width: 380px;
  background: var(--panel-2); border-left: 3px solid var(--cyan); border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); color: var(--text);
  animation: slidein 0.22s ease;
}
.toast--ok { border-left-color: var(--green); }
.toast--err { border-left-color: var(--red); color: var(--red); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* utility */
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.mb { margin-bottom: 18px; }
.actions { display: flex; gap: 6px; }
.code-pill { font-family: var(--mono); font-size: 11px; background: var(--void); border: 1px solid var(--line); padding: 3px 8px; border-radius: 3px; color: var(--cyan); }
.bar { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--violet)); }
.section-title { font-family: var(--display); font-weight: 600; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 4px 0 14px; }
