@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: rgba(30, 41, 59, 0.82);
  --panel-strong: #1e293b;
  --muted: #94a3b8;
  --text: #f8fafc;
  --border: rgba(148, 163, 184, 0.28);
  --accent: #22c55e;
  --accent-dark: #052e16;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Fira Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(34, 197, 94, 0.14), transparent 34rem),
    radial-gradient(circle at 90% 12%, rgba(56, 189, 248, 0.12), transparent 30rem),
    #0f172a;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  cursor: pointer;
}

input {
  width: 100%;
  min-height: 46px;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(15, 23, 42, 0.78);
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

label {
  display: block;
  margin-bottom: 0.45rem;
  color: #cbd5e1;
  font-size: 0.9rem;
  font-weight: 600;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-shell,
.app-shell {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: 1rem;
}

.login-body {
  display: grid;
  place-items: center;
}

.floating-nav,
.topbar {
  position: sticky;
  top: 1rem;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(20px);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.24);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-family: "Fira Code", monospace;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-dot {
  width: 0.76rem;
  height: 0.76rem;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 22px rgba(34, 197, 94, 0.7);
}

.nav-sub {
  color: var(--muted);
  font-size: 0.9rem;
}

.login-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.64fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 5rem);
  min-height: calc(100vh - 7rem);
  padding: 4rem 0 2rem;
}

.hero-copy {
  max-width: 920px;
}

.eyebrow {
  margin: 0 0 1rem;
  color: var(--accent);
  font-family: "Fira Code", monospace;
  font-size: 0.86rem;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 920px;
  font-size: clamp(2.4rem, 8vw, 4.8rem);
  line-height: 0.98;
}

h2 {
  font-size: clamp(1.12rem, 2.4vw, 1.35rem);
}

.hero-text {
  max-width: 720px;
  margin: 1.2rem 0 0;
  color: #cbd5e1;
  font-size: clamp(1rem, 1.6vw, 1.16rem);
  line-height: 1.65;
}

.login-card,
.panel,
.device-card,
.metric-grid article {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.login-card {
  display: grid;
  gap: 1rem;
  padding: clamp(1.25rem, 3vw, 2rem);
}

.primary-button,
.ghost-button,
.command-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 700;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.primary-button {
  color: #052e16;
  background: var(--accent);
}

.primary-button:hover,
.command-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.command-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.ghost-button {
  color: var(--text);
  border-color: var(--border);
  background: rgba(15, 23, 42, 0.62);
  padding: 0 1rem;
}

.hint,
.form-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.form-message[data-tone="error"] {
  color: #fca5a5;
}

.form-message[data-tone="success"] {
  color: #86efac;
}

.app-shell {
  display: grid;
  gap: 1rem;
  padding-bottom: 4rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 1rem;
  align-items: stretch;
  padding-top: 2rem;
}

.device-card {
  display: grid;
  gap: 1rem;
  align-content: start;
  padding: 1.25rem;
}

.device-card dl {
  display: grid;
  gap: 0.8rem;
  margin: 0;
}

.device-card div {
  display: grid;
  gap: 0.25rem;
}

dt {
  color: var(--muted);
  font-size: 0.84rem;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: "Fira Code", monospace;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 34px;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
}

.status-on {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.48);
  background: rgba(34, 197, 94, 0.12);
}

.status-off {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.42);
  background: rgba(239, 68, 68, 0.11);
}

.status-warn {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.42);
  background: rgba(245, 158, 11, 0.11);
}

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

.metric-grid article {
  min-height: 112px;
  padding: 1rem;
}

.metric-grid span {
  color: var(--muted);
}

.metric-grid strong {
  display: block;
  margin-top: 0.8rem;
  font-family: "Fira Code", monospace;
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.main-grid,
.secondary-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(320px, 5fr);
  gap: 1rem;
  align-items: start;
}

.secondary-grid {
  grid-template-columns: minmax(0, 8fr) minmax(320px, 4fr);
}

.panel {
  min-width: 0;
  padding: 1rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.mini-counter {
  color: var(--muted);
  font-family: "Fira Code", monospace;
  font-size: 0.82rem;
}

.telemetry-list,
.pending-list,
.log-list {
  display: grid;
  gap: 0.75rem;
}

.empty {
  color: var(--muted);
}

.data-row,
.log-row,
.pending-row {
  display: grid;
  gap: 0.4rem;
  padding: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.55);
}

.data-row strong,
.pending-row strong {
  color: var(--text);
}

.data-row span,
.pending-row span,
.log-row span {
  color: var(--muted);
}

.command-list,
.settings-form {
  display: grid;
  gap: 0.85rem;
}

.command-button {
  width: 100%;
  color: var(--text);
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
  padding: 0.75rem 1rem;
}

.command-button.compact {
  width: auto;
  min-width: 88px;
}

.inline-row {
  display: flex;
  gap: 0.6rem;
}

.logs-panel {
  margin-bottom: 2rem;
}

.log-row {
  grid-template-columns: 120px 90px minmax(0, 1fr) minmax(0, 1.5fr);
  align-items: start;
}

.log-row code {
  font-family: "Fira Code", monospace;
  color: #bbf7d0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log-error {
  color: #fca5a5;
}

@media (max-width: 920px) {
  .login-hero,
  .dashboard-hero,
  .main-grid,
  .secondary-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .floating-nav,
  .topbar {
    border-radius: var(--radius);
    align-items: flex-start;
  }

  .topbar {
    position: static;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .log-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .login-shell,
  .app-shell {
    padding: 0.75rem;
  }

  .floating-nav,
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .inline-row {
    flex-direction: column;
  }
}

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