:root {
  --ground: #0f1213;
  --surface: #171b1c;
  --surface-2: #1e2325;
  --line: #2a3033;
  --line-strong: #3a4245;
  --text: #eef1ec;
  --muted: #a3aca8;
  --accent: #9db4ff;
  --ok: #5bd08a;
  --ok-dim: #3e9c68;
  --warn: #f0b94a;
  --down: #ff7466;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
}

h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
a:hover { color: #c3d1ff; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 0 24px 56px; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }

/* Encabezado */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0 24px; }
.brand { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.mark { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--accent); display: grid; place-items: center; }
.mark::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { color: var(--muted); font-size: 14px; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.top-actions form { margin: 0; }

.btn {
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--text); font: inherit; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { border-color: var(--accent); background: var(--accent); color: var(--ground); font-weight: 600; }
.btn-primary:hover { background: #c3d1ff; }

.notice { margin-bottom: 16px; padding: 12px 16px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.notice.is-error { border-color: var(--down); color: var(--down); }

/* Tarjetas base */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }

/* Resumen */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.tile-label { color: var(--muted); font-size: 14px; }
.tile-value { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; font-size: 40px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.tile-value small { color: var(--muted); font-size: 18px; font-weight: 400; letter-spacing: 0; }
.tile-value.is-down { color: var(--down); }
.tile-sub { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* Requiere atención */
.attention { margin-top: 16px; padding: 8px 20px; }
.attention-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.attention-row:last-child { border-bottom: 0; }
.attention-text { flex: 1 1 320px; min-width: 0; }
.attention-text span { color: var(--muted); }

/* Etiquetas de estado: la forma del punto cambia junto con el color */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; background: currentColor; }
.pill.is-up { background: rgba(91, 208, 138, 0.12); color: var(--ok); }
.pill.is-up::before { border-radius: 50%; }
.pill.is-down { background: rgba(255, 116, 102, 0.14); color: var(--down); }
.pill.is-down::before { border-radius: 1px; }
.pill.is-warn { background: rgba(240, 185, 74, 0.14); color: var(--warn); }
.pill.is-warn::before { border-radius: 1px; transform: rotate(45deg); }
.pill.is-pending { background: var(--surface-2); color: var(--muted); }
.pill.is-pending::before { border-radius: 50%; background: transparent; border: 2px solid currentColor; }

/* Proyectos */
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 32px; }
.section-head h2 { font-size: 20px; font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--text); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.filter span { font-family: var(--mono); font-size: 12px; }
.filter[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--ground); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; margin-top: 16px; }
.project { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.project.is-down { border-color: rgba(255, 116, 102, 0.55); }
.project-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tag { padding: 4px 10px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: #c9d0cc; font-size: 12px; font-weight: 500; letter-spacing: 0.02em; }
.project h3 { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.project-group { color: var(--muted); font-size: 13px; margin-top: 2px; }
.project-url { display: block; margin-top: 4px; font-family: var(--mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-error { color: var(--down); font-size: 13px; }
.project-note { color: var(--warn); font-size: 13px; }

.bars { display: flex; gap: 2px; height: 24px; }
.bar { flex: 1 1 0; border-radius: 2px; background: var(--line); }
.bar.is-ok { background: var(--ok-dim); }
.bar.is-warn { background: var(--warn); }
.bar.is-down { background: var(--down); }
.bars-caption { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }
.bars-caption strong { font-family: var(--mono); font-weight: 400; color: var(--text); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 15px; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }

.meter { border-top: 1px solid var(--line); padding-top: 14px; }
.meter-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.meter-head span:first-child { color: var(--muted); }
.meter-head span:last-child { font-family: var(--mono); }
.meter-track { height: 6px; border-radius: 3px; background: var(--line); margin-top: 8px; overflow: hidden; }
.meter-fill { height: 6px; border-radius: 3px; width: var(--fill, 0%); background: var(--muted); }
.meter.is-warn .meter-fill { background: var(--warn); }
.meter.is-warn .meter-head span:last-child { color: var(--warn); }

/* Paneles inferiores */
.panels { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 32px; }
.panel { flex: 1 1 340px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.panel-head h2 { font-size: 18px; font-weight: 600; }
.panel-head span { color: var(--muted); font-size: 13px; }
.interval { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.interval-label { color: var(--muted); font-size: 13px; margin-right: 4px; }
.rows { margin-top: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-main { min-width: 0; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.row-side { font-size: 13px; font-weight: 600; text-align: right; white-space: nowrap; }
.row-side.is-ok { color: var(--ok); }
.row-side.is-warn { color: var(--warn); }
.row-side.is-down { color: var(--down); }
.row-side.is-plain { font-family: var(--mono); font-weight: 400; }
.empty { color: var(--muted); padding: 14px 0 0; }
.panel-foot { color: var(--muted); font-size: 12px; margin-top: 12px; }

/* Acceso */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { margin-bottom: 20px; }
.field label { display: block; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.field input { width: 100%; min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--ground); color: var(--text); font: inherit; }
.login-card .btn { width: 100%; margin-top: 16px; }
.login-error { color: var(--down); font-size: 14px; margin-top: 12px; }

@media (max-width: 520px) {
  .wrap { padding: 0 16px 40px; }
  .tile-value { font-size: 34px; }
  .top-actions { width: 100%; }
}
