:root {
  --bg: #081016;
  --panel: rgba(13, 28, 33, 0.88);
  --panel-soft: rgba(19, 38, 44, 0.72);
  --line: rgba(141, 190, 180, 0.18);
  --text: #eff7f3;
  --muted: #a5b7b0;
  --mint: #7de0c1;
  --mint-deep: #175347;
  --amber: #f5b85a;
  --danger: #f18778;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top left, #17343a 0, transparent 32%),
    linear-gradient(180deg, #071015 0%, #081016 100%);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

body {
  position: relative;
}

/* Hard default: the portal starts locked until JS validates auth. */
body.portal-locked .topbar,
body.portal-locked .layout {
  display: none !important;
}

body.portal-locked #login-screen {
  display: block !important;
}

/* Gate the admin workspace behind a provider admin session (public static site). */
body:not(.is-auth) .panel.workspace {
  display: none;
}

body.is-auth #login-screen {
  display: none;
}

body:not(.is-auth) .layout {
  display: none;
}

body:not(.is-auth) .topbar {
  display: none;
}

.login-screen {
  display: block;
}

/* Always keep the login screen clean, even if stale UI state exists. */
body[data-route="login"] .topbar,
body[data-route="login"] .layout {
  display: none !important;
}

body[data-route="login"] #login-screen {
  display: block !important;
}

.login-card {
  width: min(980px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.login-minimal {
  width: min(720px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 26px;
}

.login-minimal h1 {
  margin: 0 0 18px;
  font-size: 1.8rem;
}

.backdrop {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(125, 224, 193, 0.08), transparent 24%),
    radial-gradient(circle at 80% 10%, rgba(245, 184, 90, 0.14), transparent 18%);
  pointer-events: none;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 56px;
}

.hero,
.panel {
  position: relative;
  z-index: 1;
}

/* New dashboard layout */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(141, 190, 180, 0.14);
  background: rgba(7, 16, 21, 0.76);
  backdrop-filter: blur(16px);
}

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

.logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(125, 224, 193, 0.26), rgba(245, 184, 90, 0.18));
  border: 1px solid rgba(141, 190, 180, 0.22);
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.02em;
}

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

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.meta-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: right;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(141, 190, 180, 0.18);
  background: rgba(19, 38, 44, 0.55);
}

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

.sidenav {
  position: sticky;
  top: 86px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(141, 190, 180, 0.12);
  background: rgba(19, 38, 44, 0.35);
  color: var(--text);
  font-family: inherit;
  font-size: 0.98rem;
  cursor: pointer;
}

.nav-item.is-active {
  background: linear-gradient(135deg, rgba(125, 224, 193, 0.22), rgba(125, 224, 193, 0.08));
  border-color: rgba(125, 224, 193, 0.35);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(141, 190, 180, 0.14);
  border-radius: 18px;
  background: rgba(7, 16, 21, 0.32);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.table th,
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(141, 190, 180, 0.12);
  vertical-align: top;
}

.table th {
  color: rgba(239, 247, 243, 0.84);
  font-weight: 600;
  text-align: left;
  background: rgba(19, 38, 44, 0.42);
}

.table tr:hover td {
  background: rgba(125, 224, 193, 0.06);
}

.table .empty {
  text-align: center;
  color: var(--muted);
  padding: 18px 14px;
}

.panel-subhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

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

.hint {
  margin: 10px 0 0;
  color: rgba(239, 247, 243, 0.68);
  font-size: 0.95rem;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidenav {
    position: static;
    flex-direction: row;
    overflow: auto;
  }
  .nav-item {
    white-space: nowrap;
  }
  .topbar {
    position: static;
  }
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr 0.8fr;
  gap: 18px;
  margin-bottom: 18px;
}

.hero-copy,
.hero-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 30px;
}

.hero-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  background:
    linear-gradient(180deg, rgba(125, 224, 193, 0.08), transparent),
    var(--panel);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--amber);
  font-size: 0.75rem;
  font-family: "IBM Plex Mono", monospace;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.96;
  max-width: 11ch;
}

.lede {
  margin: 18px 0 0;
  max-width: 58ch;
  color: var(--muted);
  line-height: 1.6;
  font-size: 1rem;
}

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

.status-pill,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 7px 12px;
  border: 1px solid rgba(125, 224, 193, 0.2);
  background: rgba(125, 224, 193, 0.08);
  color: var(--mint);
  font-size: 0.82rem;
}

input.chip-input {
  min-width: 180px;
  outline: none;
}

input.chip-input::placeholder {
  color: rgba(125, 224, 193, 0.78);
}

.panel {
  padding: 24px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.compact-head {
  margin-top: 18px;
  margin-bottom: 14px;
  align-items: center;
}

.chip-row,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

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

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

.device-lock-grid {
  margin-top: 4px;
}

.workspace {
  background:
    linear-gradient(180deg, rgba(245, 184, 90, 0.06), transparent 28%),
    var(--panel);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.field span {
  color: var(--muted);
  font-size: 0.88rem;
}

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

input,
select,
textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(165, 183, 176, 0.16);
  background: var(--panel-soft);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
  transition: border-color 140ms ease, transform 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(125, 224, 193, 0.6);
  transform: translateY(-1px);
}

button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, border-color 140ms ease;
}

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

button.primary {
  background: linear-gradient(135deg, var(--mint) 0%, #a5eac9 100%);
  color: #07211b;
  font-weight: 700;
}

button.ghost {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  border-color: rgba(165, 183, 176, 0.16);
}

button.ghost.danger {
  color: var(--danger);
  border-color: rgba(241, 135, 120, 0.2);
}

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

.endpoint-card {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.endpoint-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

code,
.logbox,
.codebox {
  font-family: "IBM Plex Mono", monospace;
}

.endpoint-card code {
  display: block;
  white-space: normal;
  word-break: break-all;
  color: var(--mint);
}

.codebox,
.logbox {
  min-height: 140px;
  resize: vertical;
  line-height: 1.55;
}

.logbox {
  max-height: 320px;
  overflow: auto;
  background: #061116;
}

.history-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
}

.history-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.history-table th,
.history-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(165, 183, 176, 0.12);
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

.history-table th {
  color: var(--muted);
  font-weight: 500;
  background: rgba(255, 255, 255, 0.03);
}

.history-table tbody tr:hover {
  background: rgba(125, 224, 193, 0.04);
}

.empty-state-cell {
  color: var(--muted);
  text-align: center;
  padding: 18px 14px;
}

@media (max-width: 920px) {
  .hero,
  .grid.two,
  .grid.three,
  .endpoint-list {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
  }
}
