/* ==========================================================================
   Servicold — Sistema de diseño
   Un solo lugar para color, tipografía, espaciado y componentes.
   Light y dark son pares: ambos tienen su propio set de tokens.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  color-scheme: dark;

  /* Superficies — navy profundo, no negro puro */
  --sc-bg: #070b18;
  --sc-bg-2: #0a1020;
  --sc-surface: #0e1526;
  --sc-surface-2: #141d33;
  --sc-raised: #18233d;

  /* Líneas — hairline, sin glow */
  --sc-line: #1f2b47;
  --sc-line-2: #2a3a5c;

  /* Texto */
  --sc-text: #e8eef9;
  --sc-text-2: #a8b8d0;
  --sc-text-3: #7e8dac;

  /* Marca */
  --sc-brand: #3e8be0;
  --sc-brand-hover: #58a0ef;
  --sc-brand-ink: #74b5f9;   /* acento sobre dark */
  --sc-navy: #1a2a7c;        /* primary de la app móvil */
  --sc-on-brand: #ffffff;

  /* Estados — el rojo es para emergencias, el slate para información */
  --sc-ok: #2bd48a;
  --sc-warn: #f5a524;
  --sc-alarm: #ff4d5e;
  --sc-offline: #7e8dac;

  --sc-ok-wash: rgba(43, 212, 138, 0.12);
  --sc-warn-wash: rgba(245, 165, 36, 0.12);
  --sc-alarm-wash: rgba(255, 77, 94, 0.13);
  --sc-offline-wash: rgba(126, 141, 172, 0.12);
  /* Azul frío: "Temperatura baja" no es una emergencia roja */
  --sc-cold: #58a6ff;
  --sc-cold-wash: rgba(88, 166, 255, 0.14);
  --sc-brand-wash: rgba(62, 139, 224, 0.14);

  /* Tipografía */
  --sc-font: "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sc-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Radios — variedad deliberada, no todo igual */
  --sc-r-sm: 4px;
  --sc-r: 8px;
  --sc-r-lg: 12px;
  --sc-r-xl: 18px;

  /* Sombra — sobria */
  --sc-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.22);
  --sc-shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 20px 48px rgba(0, 0, 0, 0.34);

  /* Movimiento */
  --sc-ease: cubic-bezier(0.2, 0, 0, 1);
  --sc-fast: 130ms;
  --sc-base: 220ms;

  /* Estructura */
  --sc-topbar-h: 58px;
  --sc-rail-w: 216px;
  --sc-maxw: 1320px;
}

[data-sc-theme="light"] {
  color-scheme: light;

  --sc-bg: #f4f6fa;
  --sc-bg-2: #e9eef6;
  --sc-surface: #ffffff;
  --sc-surface-2: #f7f9fc;
  --sc-raised: #ffffff;

  --sc-line: #d8e0ec;
  --sc-line-2: #bcc8da;

  --sc-text: #0c1524;
  --sc-text-2: #465a78;
  /* #64748b daba 4.40:1 sobre el fondo de pagina: apenas por debajo de AA.
     #5f6b80 da 4.98:1 sobre #f4f6fa y 5.38:1 sobre blanco. */
  --sc-text-3: #5f6b80;

  --sc-brand: #1a5fb4;
  --sc-brand-hover: #154c93;
  --sc-brand-ink: #0f4a94;
  --sc-navy: #1a2a7c;

  --sc-ok: #0b7a4b;
  --sc-warn: #9a6200;
  --sc-alarm: #c21130;
  --sc-offline: #5f6b80;

  --sc-ok-wash: rgba(11, 122, 75, 0.1);
  --sc-warn-wash: rgba(154, 98, 0, 0.1);
  --sc-alarm-wash: rgba(194, 17, 48, 0.09);
  --sc-offline-wash: rgba(100, 116, 139, 0.1);
  --sc-cold: #0b6bcb;
  --sc-cold-wash: rgba(11, 107, 203, 0.1);
  --sc-brand-wash: rgba(26, 95, 180, 0.1);

  --sc-shadow: 0 1px 2px rgba(12, 21, 36, 0.06), 0 8px 20px rgba(12, 21, 36, 0.07);
  --sc-shadow-lg: 0 2px 6px rgba(12, 21, 36, 0.08), 0 20px 44px rgba(12, 21, 36, 0.12);
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--sc-bg);
  color: var(--sc-text);
  font-family: var(--sc-font);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4, h5 {
  margin: 0;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--sc-text);
}

p { margin: 0; }

a { color: var(--sc-brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; }
img { height: auto; }

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

:focus-visible {
  outline: 2px solid var(--sc-brand-ink);
  outline-offset: 2px;
  border-radius: var(--sc-r-sm);
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--sc-brand-wash); }

.sc-visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sc-skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  background: var(--sc-brand);
  color: var(--sc-on-brand);
  padding: 10px 16px;
  border-radius: var(--sc-r);
  font-weight: 600;
  transition: top var(--sc-fast) var(--sc-ease);
}
.sc-skip-link:focus { top: 12px; text-decoration: none; }

/* --------------------------------------------------------------------------
   3. Tipografía
   -------------------------------------------------------------------------- */
.sc-display {
  font-size: clamp(2.1rem, 1.3rem + 3.4vw, 3.9rem);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: 800;
}

.sc-h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem); line-height: 1.12; letter-spacing: -0.03em; font-weight: 800; }
.sc-h2 { font-size: clamp(1.3rem, 1.1rem + 0.9vw, 1.75rem); line-height: 1.18; font-weight: 700; }
.sc-h3 { font-size: 1.1875rem; line-height: 1.28; font-weight: 700; }
.sc-h4 { font-size: 1rem; line-height: 1.35; font-weight: 600; }
/* Sin viudas: los títulos se balancean en varias líneas si hacen falta. */
.sc-h1, .sc-h2, .sc-h3, .sc-h4, h1, h2 { text-wrap: balance; }

.sc-lead {
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--sc-text-2);
  max-width: 62ch;
}

.sc-meta {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--sc-text-3);
}

.sc-num {
  font-family: var(--sc-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.02em;
}

/* --------------------------------------------------------------------------
   4. Chrome de aplicación — topbar + rail
   -------------------------------------------------------------------------- */
.sc-app {
  display: grid;
  grid-template-columns: var(--sc-rail-w) 1fr;
  grid-template-rows: var(--sc-topbar-h) 1fr;
  grid-template-areas:
    "brand topbar"
    "rail  main";
  min-height: 100vh;
}

.sc-brand-cell {
  grid-area: brand;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-right: 1px solid var(--sc-line);
  border-bottom: 1px solid var(--sc-line);
  /* Tinte con el navy que usa la app movil como primary, para que la marca
     se lea igual en los dos lados. */
  background: color-mix(in srgb, var(--sc-navy) 12%, var(--sc-surface));
}
.sc-brand-cell a { display: flex; align-items: center; gap: 10px; }

/* Marca y burger del topbar: solo se usan cuando el rail se esconde. */
.sc-topbar__brand,
.sc-topbar__burger { display: none; }

.sc-topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--sc-line);
  background: var(--sc-surface);
  position: sticky;
  top: 0;
  z-index: 40;
}
.sc-topbar__title { font-size: 0.9375rem; font-weight: 600; color: var(--sc-text-2); }
.sc-topbar__spacer { flex: 1; }

.sc-rail {
  grid-area: rail;
  border-right: 1px solid var(--sc-line);
  background: var(--sc-surface);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: var(--sc-topbar-h);
  height: calc(100vh - var(--sc-topbar-h));
  overflow-y: auto;
}

.sc-navlink {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--sc-r);
  color: var(--sc-text-2);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--sc-fast) var(--sc-ease), color var(--sc-fast) var(--sc-ease);
}
.sc-navlink:hover { background: var(--sc-surface-2); color: var(--sc-text); text-decoration: none; }
.sc-navlink[aria-current="page"] {
  background: var(--sc-brand-wash);
  color: var(--sc-brand-ink);
  font-weight: 600;
}
.sc-navlink svg { flex: none; width: 18px; height: 18px; }
.sc-navlink__badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--sc-alarm);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sc-main { grid-area: main; min-width: 0; }
.sc-wrap { max-width: var(--sc-maxw); padding: 28px 32px 64px; }
.sc-wrap--narrow { max-width: 860px; }
/* Panel y lista: la información es una tabla, usa todo el ancho disponible. */
.sc-wrap--wide { max-width: none; }

.sc-pagetop {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--sc-line);
}
.sc-pagetop__text { min-width: 0; }
.sc-pagetop__text .sc-meta { margin-top: 4px; }
.sc-pagetop__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   5. Botones
   -------------------------------------------------------------------------- */
.sc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--sc-r);
  background: transparent;
  color: var(--sc-text);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--sc-fast) var(--sc-ease), border-color var(--sc-fast) var(--sc-ease), color var(--sc-fast) var(--sc-ease);
}
.sc-btn:hover { text-decoration: none; }
.sc-btn svg { width: 16px; height: 16px; flex: none; }
.sc-btn:disabled, .sc-btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

.sc-btn--primary { background: var(--sc-brand); border-color: var(--sc-brand); color: var(--sc-on-brand); }
.sc-btn--primary:hover:not(:disabled) { background: var(--sc-brand-hover); border-color: var(--sc-brand-hover); }

.sc-btn--secondary { background: var(--sc-surface-2); border-color: var(--sc-line-2); color: var(--sc-text); }
.sc-btn--secondary:hover:not(:disabled) { background: var(--sc-raised); border-color: var(--sc-text-3); }

.sc-btn--ghost { color: var(--sc-text-2); }
.sc-btn--ghost:hover:not(:disabled) { background: var(--sc-surface-2); color: var(--sc-text); }

.sc-btn--danger { background: var(--sc-alarm); border-color: var(--sc-alarm); color: #fff; }
.sc-btn--danger:hover:not(:disabled) { filter: brightness(1.08); }

.sc-btn--quiet-danger { color: var(--sc-alarm); border-color: var(--sc-line-2); }
.sc-btn--quiet-danger:hover:not(:disabled) { background: var(--sc-alarm-wash); border-color: var(--sc-alarm); }

.sc-btn--sm { height: 31px; padding: 0 11px; font-size: 0.8125rem; }
.sc-btn--block { width: 100%; }
.sc-btn--icon { width: 38px; padding: 0; }
.sc-btn--icon.sc-btn--sm { width: 31px; }

/* Toggle de tema */
.sc-theme-toggle {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--sc-line-2);
  border-radius: var(--sc-r);
  background: var(--sc-surface-2);
  color: var(--sc-text-2);
  cursor: pointer;
  transition: background var(--sc-fast) var(--sc-ease), color var(--sc-fast) var(--sc-ease);
}
.sc-theme-toggle:hover { background: var(--sc-raised); color: var(--sc-text); }
.sc-theme-toggle svg { width: 17px; height: 17px; }
[data-sc-theme-toggle] .sc-icon-moon { display: none; }
[data-sc-theme="light"] [data-sc-theme-toggle] .sc-icon-moon { display: block; }
[data-sc-theme="light"] [data-sc-theme-toggle] .sc-icon-sun { display: none; }

/* --------------------------------------------------------------------------
   6. Superficies
   -------------------------------------------------------------------------- */
.sc-panel {
  background: var(--sc-surface);
  border: 1px solid var(--sc-line);
  border-radius: var(--sc-r-lg);
}
.sc-panel__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--sc-line);
}
.sc-panel__head h2, .sc-panel__head h3 { font-size: 0.9375rem; font-weight: 600; }
.sc-panel__head .sc-meta { margin-left: auto; }
.sc-panel__body { padding: 20px; }
.sc-panel__body--flush { padding: 0; }

/* --------------------------------------------------------------------------
   7. La banda de umbral — el elemento que define el producto
   -------------------------------------------------------------------------- */
.sc-band {
  --band-h: 40px;
  display: block;
}
.sc-band__track {
  position: relative;
  height: var(--band-h);
  border-radius: var(--sc-r);
  overflow: hidden;
  background: var(--sc-surface-2);
  border: 1px solid var(--sc-line);
}
.sc-band__zone {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--sc-alarm-wash);
}
.sc-band__zone--off { background: var(--sc-offline-wash); }
.sc-band__safe {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--sc-ok-wash);
  border-left: 1px solid var(--sc-ok);
  border-right: 1px solid var(--sc-ok);
}
.sc-band__safe-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, var(--sc-ok-wash) 100%);
}
.sc-band__tick {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 3px;
  margin-left: -1.5px;
  background: var(--sc-text);
  border-radius: 2px;
  transition: left var(--sc-base) var(--sc-ease), background var(--sc-base) var(--sc-ease);
}
.sc-band__tick::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 11px;
  height: 11px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--sc-text);
  box-shadow: 0 0 0 3px var(--sc-surface);
}
.sc-band[data-state="ok"] .sc-band__tick,
.sc-band[data-state="ok"] .sc-band__tick::after { background: var(--sc-ok); }
.sc-band[data-state="warn"] .sc-band__tick,
.sc-band[data-state="warn"] .sc-band__tick::after { background: var(--sc-warn); }
.sc-band[data-state="alarm"] .sc-band__tick,
.sc-band[data-state="alarm"] .sc-band__tick::after { background: var(--sc-alarm); }
/* Bajo el mínimo: el desvío es frío, no de alarma roja. */
.sc-band[data-state="alarm"][data-dir="low"] .sc-band__tick,
.sc-band[data-state="alarm"][data-dir="low"] .sc-band__tick::after { background: var(--sc-cold); }
.sc-band[data-state="offline"] .sc-band__tick { opacity: 0.4; }
.sc-band[data-state="offline"] .sc-band__tick::after { background: var(--sc-offline); }

.sc-band__scale {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--sc-mono);
  font-size: 0.6875rem;
  color: var(--sc-text-3);
}
.sc-band__readout {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.sc-band__value {
  font-family: var(--sc-mono);
  font-size: 2.25rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--sc-text);
}
.sc-band__unit { font-size: 1rem; color: var(--sc-text-3); font-weight: 500; }
.sc-band[data-state="ok"] .sc-band__value { color: var(--sc-ok); }
.sc-band[data-state="warn"] .sc-band__value { color: var(--sc-warn); }
.sc-band[data-state="alarm"] .sc-band__value { color: var(--sc-alarm); }
.sc-band[data-state="alarm"][data-dir="low"] .sc-band__value { color: var(--sc-cold); }
.sc-band[data-state="offline"] .sc-band__value { color: var(--sc-offline); }

/* Variante compacta para tarjetas de sensor */
.sc-band--sm { --band-h: 20px; }
.sc-band--sm .sc-band__tick::after { width: 8px; height: 8px; box-shadow: 0 0 0 2px var(--sc-surface); }
.sc-band--sm .sc-band__scale { display: none; }

/* --------------------------------------------------------------------------
   8. Estados (pastillas)
   -------------------------------------------------------------------------- */
.sc-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 23px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--sc-surface-2);
  border: 1px solid var(--sc-line-2);
  color: var(--sc-text-2);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.sc-pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.sc-pill--ok { background: var(--sc-ok-wash); border-color: transparent; color: var(--sc-ok); }
.sc-pill--warn { background: var(--sc-warn-wash); border-color: transparent; color: var(--sc-warn); }
.sc-pill--alarm { background: var(--sc-alarm-wash); border-color: transparent; color: var(--sc-alarm); }
.sc-pill--offline { background: var(--sc-offline-wash); border-color: transparent; color: var(--sc-offline); }
.sc-pill--cold { background: var(--sc-cold-wash); border-color: transparent; color: var(--sc-cold); }
.sc-pill--brand { background: var(--sc-brand-wash); border-color: transparent; color: var(--sc-brand-ink); }
.sc-pill--plain::before { display: none; }

/* --------------------------------------------------------------------------
   9. Tablas
   -------------------------------------------------------------------------- */
.sc-tablewrap { overflow-x: auto; }
.sc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.sc-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--sc-text-3);
  border-bottom: 1px solid var(--sc-line-2);
  background: var(--sc-surface-2);
  white-space: nowrap;
}
.sc-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--sc-line);
  color: var(--sc-text-2);
  vertical-align: middle;
}
.sc-table tbody tr:last-child td { border-bottom: 0; }
.sc-table tbody tr:hover td { background: var(--sc-surface-2); }
.sc-table td:first-child { color: var(--sc-text); font-weight: 500; }
.sc-table .sc-num { color: var(--sc-text); }
.sc-table__actions { text-align: right; white-space: nowrap; }
.sc-table__actions .sc-btn + .sc-btn { margin-left: 4px; }

/* --------------------------------------------------------------------------
   10. Formularios
   -------------------------------------------------------------------------- */
.sc-field { margin-bottom: 16px; }
.sc-field:last-child { margin-bottom: 0; }
.sc-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--sc-text-2);
}
.sc-input,
.sc-select,
.sc-textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--sc-surface-2);
  border: 1px solid var(--sc-line-2);
  border-radius: var(--sc-r);
  color: var(--sc-text);
  font-size: 0.9375rem;
  transition: border-color var(--sc-fast) var(--sc-ease), background var(--sc-fast) var(--sc-ease);
}
.sc-textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.sc-input::placeholder, .sc-textarea::placeholder { color: var(--sc-text-3); }
.sc-input:hover, .sc-select:hover, .sc-textarea:hover { border-color: var(--sc-text-3); }
.sc-input:focus, .sc-select:focus, .sc-textarea:focus {
  outline: none;
  border-color: var(--sc-brand);
  background: var(--sc-surface);
  box-shadow: 0 0 0 3px var(--sc-brand-wash);
}
.sc-input[aria-invalid="true"] { border-color: var(--sc-alarm); }
.sc-select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%237e8dac' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 12px;
}
.sc-help { margin-top: 6px; font-size: 0.8125rem; color: var(--sc-text-3); }

/* Checkbox binaria — accent-color de marca, semántica nativa intacta */
.sc-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9375rem;
  color: var(--sc-text-2);
  cursor: pointer;
}
.sc-check input[type="checkbox"] {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--sc-brand);
  cursor: pointer;
}
.sc-check .sc-help { display: block; margin-top: 2px; }
.sc-field--row { display: flex; gap: 12px; flex-wrap: wrap; }
.sc-field--row > * { flex: 1 1 180px; }

.sc-input-group { position: relative; }
.sc-input-group .sc-input { padding-right: 42px; }
.sc-input-group__btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--sc-r-sm);
  background: transparent;
  color: var(--sc-text-3);
  cursor: pointer;
}
.sc-input-group__btn:hover { background: var(--sc-surface); color: var(--sc-text); }
.sc-input-group__btn svg { width: 17px; height: 17px; }

/* Grupo con botón de texto al lado (p. ej. Copiar), no de ícono */
.sc-input-group--text { display: flex; gap: 8px; }
.sc-input-group--text .sc-input { flex: 1; min-width: 0; padding-right: 12px; }
.sc-input-group--text .sc-input-group__btn {
  position: static;
  transform: none;
  flex: none;
  width: auto;
  height: auto;
  padding: 0 14px;
  border: 1px solid var(--sc-line-2);
  background: var(--sc-surface-2);
  color: var(--sc-text-2);
  font-size: 0.875rem;
  font-weight: 600;
}
.sc-input-group--text .sc-input-group__btn:hover {
  background: var(--sc-surface);
  color: var(--sc-text);
}

/* Control segmentado */
.sc-segment {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--sc-surface-2);
  border: 1px solid var(--sc-line);
  border-radius: var(--sc-r);
}
.sc-segment button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--sc-r-sm);
  background: transparent;
  color: var(--sc-text-2);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--sc-fast) var(--sc-ease), color var(--sc-fast) var(--sc-ease);
}
.sc-segment button:hover { color: var(--sc-text); }
.sc-segment button[aria-pressed="true"] {
  background: var(--sc-surface);
  color: var(--sc-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.sc-segment button .sc-count {
  font-family: var(--sc-mono);
  font-size: 0.75rem;
  color: var(--sc-text-3);
}
.sc-segment button[aria-pressed="true"] .sc-count { color: var(--sc-brand-ink); }

/* --------------------------------------------------------------------------
   11. Alertas y mensajes
   -------------------------------------------------------------------------- */
.sc-note {
  display: flex;
  gap: 11px;
  padding: 12px 15px;
  border-radius: var(--sc-r);
  border: 1px solid var(--sc-line-2);
  background: var(--sc-surface-2);
  font-size: 0.875rem;
  color: var(--sc-text-2);
}
.sc-note svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.sc-note--ok { background: var(--sc-ok-wash); border-color: transparent; color: var(--sc-ok); }
.sc-note--warn { background: var(--sc-warn-wash); border-color: transparent; color: var(--sc-warn); }
.sc-note--alarm { background: var(--sc-alarm-wash); border-color: transparent; color: var(--sc-alarm); }
.sc-note--brand { background: var(--sc-brand-wash); border-color: transparent; color: var(--sc-brand-ink); }
.sc-note strong { color: inherit; }

.sc-formmsg { margin-top: 12px; }
.sc-formmsg:empty { display: none; }

/* --------------------------------------------------------------------------
   12. Diálogo
   -------------------------------------------------------------------------- */
.sc-dialog {
  border: 1px solid var(--sc-line-2);
  border-radius: var(--sc-r-lg);
  background: var(--sc-surface);
  color: var(--sc-text);
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  box-shadow: var(--sc-shadow-lg);
}
.sc-dialog::backdrop { background: rgba(3, 6, 14, 0.62); backdrop-filter: blur(3px); }
[data-sc-theme="light"] .sc-dialog::backdrop { background: rgba(12, 21, 36, 0.42); }
.sc-dialog__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 0;
}
.sc-dialog__head h2 { font-size: 1.0625rem; font-weight: 700; }
.sc-dialog__head .sc-meta { margin-top: 3px; }
.sc-dialog__close {
  margin-left: auto;
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--sc-r-sm);
  background: transparent;
  color: var(--sc-text-3);
  cursor: pointer;
  flex: none;
}
.sc-dialog__close:hover { background: var(--sc-surface-2); color: var(--sc-text); }
.sc-dialog__close svg { width: 16px; height: 16px; }
.sc-dialog__body { padding: 16px 20px 20px; }
.sc-dialog__foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--sc-line);
  background: var(--sc-surface-2);
  border-radius: 0 0 var(--sc-r-lg) var(--sc-r-lg);
}

/* --------------------------------------------------------------------------
   13. Estados vacíos / carga
   -------------------------------------------------------------------------- */
/* Fila dePlaceholder para tablas sin datos ni error */
.sc-empty-cell {
  text-align: center;
  padding: 34px 16px;
  color: var(--sc-text-3);
  font-size: 0.875rem;
}

.sc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 52px 24px;
  color: var(--sc-text-3);
}
.sc-empty svg { width: 30px; height: 30px; color: var(--sc-line-2); }
.sc-empty h3 { font-size: 0.9375rem; font-weight: 600; color: var(--sc-text-2); }
.sc-empty p { font-size: 0.875rem; max-width: 42ch; }

.sc-spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--sc-line-2);
  border-top-color: var(--sc-brand);
  border-radius: 50%;
  animation: sc-spin 0.7s linear infinite;
}
@keyframes sc-spin { to { transform: rotate(360deg); } }

/* El atributo hidden manda: un display del author (flex, grid) no lo pisa.
   Sin esto, elementos como el spinner quedaban visibles para siempre. */
[hidden] { display: none !important; }

.sc-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 48px 20px;
  color: var(--sc-text-3);
  font-size: 0.875rem;
}

/* --------------------------------------------------------------------------
   14. Cabecera pública (marketing / auth)
   -------------------------------------------------------------------------- */
.sc-pub {
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--sc-topbar-h);
  padding: 0 28px;
  border-bottom: 1px solid var(--sc-line);
  background: var(--sc-surface);
  position: sticky;
  top: 0;
  z-index: 50;
}
.sc-pub__brand { display: flex; align-items: center; flex: none; }
/* El logo nuevo trae su propio marco con degradado y fondo transparente:
   va directo sobre la superficie. En tema claro se le pone una platita
   blanca para que el interior del marco conserve el look de chip. */
.sc-pub__brand img,
.sc-brand-cell img,
.sc-topbar__brand img,
.sc-drawer__head img,
.sc-auth__mark-sm img {
  height: 36px;
  width: auto;
  display: block;
}
[data-sc-theme="light"] .sc-pub__brand img,
[data-sc-theme="light"] .sc-brand-cell img,
[data-sc-theme="light"] .sc-topbar__brand img,
[data-sc-theme="light"] .sc-drawer__head img,
[data-sc-theme="light"] .sc-auth__mark-sm img {
  box-sizing: content-box;
  background: #fff;
  padding: 3px 5px;
  border-radius: 10px;
}
.sc-pub__nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.sc-pub__nav a {
  padding: 7px 12px;
  border-radius: var(--sc-r);
  color: var(--sc-text-2);
  font-size: 0.875rem;
  font-weight: 500;
}
.sc-pub__nav a:hover { background: var(--sc-surface-2); color: var(--sc-text); text-decoration: none; }
.sc-pub__nav a[aria-current="page"] { color: var(--sc-text); font-weight: 600; }
.sc-pub__actions { display: flex; align-items: center; gap: 8px; flex: none; }

.sc-burger {
  display: none;
  width: 38px; height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--sc-line-2);
  border-radius: var(--sc-r);
  background: var(--sc-surface-2);
  color: var(--sc-text-2);
  cursor: pointer;
  margin-left: auto;
}
.sc-burger svg { width: 18px; height: 18px; }

.sc-scrim {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 14, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--sc-base) var(--sc-ease), visibility var(--sc-base);
  z-index: 60;
}
.sc-scrim[data-open] { opacity: 1; visibility: visible; }

.sc-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(300px, 84vw);
  padding: 18px;
  background: var(--sc-surface);
  border-left: 1px solid var(--sc-line);
  transform: translateX(100%);
  transition: transform var(--sc-base) var(--sc-ease);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sc-drawer[data-open] { transform: translateX(0); }
.sc-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--sc-line);
}
/* El botón de cerrar es un cuadrado propio: no hereda el position:absolute
   del componente de input-group, que lo dejaba flotando en el drawer. */
.sc-drawer__head .sc-input-group__btn {
  position: static;
  transform: none;
  flex: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--sc-line-2);
  border-radius: var(--sc-r);
  background: var(--sc-surface-2);
  color: var(--sc-text-2);
}
.sc-drawer .sc-navlink { padding: 11px 12px; font-size: 0.9375rem; }
/* Tema claro/oscuro como fila del menú, no un botón suelto. */
.sc-drawer__theme {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: none;
  width: 100%;
  font-family: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
}
/* Acciones de cuenta cuando no hay sesión: visibles también en el menú. */
.sc-drawer__auth {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--sc-line);
}
.sc-drawer__auth .sc-btn { width: 100%; justify-content: center; }

/* --------------------------------------------------------------------------
   15. Grids
   -------------------------------------------------------------------------- */
.sc-grid { display: grid; gap: 16px; }
/* Columnas fijas por variante: con auto-fit, 6 cards en pantalla ancha
   caían 4+2. Cantidades fijas garantizan filas completas (6 = 3+3). */
.sc-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sc-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sc-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) {
  .sc-grid--3, .sc-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .sc-grid--2, .sc-grid--3, .sc-grid--4 { grid-template-columns: 1fr; }
}

.sc-stack { display: flex; flex-direction: column; gap: 16px; }
.sc-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sc-row--between { justify-content: space-between; }

/* Dos columnas que se apilan solas en pantallas angostas */
.sc-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) { .sc-two { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------------
   16. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1000px) {
  .sc-app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .sc-brand-cell { display: none; }
  .sc-rail { display: none; }
  .sc-topbar { border-bottom: 1px solid var(--sc-line); gap: 12px; }
  .sc-topbar__brand { display: inline-flex; align-items: center; flex: none; }
  .sc-topbar__burger { display: inline-flex; }
  .sc-wrap { padding: 20px 18px 56px; }
}

@media (max-width: 760px) {
  .sc-pub { padding: 0 16px; gap: 12px; }
  .sc-pub__nav, .sc-pub__actions .sc-btn { display: none; }
  .sc-burger { display: inline-flex; margin-left: 0; }
  .sc-pub__actions { margin-left: 0; }
  .sc-pub__brand { margin-right: auto; }
  .sc-pagetop__actions { margin-left: 0; width: 100%; }
  .sc-band__value { font-size: 1.875rem; }
  .sc-dialog__foot { flex-direction: column-reverse; }
  .sc-dialog__foot .sc-btn { width: 100%; }
}

@media (max-width: 480px) {
  body { font-size: 14.5px; }
  .sc-wrap { padding: 16px 14px 48px; }
  .sc-panel__body { padding: 16px; }
  .sc-grid { gap: 12px; }
  .sc-segment { width: 100%; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .sc-topbar, .sc-rail, .sc-pagtop__actions, .sc-theme-toggle { display: none; }
  body { background: #fff; color: #000; }
}
