:root {
  color-scheme: light;
  --bg: #edf2f7;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --border: #d7dee8;
  --text: #17202c;
  --text-dim: #5a6778;
  --accent: #0f6cbd;
  --accent-strong: #084b84;
  --accent-soft: rgba(15, 108, 189, 0.1);
  --success: #11845b;
  --warning: #b26b00;
  --danger: #c23934;
  --radius: 18px;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  --menu-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "Consolas", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 108, 189, 0.16), transparent 32%),
    radial-gradient(circle at bottom right, rgba(17, 132, 91, 0.1), transparent 28%),
    var(--bg);
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.portal-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.portal-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.3rem 1.4rem;
}

.portal-card-compact {
  max-width: 720px;
  align-self: center;
}

.portal-card-wide {
  max-width: 1120px;
  align-self: center;
}

.portal-card-hero {
  background:
    linear-gradient(135deg, rgba(15, 108, 189, 0.09), rgba(255, 255, 255, 0.96)),
    var(--bg-card);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.portal-logo {
  width: 64px;
  height: auto;
  flex-shrink: 0;
}

.portal-eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(1.75rem, 3vw, 2.35rem);
}

h2 {
  font-size: 1.16rem;
}

.portal-copy,
.section-copy {
  color: var(--text-dim);
}

.portal-copy {
  margin: 0.45rem 0 0;
  max-width: 40ch;
}

.section-copy {
  margin: 0.3rem 0 0;
}

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

.portal-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field span {
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 600;
}

.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  background: var(--bg-subtle);
  color: var(--text);
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 108, 189, 0.12);
}

.button,
.icon-button,
.menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.button:hover,
.icon-button:hover,
.menu-trigger:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: var(--bg-subtle);
}

.button:disabled,
.icon-button:disabled,
.menu-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.button {
  min-height: 42px;
  padding: 0.7rem 1rem;
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.button-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.icon-button,
.menu-trigger {
  width: 38px;
  height: 38px;
  padding: 0;
}

.icon-button svg,
.menu-trigger svg,
.instance-menu-item svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.form-status {
  min-height: 1.2rem;
  margin: 0.8rem 0 0;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.form-status.success {
  color: var(--success);
}

.form-status.error {
  color: var(--danger);
}

.instance-table-shell {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--bg-card), var(--bg-subtle));
  overflow-x: auto;
  overflow-y: visible;
}

.instance-table {
  width: 100%;
  min-width: 860px;
  border-collapse: separate;
  border-spacing: 0;
}

.instance-table th,
.instance-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.instance-table thead th {
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(248, 250, 252, 0.88);
  white-space: nowrap;
}

.instance-table tbody tr:last-child td {
  border-bottom: none;
}

.instance-table tbody tr:hover {
  background: rgba(15, 108, 189, 0.03);
}

.instance-table-row.is-selected {
  background: rgba(15, 108, 189, 0.06);
}

.instance-deployment {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.instance-name {
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.94rem;
  font-weight: 700;
  word-break: break-word;
}

.instance-meta {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.instance-meta-warning {
  color: var(--warning);
}

.instance-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.instance-ip,
.instance-version,
.instance-last-seen {
  white-space: nowrap;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  background: #e8eef5;
  color: #425466;
}

.state-pill.connected {
  background: rgba(17, 132, 91, 0.13);
  color: var(--success);
}

.state-pill.stale {
  background: rgba(178, 107, 0, 0.14);
  color: var(--warning);
}

.state-pill.offline {
  background: rgba(194, 57, 52, 0.12);
  color: var(--danger);
}

.instance-actions-header,
.instance-actions-cell {
  width: 72px;
}

.instance-actions-cell {
  text-align: right;
}

.instance-empty td {
  padding: 1.2rem 1rem;
  text-align: center;
  color: var(--text-dim);
}

.portal-toolbar {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.instance-menu {
  position: fixed;
  min-width: 180px;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: var(--menu-shadow);
  z-index: 2000;
}

.instance-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  text-align: left;
}

.instance-menu-item:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.instance-menu-item:disabled {
  color: var(--text-dim);
  cursor: not-allowed;
}

.instance-menu-item:disabled:hover {
  background: transparent;
  color: var(--text-dim);
}

.instance-menu-note {
  padding: 0.2rem 0.75rem 0.45rem;
  color: var(--text-dim);
  font-size: 0.76rem;
  line-height: 1.45;
}

.instance-menu-label {
  flex: 1;
}

@media (max-width: 900px) {
  .portal-card-wide {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .portal-shell {
    padding: 1rem 0.85rem 2rem;
  }

  .portal-card {
    padding: 1rem;
  }

  .portal-card-compact,
  .portal-card-wide {
    max-width: 100%;
  }

  .portal-brand {
    align-items: flex-start;
  }

  .portal-logo {
    width: 56px;
  }

  .section-head,
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .button {
    width: 100%;
  }
}
