@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  color-scheme: dark;
  --bg: #070d17;
  --bg-soft: #0c1728;
  --panel: rgba(10, 18, 32, 0.86);
  --panel-strong: #111f36;
  --line: rgba(128, 161, 210, 0.2);
  --text: #eaf2ff;
  --muted: #9bb0cc;
  --accent: #7aa4ff;
  --accent-2: #5fe3d8;
  --danger: #ff6b6b;
  --success: #7be6ab;
  --shadow: 0 26px 72px rgba(0, 0, 0, 0.42);
  --role-glow: rgba(122, 164, 255, 0.28);
  --radius: 22px;
  font-family: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

body[data-role='admin'] {
  --accent: #5fe3d8;
  --accent-2: #f2b24d;
  --role-glow: rgba(95, 227, 216, 0.28);
}

body[data-role='operator'] {
  --accent: #f2b24d;
  --accent-2: #ff7a90;
  --role-glow: rgba(242, 178, 77, 0.28);
}

body[data-role='viewer'] {
  --accent: #7aa4ff;
  --accent-2: #77d0ff;
  --role-glow: rgba(122, 164, 255, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 14% -6%, var(--role-glow), transparent 34%),
    radial-gradient(circle at 92% 2%, rgba(242, 178, 77, 0.16), transparent 26%),
    linear-gradient(180deg, #070d17 0%, #050912 100%);
  color: var(--text);
}

body {
  padding: 28px 18px 40px;
  overflow-x: hidden;
  transition: background 420ms ease, color 300ms ease;
}

#heroModeLabel,
#statusInterface {
  font-family: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.62), transparent 92%);
  opacity: 0.35;
}

.shell {
  width: min(1240px, 100%);
  margin: 0 auto;
}

.login-shell {
  min-height: calc(100vh - 68px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(520px, 100%);
  padding: 28px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(16, 29, 49, 0.98), rgba(10, 19, 33, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.login-card h1 {
  max-width: none;
  margin-top: 14px;
}

.login-card p {
  color: var(--muted);
  line-height: 1.6;
  margin-top: 12px;
}

.login-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent);
  border: 1px solid rgba(15, 118, 110, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.76rem;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.login-button {
  width: 100%;
  margin-top: 6px;
}

.login-feedback {
  min-height: 1.2em;
  margin: 0;
  text-align: center;
}

.login-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.84rem;
}

.admin-panel {
  display: grid;
  gap: 18px;
}

.admin-layout {
  align-items: flex-start;
}

.admin-form {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  padding: 16px;
}

.admin-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
}

.admin-list-header strong {
  color: var(--text);
}

.admin-panel .panel-heading {
  margin-top: 6px;
}

.esp-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.user-card {
  display: grid;
  gap: 12px;
}

.user-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.user-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.user-card-actions button,
.user-card-actions select,
.user-card-actions input {
  min-width: 0;
}

.user-card-actions button {
  padding: 10px 12px;
}

.user-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.pill.admin {
  color: #06111d;
  background: var(--accent);
}

.pill.operator {
  color: #06111d;
  background: var(--accent-2);
}

.pill.viewer {
  color: #06111d;
  background: #b8c4d2;
}

.pill.active {
  color: #06111d;
  background: var(--success);
}

.pill.inactive {
  color: #06111d;
  background: var(--danger);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(290px, 0.85fr);
  gap: 20px;
  margin-bottom: 22px;
}

.hero-copy,
.hero-card,
.status-strip,
.panel {
  position: relative;
  overflow: hidden;
}

.eyebrow {
  margin: 0 0 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.4rem, 4vw, 4.4rem);
  line-height: 0.92;
  max-width: 10ch;
}

.lead {
  max-width: 760px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 18px;
}

.logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
input,
select,
textarea {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

button {
  cursor: pointer;
  padding: 12px 16px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  font-weight: 600;
}

button:hover {
  transform: translateY(-2px);
}

.primary {
  background: linear-gradient(135deg, var(--accent), #3e87d4);
  color: #03111b;
  border: 0;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.24);
}

.secondary {
  background: rgba(255, 255, 255, 0.05);
}

.hero-card {
  padding: 20px;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(21, 40, 66, 0.98), rgba(12, 23, 39, 0.94)),
    radial-gradient(circle at top right, var(--role-glow), transparent 42%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: var(--shadow);
  transition: border-color 260ms ease, box-shadow 260ms ease, transform 260ms ease;
}

.hero-card-top {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.hero-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.55);
  animation: pulse 2s infinite;
}

.hero-card-value {
  margin-top: 20px;
  font-size: clamp(1.6rem, 2.4vw, 2.4rem);
  font-weight: 800;
}

.hero-card-detail {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.hero-card-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.hero-card-stats div {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.hero-card-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 8px;
}

.hero-card-stats strong {
  font-size: 1.02rem;
}

.layout {
  display: grid;
  gap: 18px;
}

.panel {
  background:
    linear-gradient(180deg, rgba(16, 29, 49, 0.97), rgba(10, 19, 33, 0.94)),
    radial-gradient(circle at top right, var(--role-glow), transparent 40%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.panel::before,
.hero-card::before,
.status-strip::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 34%);
  opacity: 0.25;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.status-item {
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: border-color 260ms ease, background 260ms ease, transform 260ms ease;
}

body.role-shift .hero-card {
  animation: role-shift-hero 520ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

body.role-shift .status-strip .status-item {
  animation: role-shift-status 460ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

body.role-shift #heroModeLabel,
body.role-shift #statusInterface {
  animation: role-shift-label 420ms ease;
}

.status-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

.status-item strong {
  font-size: 1rem;
}

.summary-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  padding: 18px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    linear-gradient(135deg, var(--role-glow), rgba(242, 178, 77, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 140px;
  display: flex;
  flex-direction: column;
}

.metric .label {
  color: var(--muted);
  font-size: 0.86rem;
}

.metric .value {
  margin-top: 10px;
  font-size: clamp(1.5rem, 2.6vw, 2.5rem);
  font-weight: 800;
}

.metric .hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.metric-bar {
  margin-top: auto;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.metric-bar::after {
  content: '';
  display: block;
  width: 68%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), rgba(95, 227, 216, 0.25));
}

.metric-bar.online::after {
  width: 82%;
  background: linear-gradient(90deg, var(--success), rgba(123, 230, 171, 0.25));
}

.metric-bar.warning::after {
  width: 48%;
  background: linear-gradient(90deg, var(--accent-2), rgba(242, 178, 77, 0.3));
}

.metric-bar.light::after {
  width: 62%;
  background: linear-gradient(90deg, #7cb7ff, rgba(124, 183, 255, 0.28));
}

.metric-bar.temp::after {
  width: 72%;
  background: linear-gradient(90deg, #ff7e7e, rgba(255, 126, 126, 0.28));
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-heading--tight {
  align-items: flex-start;
}

.section-kicker {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
  margin-bottom: 8px;
  font-weight: 700;
}

.panel-heading p {
  color: var(--muted);
  margin-top: 6px;
}

.panel-controls {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.control-label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.control-label select {
  min-width: 220px;
}

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.84rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.legend-line {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 999px;
}

.legend-line.temp {
  background: var(--accent);
}

.legend-line.light {
  background: var(--accent-2);
}

#chart {
  width: 100%;
  height: auto;
  background:
    radial-gradient(circle at top, var(--role-glow), transparent 45%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stack {
  display: grid;
  gap: 12px;
}

.card {
  display: grid;
  gap: 10px;
  padding: 16px 16px 15px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025)),
    rgba(10, 19, 33, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 40%, rgba(255, 255, 255, 0.14));
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.3);
}

.node-card {
  position: relative;
}

.node-card::after {
  content: '';
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.node-card[data-status='online']::after {
  background: var(--success);
  box-shadow: 0 0 16px rgba(123, 230, 171, 0.45);
}

.node-card:hover .node-metric {
  border-color: color-mix(in srgb, var(--accent) 36%, rgba(255, 255, 255, 0.07));
  transform: translateY(-1px);
}

.alert-card {
  position: relative;
  overflow: hidden;
}

.alert-card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.alert-card:hover::before {
  opacity: 1;
}

.alert-card.alert-warning::before {
  background: linear-gradient(110deg, rgba(242, 178, 77, 0.14), transparent 40%);
}

.alert-card.alert-critical::before {
  background: linear-gradient(110deg, rgba(255, 107, 107, 0.16), transparent 40%);
}

.alert-card.alert-online::before {
  background: linear-gradient(110deg, rgba(123, 230, 171, 0.12), transparent 40%);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge.online {
  color: #07111f;
  background: var(--success);
}

.badge.offline {
  color: #07111f;
  background: #b8c4d2;
}

.badge.warning {
  color: #07111f;
  background: var(--accent-2);
}

.badge.critical {
  color: #07111f;
  background: var(--danger);
}

.meta {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.node-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.node-metric {
  padding: 10px 11px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.node-metric span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.node-metric strong {
  font-size: 0.98rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.form-grid .full {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, white 30%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 24%, transparent 76%);
}

textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

#commandFeedback {
  color: var(--muted);
  font-size: 0.92rem;
}

.hero-copy,
.hero-card,
.panel,
.status-item,
.metric,
.card {
  animation: rise-in 0.65s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.hero-card {
  animation-delay: 0.1s;
}

.summary-grid .metric:nth-child(2) {
  animation-delay: 0.06s;
}

.summary-grid .metric:nth-child(3) {
  animation-delay: 0.12s;
}

.summary-grid .metric:nth-child(4) {
  animation-delay: 0.18s;
}

.stack .card:nth-child(1) {
  animation-delay: 0.04s;
}

.stack .card:nth-child(2) {
  animation-delay: 0.08s;
}

.stack .card:nth-child(3) {
  animation-delay: 0.12s;
}

.stack .card:nth-child(4) {
  animation-delay: 0.16s;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes role-shift-hero {
  0% {
    transform: translateY(0) scale(1);
    box-shadow: var(--shadow);
  }
  45% {
    transform: translateY(-2px) scale(1.005);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 36%, transparent), var(--shadow);
  }
  100% {
    transform: translateY(0) scale(1);
    box-shadow: var(--shadow);
  }
}

@keyframes role-shift-status {
  0% {
    transform: translateY(0);
  }
  45% {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 44%, rgba(255, 255, 255, 0.1));
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes role-shift-label {
  0% {
    opacity: 0.76;
    letter-spacing: 0.03em;
  }
  100% {
    opacity: 1;
    letter-spacing: 0.02em;
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.55);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(21, 128, 61, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(21, 128, 61, 0);
  }
}

@media (max-width: 1000px) {
  .hero,
  .summary-grid,
  .grid-two,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .status-strip {
    grid-template-columns: 1fr 1fr;
  }

  .hero-card-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    padding: 16px 12px 24px;
  }

  h1 {
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .login-card {
    padding: 22px;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .panel-controls {
    width: 100%;
  }

  .control-label,
  .control-label select {
    width: 100%;
    min-width: 0;
  }

  .hero-card-value {
    font-size: 1.4rem;
  }

  .hero-card-stats {
    gap: 10px;
  }

  .node-metrics {
    grid-template-columns: 1fr;
  }
}

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