:root {
  --bg: #0b0f1a;
  --bg-soft: #0f1524;
  --panel: #10182c;
  --text: #dbe7ff;
  --text-dim: #9cb3db;
  --accent: #4ec3ff;
  --accent-2: #9bf6ff;
  --warning: #ffcc66;
  --error: #ff6b6b;
  --ok: #66ffa6;
  --outline: #223252;
  --outline-2: #2a3a5f;
  --scanline: rgba(255, 255, 255, 0.04);
  --shadow: rgba(0, 0, 0, 0.5);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(1200px 800px at 10% 0%, #0e1422, var(--bg))
    no-repeat fixed;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu,
    Cantarell, "Helvetica Neue", Arial, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

/* Ambient overlay */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(
      to bottom,
      var(--scanline) 1px,
      transparent 1px
    ),
    radial-gradient(800px 400px at 80% -10%, rgba(78, 195, 255, 0.08), transparent);
  background-size: 100% 3px, auto;
  mix-blend-mode: overlay;
  z-index: 0;
}

/* Header */
.mc-header {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px clamp(16px, 3vw, 32px);
  background: linear-gradient(180deg, #0b0f1ad0, #0b0f1a 70%);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--outline);
  z-index: 10;
}

.badge {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
  letter-spacing: 0.2em;
  font-weight: 600;
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid var(--outline);
  border-radius: 4px;
  color: var(--accent);
}

.badge-inline {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border: 1px solid var(--outline);
  border-radius: 4px;
  color: var(--warning);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
}

.title {
  margin: 0;
  font-size: clamp(22px, 3vw, 28px);
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Icon helpers */
.icon {
  display: inline-block;
  vertical-align: -2px;
}
.with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  background: linear-gradient(180deg, #15223b, #0f1b33);
  color: var(--text);
  border: 1px solid var(--outline);
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    transform 0.05s ease;
}
.btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #4ec3ff22, 0 6px 18px #00000066 inset;
}
.btn:active {
  transform: translateY(1px);
}
.btn-small {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 7px;
}
.btn.ghost {
  background: transparent;
}
.btn.danger {
  border-color: #5b1a1a;
  background: linear-gradient(180deg, #371616, #2a0f0f);
}

/* Inputs */
.input {
  appearance: none;
  background: #0f1730;
  color: var(--text);
  border: 1px solid var(--outline-2);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 40px;
  min-width: 200px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    background 0.15s ease;
}
.input::placeholder {
  color: #8aa1c7;
  opacity: 0.8;
}
textarea.input {
  resize: vertical;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #4ec3ff22, 0 0 0 1px #4ec3ff55 inset;
  background: #101c37;
}

/* Layout blocks */
.container {
  padding: 24px clamp(16px, 3vw, 32px) 40px;
  position: relative;
  z-index: 1;
}

.panel {
  background: linear-gradient(180deg, var(--panel), #0b1223);
  border: 1px solid var(--outline);
  border-radius: 12px;
  box-shadow: 0 10px 30px var(--shadow);
  overflow: clip;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--outline);
}

.panel-title {
  margin: 0;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-2);
}

.panel-tools {
  display: flex;
  gap: 12px;
  align-items: center;
}

.filter {
  display: grid;
  gap: 6px;
}
.filter-label {
  font-size: 12px;
  color: var(--text-dim);
}

/* Status */
.status {
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text-dim);
  border-bottom: 1px dashed var(--outline);
}

/* Quotes */
.quotes {
  list-style: none;
  margin: 0;
  padding: 8px;
  display: grid;
  gap: 10px;
}

.quote {
  background: linear-gradient(180deg, #0e1834, #0c142a);
  border: 1px solid #1a2a4f;
  border-radius: 10px;
  padding: 14px 14px 10px;
}

.quote-text {
  margin: 0 0 10px;
  font-size: clamp(16px, 2.4vw, 18px);
  letter-spacing: 0.01em;
}

.quote-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: baseline;
  color: var(--text-dim);
  font-size: 13px;
}

.quote-author::before {
  content: "Author: ";
  color: var(--accent);
}

/* Tags */
.quote-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.quote-tags li {
  background: #0f213f;
  border: 1px solid #224070;
  color: var(--accent);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.quote-tags::before {
  content: "Tags:";
  color: var(--warning);
  margin-right: 8px;
  align-self: center;
}

.quote-time::before {
  content: "Received: ";
  color: var(--ok);
}

.quote-id::before {
  content: "ID: ";
  color: var(--accent-2);
  margin-left: 6px;
}

.quote-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Admin utilities */
.hidden {
  display: none !important;
}

.admin .panel-head {
  border-bottom: 1px solid var(--outline);
}

.admin-msg {
  color: var(--text-dim);
  font-size: 13px;
}

/* Shared form grid inside dialogs */
.form-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}
.form-grid > label:nth-child(1) {
  grid-column: span 6;
}
.form-grid > label:nth-child(2) {
  grid-column: span 6;
}
.form-grid > .checkbox {
  grid-column: span 12;
}

/* Checkbox line */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  color: var(--text-dim);
}

/* Modal polish + animation */
.modal::backdrop {
  background: radial-gradient(
    50% 50% at 50% 50%,
    rgba(8, 14, 30, 0.8) 0%,
    rgba(8, 14, 30, 0.9) 100%
  );
  backdrop-filter: blur(2px);
}

.modal {
  padding: 0;
  border: none;
  background: transparent;
}

.modal .modal-card {
  background:
    linear-gradient(180deg, #0f1730, #0b1223) padding-box,
    linear-gradient(180deg, #284779, #18284a) border-box;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 18px;
  width: min(620px, 92vw);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6),
    0 0 0 1px #1a2a4f inset, 0 0 80px #153a5c22;
  transform-origin: center;
}

.modal-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.02em;
}
.modal-title.with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.modal-sub {
  margin: 4px 0 12px 0;
  color: var(--text-dim);
  font-size: 13px;
}

.modal .admin-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Modal labels spacing */
.modal .modal-card label > span {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 4px 0 6px 0;
}

/* Open/close animation */
@keyframes modalIn {
  0% {
    opacity: 0;
    transform: scale(0.96);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes modalOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.96);
  }
}
.animate[open] .modal-card {
  animation: modalIn 140ms ease-out forwards;
}
.animate.closing .modal-card {
  animation: modalOut 120ms ease-in forwards;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .animate[open] .modal-card,
  .animate.closing .modal-card {
    animation: none !important;
  }
}

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px clamp(16px, 3vw, 32px);
  border-top: 1px solid var(--outline);
  color: var(--text-dim);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
  letter-spacing: 0.04em;
}

/* Responsive */
@media (max-width: 720px) {
  .form-grid > label:nth-child(1),
  .form-grid > label:nth-child(2) {
    grid-column: span 12;
  }
}
@media (max-width: 540px) {
  .input {
    min-width: 0;
    width: 100%;
  }
}

/* Boot overlay */
.boot {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: radial-gradient(1600px 1000px at 50% -20%, #0f1a2f, #081020);
  color: var(--text);
}

.boot-card {
  position: relative;
  width: min(720px, 92vw);
  padding: 20px 20px 16px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, #0e1730, #0b1223) padding-box,
    linear-gradient(180deg, #284779, #18284a) border-box;
  border: 1px solid transparent;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px #1a2a4f inset,
    0 0 100px #153a5c22;
  overflow: hidden;
}

.boot-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 24px;
  background: linear-gradient(
    180deg,
    rgba(78, 195, 255, 0) 0%,
    rgba(78, 195, 255, 0.22) 50%,
    rgba(78, 195, 255, 0) 100%
  );
  animation: bootScan 1.2s ease-in-out 80ms 1 both;
  filter: blur(0.3px);
}
@keyframes bootScan {
  from {
    top: -24px;
    opacity: 0.4;
  }
  50% {
    opacity: 0.8;
  }
  to {
    top: calc(100% + 24px);
    opacity: 0.4;
  }
}

.boot-head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.12em;
}
.boot-badge {
  border: 1px solid var(--outline);
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--accent);
  font-weight: 600;
}
.boot-title {
  color: var(--accent-2);
  opacity: 0.9;
}

.boot-log {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}
.boot-line {
  opacity: 0;
  transform: translateY(2px);
  animation: bootType 220ms ease-out var(--d) 1 both;
}
.boot-line::after {
  content: " ▉";
  color: var(--accent);
  opacity: 0;
  animation: bootCaret 700ms steps(1, end) calc(var(--d) + 220ms) 2;
}
.boot-line.strong {
  color: var(--ok);
}
@keyframes bootType {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes bootCaret {
  0%,
  49% {
    opacity: 0;
  }
  50%,
  100% {
    opacity: 1;
  }
}

/* Hide content until boot completes */
body.booting > *:not(.boot) {
  opacity: 0;
  transition: opacity 220ms ease;
}
body.ready > *:not(.boot) {
  opacity: 1;
}

/* Reduced motion: quick fade */
@media (prefers-reduced-motion: reduce) {
  .boot-scan,
  .boot-line,
  .boot-line::after {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Telemetry Console */
.console.collapsed .console-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 220ms ease, opacity 220ms ease;
  opacity: 0.8;
}
.console .console-body {
  max-height: 220px;
  overflow: auto;
  transition: max-height 220ms ease;
  border-top: 1px dashed var(--outline);
  background: linear-gradient(180deg, #0e142a, #0b1223);
}

.console-log {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-dim);
  display: grid;
  gap: 6px;
}

.console-log li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: baseline;
  border-left: 2px solid transparent;
  padding-left: 8px;
}

.console-time {
  color: var(--accent-2);
  opacity: 0.9;
}

.console-msg.ok {
  color: var(--ok);
}
.console-msg.err {
  color: var(--error);
}
.console-msg.info {
  color: var(--text-dim);
}

.console-log li.added {
  border-color: var(--ok);
}
.console-log li.updated {
  border-color: var(--warning);
}
.console-log li.removed {
  border-color: var(--error);
}
/* Terminal-styled modals — NASA blue theme */
:root {
  --term-bg: #0b1223;       /* panel bg */
  --term-bg-2: #0f1730;     /* gradient base */
  --term-fg: #dbe7ff;       /* primary text (blue theme) */
  --term-dim: #9cb3db;      /* dim text */
  --term-accent: #4ec3ff;   /* cyan/blue accent */
  --term-warn: #ffcc66;
  --term-err: #ff6b6b;
  --term-border: #1a2a4f;   /* panel border */
  --term-grid: #1a2a4f;     /* grid separators */
  --term-glow: 0 0 24px #4ec3ff22, 0 0 60px #4ec3ff11;
}

.modal::backdrop {
  background: radial-gradient(60% 60% at 50% 20%, rgba(4, 8, 18, 0.85), #050a14)
    no-repeat;
  backdrop-filter: blur(1.5px);
}

.modal {
  padding: 0;
  border: none;
  background: transparent;
}

.modal .modal-card {
  background:
    linear-gradient(180deg, var(--term-bg-2), var(--term-bg)) padding-box,
    linear-gradient(180deg, #284779, #18284a) border-box;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 16px 16px 14px;
  width: min(640px, 94vw);
  color: var(--term-fg);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px #102047 inset,
    var(--term-glow);
  position: relative;
  overflow: hidden;
}

.modal .modal-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 28px;
  background: repeating-linear-gradient(
    90deg,
    rgba(78, 195, 255, 0.16) 0 8px,
    rgba(78, 195, 255, 0.06) 8px 16px
  );
  border-bottom: 1px solid #21335a;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.35;
}

/* Title, subtitle, labels */
.modal-title {
  margin: 0 0 8px 0;
  color: var(--term-accent);
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.modal-title.with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.modal-title::before {
  content: "[";
  color: var(--term-dim);
  margin-right: 6px;
}
.modal-title::after {
  content: "]";
  color: var(--term-dim);
  margin-left: 6px;
}
.modal-sub {
  margin: 2px 0 12px 0;
  color: var(--term-dim);
  font-size: 12px;
  letter-spacing: 0.02em;
}

/* Grid separators */
.modal .form-grid {
  border-top: 1px dashed var(--term-grid);
  border-bottom: 1px dashed var(--term-grid);
  padding: 12px 0;
  margin-bottom: 12px;
}

/* Inputs (blue terminal) */
.modal .input {
  background: #0a1430;
  color: var(--term-fg);
  border: 1px solid #1c2b56;
  border-radius: 8px;
  min-height: 38px;
  padding: 9px 10px;
  box-shadow: inset 0 0 0 1px #0e1a3c, inset 0 12px 24px #00000055;
  caret-color: var(--term-accent);
}
.modal .input::placeholder {
  color: #89a4d6;
  opacity: 0.75;
}
.modal .input:focus {
  border-color: var(--term-accent);
  box-shadow: 0 0 0 2px #4ec3ff22, inset 0 0 0 1px #4ec3ff55;
  background: #0d1938;
  outline: none;
}

/* Checkbox */
.modal .checkbox {
  color: var(--term-dim);
}

/* Buttons (blue terminal keys) */
.modal .btn {
  background: linear-gradient(180deg, #0f1d3a, #0b142a);
  color: var(--term-fg);
  border: 1px solid #21335a;
  border-radius: 8px;
  padding: 9px 13px;
  box-shadow: inset 0 0 0 1px #141f3f;
}
.modal .btn:hover {
  border-color: var(--term-accent);
  box-shadow: 0 0 0 2px #4ec3ff22 inset, var(--term-glow);
}
.modal .btn.ghost {
  background: transparent;
  border-color: #1a2a4f;
}
.modal .btn.danger {
  background: linear-gradient(180deg, #2a1616, #1e0f0f);
  border-color: #5b1a1a;
  color: #ffb3b3;
}

/* Icons tint to blue */
.modal .icon {
  color: var(--term-accent);
}

/* Keep your existing modal animations */