@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;700;800&family=Space+Grotesk:wght@500;700&display=swap");

:root {
  color-scheme: light;
  --bg: #f2f7fd;
  --bg-strong: #e4f0ff;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --surface-soft: rgba(248, 251, 255, 0.88);
  --border: rgba(21, 55, 92, 0.1);
  --border-strong: rgba(21, 55, 92, 0.16);
  --text: #16314d;
  --text-soft: #607790;
  --accent: #0f7bf6;
  --accent-strong: #084d99;
  --accent-soft: rgba(15, 123, 246, 0.1);
  --ok: #0c8a5b;
  --ok-soft: rgba(12, 138, 91, 0.12);
  --warn: #a96a00;
  --warn-soft: rgba(169, 106, 0, 0.12);
  --danger: #c44153;
  --danger-soft: rgba(196, 65, 83, 0.12);
  --ink-soft: #203a58;
  --shadow-lg: 0 28px 80px rgba(20, 54, 91, 0.12);
  --shadow-md: 0 16px 40px rgba(20, 54, 91, 0.1);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Manrope", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(140, 224, 255, 0.52), transparent 34%),
    radial-gradient(circle at 85% 18%, rgba(146, 175, 255, 0.28), transparent 28%),
    radial-gradient(circle at bottom right, rgba(166, 245, 219, 0.24), transparent 30%),
    linear-gradient(135deg, #f4f8ff 0%, #ebf4ff 45%, #f9fcff 100%);
  color: var(--text);
  font-family: var(--font-body);
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  width: min(1380px, calc(100% - 40px));
  margin: 0 auto;
  padding: 30px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-card,
.panel,
.device-card,
.empty-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}

.hero-card,
.panel,
.device-card,
.empty-card {
  padding: 28px;
}

.hero-primary {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(245, 250, 255, 0.92)),
    var(--surface);
}

.hero-badge,
.section-kicker {
  display: inline-flex;
  align-items: center;
  padding: 9px 15px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.section-kicker {
  margin-bottom: 12px;
}

.hero-title {
  max-width: 10ch;
  margin: 18px 0 14px;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 5vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.hero-copy {
  max-width: 60ch;
  margin: 0;
  color: var(--text-soft);
  font-size: 1.02rem;
  line-height: 1.7;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 26px;
}

.metric {
  min-width: 0;
  padding: 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(238, 246, 255, 0.98));
  border: 1px solid rgba(15, 123, 246, 0.13);
}

.metric strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.15rem;
  font-family: var(--font-display);
}

.metric span,
.panel-subtitle,
.subtle,
.status-card p,
.footer-note,
.hint {
  color: var(--text-soft);
  line-height: 1.6;
}

.status-stack {
  display: grid;
  gap: 18px;
}

.status-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.status-card h2,
.panel h2 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.layout.app-mode {
  grid-template-columns: 1fr;
}

.layout.app-mode > .app-shell {
  grid-column: 1 / -1;
}

.auth-pane[hidden],
.app-shell[hidden] {
  display: none !important;
}

.panel-header,
.toolbar,
.device-header,
.history-top,
.panel-head,
.dashboard-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-header {
  margin-bottom: 16px;
}

.panel-header h2,
.toolbar-meta h2 {
  margin: 0;
  font-family: var(--font-display);
}

.tabs {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(18, 50, 82, 0.06);
}

.tab-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: transparent;
  color: var(--text-soft);
  font-weight: 800;
  cursor: pointer;
  transition: 160ms ease;
}

.tab-button.active {
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: 0 12px 28px rgba(20, 54, 91, 0.08);
}

.field-grid {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 0.94rem;
  font-weight: 800;
}

.field input,
.field textarea,
.command-inline input {
  width: 100%;
  padding: 14px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(21, 55, 92, 0.14);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.field textarea {
  min-height: 130px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.command-inline input:focus {
  outline: none;
  border-color: rgba(15, 123, 246, 0.5);
  box-shadow: 0 0 0 4px rgba(15, 123, 246, 0.12);
  transform: translateY(-1px);
}

.actions,
.toolbar-actions,
.device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.58;
  cursor: wait;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #005bda 100%);
  color: #fff;
  box-shadow: 0 18px 34px rgba(15, 123, 246, 0.24);
}

.btn-secondary {
  background: rgba(18, 50, 82, 0.07);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.notice {
  display: none;
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  line-height: 1.55;
}

.notice.show {
  display: block;
}

.notice.ok {
  background: rgba(12, 138, 91, 0.1);
  border-color: rgba(12, 138, 91, 0.18);
  color: var(--ok);
}

.notice.error {
  background: rgba(196, 65, 83, 0.1);
  border-color: rgba(196, 65, 83, 0.18);
  color: var(--danger);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.app-shell {
  min-width: 0;
}

.dashboard-rail {
  display: grid;
  gap: 18px;
  align-self: start;
}

.dashboard-main {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.account-panel,
.pair-panel,
.summary-panel {
  box-shadow: var(--shadow-md);
}

.toolbar {
  margin: 0;
}

.toolbar-meta h2 {
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.toolbar-meta p {
  margin: 8px 0 0;
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.dashboard-intro {
  gap: 24px;
}

.dashboard-intro h2 {
  margin: 0 0 12px;
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.intro-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 12px;
  min-width: min(100%, 320px);
}

.hero-stat {
  min-width: 0;
  padding: 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(236, 245, 255, 0.9));
  border: 1px solid rgba(21, 55, 92, 0.08);
}

.hero-stat span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.hero-stat strong {
  display: block;
  font-size: 1.7rem;
  font-family: var(--font-display);
}

.summary-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.summary-list div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.summary-list dt {
  color: var(--text-soft);
}

.summary-list dd {
  margin: 0;
  font-weight: 800;
}

.device-grid {
  display: grid;
  gap: 20px;
}

.device-card {
  padding: 24px;
}

.device-header {
  margin-bottom: 18px;
}

.device-heading {
  min-width: 0;
}

.device-eyebrow {
  margin-bottom: 8px;
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.device-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2vw, 2rem);
  line-height: 1;
}

.device-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
}

.chip {
  background: rgba(18, 50, 82, 0.06);
  color: var(--text-soft);
}

.status-pill {
  background: rgba(18, 50, 82, 0.08);
  color: var(--ink-soft);
}

.status-pill.is-online {
  background: var(--ok-soft);
  color: var(--ok);
}

.status-pill.is-offline {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-pill.is-delivered {
  background: rgba(15, 123, 246, 0.1);
  color: var(--accent-strong);
}

.status-pill.is-acked {
  background: var(--ok-soft);
  color: var(--ok);
}

.status-pill.is-pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-pill.is-unknown {
  background: rgba(18, 50, 82, 0.08);
  color: var(--text-soft);
}

.device-panels {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 18px;
}

.mini-panel {
  min-width: 0;
  min-height: 100%;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(249, 252, 255, 0.98), rgba(239, 245, 255, 0.94));
  border: 1px solid rgba(21, 55, 92, 0.08);
}

.panel-head {
  margin-bottom: 14px;
}

.mini-panel .subtle {
  margin: 8px 0 0;
}

.panel-head h3,
.mini-panel h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

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

.telemetry-stat {
  min-width: 0;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(21, 55, 92, 0.08);
  background: rgba(255, 255, 255, 0.92);
}

.telemetry-stat span {
  display: block;
  margin-bottom: 10px;
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 700;
}

.telemetry-stat strong {
  display: block;
  font-size: clamp(1rem, 1.6vw, 1.5rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.telemetry-stat.tone-sky {
  background: rgba(223, 238, 255, 0.8);
}

.telemetry-stat.tone-mint {
  background: rgba(224, 248, 236, 0.8);
}

.telemetry-stat.tone-gold {
  background: rgba(255, 244, 221, 0.82);
}

.telemetry-stat.tone-rose {
  background: rgba(255, 232, 239, 0.82);
}

.telemetry-stat.tone-slate {
  background: rgba(235, 242, 250, 0.86);
}

.message-card {
  margin-top: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(17, 43, 69, 0.92);
  color: #edf5ff;
}

.message-label {
  display: block;
  margin-bottom: 8px;
  color: rgba(237, 245, 255, 0.72);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.message-card p {
  margin: 0;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.raw-block {
  margin-top: 14px;
}

.raw-block summary {
  cursor: pointer;
  color: var(--text-soft);
  font-weight: 800;
}

.raw-block[open] summary {
  margin-bottom: 12px;
}

.prebox {
  margin: 0;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(18, 43, 69, 0.94);
  color: #e9f3ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.81rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 280px;
  overflow: auto;
}

.command-form {
  display: grid;
  gap: 14px;
}

.command-form textarea {
  min-height: 104px;
}

.command-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.history-list {
  display: grid;
  gap: 12px;
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  max-height: 420px;
  overflow: auto;
}

.history-item {
  min-width: 0;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(17, 43, 69, 0.94);
  color: #edf5ff;
  border: 1px solid rgba(140, 185, 235, 0.08);
}

.history-command {
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.history-meta,
.history-result {
  margin-top: 8px;
  color: rgba(237, 245, 255, 0.78);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.history-meta div + div {
  margin-top: 4px;
}

.history-result {
  padding-top: 10px;
  border-top: 1px solid rgba(140, 185, 235, 0.12);
  color: #ffffff;
}

.empty-card {
  text-align: center;
}

.empty-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.footer-note {
  margin-top: 20px;
  font-size: 0.9rem;
}

.shell.is-authenticated .hero {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.shell.is-authenticated .hero-title {
  max-width: 12ch;
  font-size: clamp(2rem, 3vw, 3.2rem);
}

.shell.is-authenticated .hero-copy {
  max-width: 52ch;
}

.shell.is-authenticated .hero-metrics {
  display: none;
}

@media (max-width: 1180px) {
  .hero,
  .dashboard-grid,
  .device-panels {
    grid-template-columns: 1fr;
  }

  .shell.is-authenticated .hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .layout,
  .layout.app-mode {
    grid-template-columns: 1fr;
  }

  .auth-panel,
  .dashboard-rail,
  .dashboard-main {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 18px, 100%);
    padding-top: 18px;
  }

  .hero-card,
  .panel,
  .device-card,
  .empty-card {
    padding: 20px;
    border-radius: 24px;
  }

  .hero-title {
    font-size: 2.25rem;
    max-width: none;
  }

  .hero-metrics,
  .telemetry-grid,
  .intro-stats,
  .command-inline {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .toolbar,
  .device-header,
  .device-actions,
  .dashboard-intro,
  .history-top {
    flex-direction: column;
    align-items: stretch;
  }

  .tabs {
    width: 100%;
  }

  .tab-button {
    flex: 1;
    justify-content: center;
  }
}
