:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3d8bfd;
  --accent-dim: #2563c7;
  --ok: #3ecf8e;
  --warn: #f0b429;
  --err: #f07178;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
}

header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

header .meta {
  color: var(--muted);
  font-size: 0.875rem;
}

.banner {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tabs button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
}

.tabs button.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

.panel {
  display: none !important;
}

.panel.active {
  display: block !important;
}

.panel.active.dash-flow {
  display: flex !important;
  flex-direction: column;
  gap: 1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat {
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.75rem;
}

.stat .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stat .value {
  font-size: 1.35rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

form.inline,
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.form-stack {
  flex-direction: column;
  align-items: stretch;
}

.form-stack label {
  width: 100%;
}

.gpu-suggestions ul {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
}

.gpu-suggestions li {
  margin-bottom: 0.25rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}

input,
select,
button.primary {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  font-size: 0.875rem;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 500;
}

button.primary:hover {
  background: var(--accent-dim);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}

button.ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.badge.online {
  background: rgba(62, 207, 142, 0.15);
  color: var(--ok);
}

.badge.offline {
  background: rgba(240, 180, 41, 0.15);
  color: var(--warn);
}

.badge.revoked {
  background: rgba(240, 113, 120, 0.15);
  color: var(--err);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.alert.error {
  background: rgba(240, 113, 120, 0.12);
  border: 1px solid var(--err);
  color: var(--err);
}

.alert.success {
  background: rgba(62, 207, 142, 0.12);
  border: 1px solid var(--ok);
  color: var(--ok);
}

.alert.warn {
  background: rgba(240, 180, 41, 0.12);
  border: 1px solid var(--warn);
  color: var(--warn);
}

.token-box {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  word-break: break-all;
  background: var(--bg);
  padding: 0.75rem;
  border-radius: 6px;
  margin-top: 0.5rem;
}

#login-screen {
  max-width: 380px;
  margin: 4rem auto;
}

#login-screen h2 {
  margin-top: 0;
}

#login-form label {
  display: block;
  margin-bottom: 0.75rem;
}

#login-form input {
  width: 100%;
  margin-top: 0.25rem;
}

#login-form button.primary {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.65rem;
}

.hidden {
  display: none !important;
}

.node-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--surface2);
}

.node-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.node-insights h4 {
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.node-insights tr.row-active td {
  background: rgba(62, 207, 142, 0.08);
}

.muted {
  color: var(--muted);
  font-size: 0.8rem;
}

footer {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.75rem;
}

/* Dashboard actividad */
.dash-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.dash-title {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.dash-subtitle {
  margin: 0;
  max-width: 42rem;
}

.period-pills {
  display: flex;
  gap: 0.35rem;
  background: var(--bg);
  padding: 0.25rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.period-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kpi-card {
  background: linear-gradient(145deg, var(--surface2) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.kpi-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
}

.kpi-hint {
  font-size: 0.72rem;
  color: var(--muted);
}

/* Actividad: bloques apilados a ancho completo (solo panel activo) */
.panel.active.dash-flow > .card,
.panel.active.dash-flow > .kpi-grid,
.panel.active.dash-flow > .overview-pane,
.panel.active.dash-flow > .sub-tabs,
.panel.active.dash-flow > .dash-toolbar {
  width: 100%;
  margin-bottom: 0;
}

.panel.active.dash-flow .dash-block,
.panel.active.dash-flow .dash-chart-card {
  width: 100%;
}

.panel-inner {
  margin-top: 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.sub-tabs button {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.sub-tabs button.active {
  color: var(--text);
  border-color: var(--accent);
  background: var(--surface2);
}

.overview-pane.hidden {
  display: none !important;
}

.node-section-title {
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.node-ops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin: 0.5rem 0 0;
}

.ops-kpi {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ops-label {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ops-value {
  font-size: 0.9rem;
  font-weight: 600;
}

.runtime-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 0;
}

.runtime-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  background: var(--surface2);
}

.runtime-card h4 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
}

.runtime-card h4 a {
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 0.35rem;
}

.runtime-cmds {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.5rem 0;
}

.runtime-cmd {
  display: block;
  font-size: 0.72rem;
  padding: 0.35rem 0.5rem;
  background: var(--bg);
  border-radius: 4px;
  word-break: break-all;
}

.runtime-foot {
  margin: 0;
  font-size: 0.72rem;
}

#clients-metric-note {
  margin: 0.75rem 0;
  font-size: 0.8rem;
}

.dash-row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card-heading {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.card-hint {
  margin: 0 0 0.85rem;
  font-size: 0.75rem;
}

.dash-chart-card .chart-area {
  min-height: 160px;
  width: 100%;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 140px;
  padding-top: 0.5rem;
  width: 100%;
}

.chart-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  max-width: 48px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dim) 100%);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}

.chart-label {
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.chart-empty {
  padding: 2rem 0;
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  table-layout: auto;
}

.data-table td,
.data-table th {
  vertical-align: middle;
  white-space: nowrap;
}

.data-table td:first-child,
.data-table th:first-child {
  white-space: normal;
  min-width: 8rem;
}

.share-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 7rem;
}

.share-bar {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.share-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.share-pct {
  font-size: 0.72rem;
  color: var(--muted);
  min-width: 2.5rem;
  text-align: right;
}

.metric-pill {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.metric-pill.ok {
  background: rgba(62, 207, 142, 0.15);
  color: var(--ok);
}

.metric-pill.warn {
  background: rgba(240, 180, 41, 0.15);
  color: var(--warn);
}

.metric-pill.err {
  background: rgba(240, 113, 120, 0.15);
  color: var(--err);
}

.task-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.8rem;
}

.host-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.infra-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  background: var(--surface2);
}

.infra-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
