:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e8ecf3;
  --text-muted: rgba(232, 236, 243, 0.7);
  --primary: #2f6fed;
  --primary-hover: #4880f5;
  --accent: #ffcc66;
  --error-bg: rgba(255, 80, 80, 0.12);
  --error-text: #ffb7b7;
  --ok-bg: rgba(90, 220, 140, 0.12);
  --ok-text: #b6f3cc;
}

* {
  box-sizing: border-box;
}

/* Heading visualmente oculto pero accesible (mejora SEO + lectores de pantalla). */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body,
html,
#root {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  min-width: 0;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 18, 26, 0.92);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 120;
  min-width: 0;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  min-width: 0;
  flex: 1 1 auto;
}

a.brand-home-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

a.brand-home-link:hover {
  opacity: 0.9;
}

a.brand-home-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 8px;
}

.topbar .brand > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .brand img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.topbar .nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.topbar .menu-toggle {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

@media (min-width: 900px) {
  .topbar .menu-toggle {
    display: none;
  }
}

.topbar .user-pill {
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
  max-width: min(160px, 38vw);
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 12px;
  width: 100%;
  max-width: min(1100px, 100%);
  margin: 0 auto;
  box-sizing: border-box;
  min-width: 0;
  align-items: start;
}

@media (min-width: 900px) {
  .app-body {
    grid-template-columns: 240px 1fr;
    align-items: start;
  }
}

.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 70px;
  min-width: 0;
}

.sidebar.mobile-open {
  display: flex;
}

@media (max-width: 899px) {
  .sidebar {
    position: fixed;
    top: 56px;
    left: 8px;
    right: 8px;
    max-height: calc(100dvh - 72px);
    overflow-y: auto;
    z-index: 115;
    display: none;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
    background: #141821;
    border: 1px solid var(--border-strong);
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.mobile-open {
    display: flex;
  }
}

.sidebar a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;
}

.sidebar a.active {
  background: var(--primary);
  color: white;
}

.sidebar .group-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 12px 4px;
  letter-spacing: 0.6px;
}

.content {
  display: grid;
  gap: 16px;
  min-width: 0;
  width: 100%;
  /* hidden cortaba el scroll horizontal de tablas anchas (p. ej. Máquinas) */
  overflow-x: auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.card h1,
.card h2,
.card h3 {
  margin-top: 0;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  font-size: 14px;
}

input,
select,
textarea {
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 12px;
  width: 100%;
  font: inherit;
}

/* Menús nativos de <select>: contraste legible en tema oscuro (Windows/Chrome suele mezclar fondo claro + texto claro). */
select {
  color-scheme: dark;
  accent-color: var(--primary);
  background-color: rgba(255, 255, 255, 0.08);
}

select option,
select optgroup {
  /* Valores sólidos: algunos motores no aplican bien variables en <option> */
  background-color: #12151c;
  color: #e8ecf3;
}

select option:checked,
select option:hover {
  background-color: #2f6fed;
  color: #ffffff;
}

select option:disabled {
  background-color: #12151c;
  color: rgba(232, 236, 243, 0.45);
}

button {
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--primary);
  color: white;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--primary-hover);
}

button.secondary {
  background: rgba(255, 255, 255, 0.06);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.row .grow {
  flex: 1;
}

.error,
.success {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
}

.error {
  background: var(--error-bg);
  border: 1px solid rgba(255, 80, 80, 0.3);
  color: var(--error-text);
}

.success {
  background: var(--ok-bg);
  border: 1px solid rgba(90, 220, 140, 0.3);
  color: var(--ok-text);
}

.tableWrap {
  margin-top: 12px;
  overflow-x: auto;
}

.dataTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.dataTable th,
.dataTable td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.dataTable th {
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
}

.checkboxLine {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkboxLine input {
  width: auto;
}

/* Legacy toast classes (Downloads) — prefer useUi() */
.toast {
  display: none;
}

.footerLine {
  border-top: 1px solid var(--border);
  padding: 14px 12px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
  box-sizing: border-box;
  word-break: break-word;
}

.footerLine a {
  color: var(--accent);
  font-weight: 600;
}

.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.login-shell main {
  display: grid;
  place-items: center;
  padding: 20px 16px;
}

.login-shell .login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
}

.login-shell h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.dashboard-hero {
  background: linear-gradient(135deg, rgba(47, 111, 237, 0.18), rgba(47, 111, 237, 0.04));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
}

.dashboard-hero h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

@media (min-width: 600px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.stat-card .label {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.stat-card .value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 4px;
}

.password-toggle {
  position: relative;
}

.password-toggle input {
  padding-right: 42px;
}

.password-toggle .eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  font-size: 14px;
}

.eye:hover {
  color: var(--text);
}

@media (max-width: 520px) {
  .topbar {
    flex-wrap: nowrap;
  }

  .topbar .user-pill {
    max-width: min(120px, 32vw);
  }
}

body.nav-drawer-open {
  overflow: hidden;
  touch-action: none;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 899px) {
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(0, 0, 0, 0.72);
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    appearance: none;
  }
}

.ui-toast-stack {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 4000;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  align-items: center;
  pointer-events: none;
  max-width: calc(100vw - 24px);
  width: min(420px, 100%);
}

.ui-toast {
  pointer-events: auto;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  animation: ui-toast-in 0.22s ease-out;
}

@keyframes ui-toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ui-toast--ok {
  border: 1px solid rgba(90, 220, 140, 0.4);
  background: rgba(22, 58, 36, 0.96);
  color: #d4fbe3;
}

.ui-toast--err {
  border: 1px solid rgba(255, 100, 100, 0.45);
  background: rgba(72, 22, 22, 0.96);
  color: #ffd6d6;
}

.ui-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3500;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.ui-confirm {
  width: min(400px, 100%);
  background: #151923;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
}

.ui-confirm h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.ui-confirm-msg {
  margin: 0 0 16px;
  white-space: pre-wrap;
}

.ui-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

button.danger {
  background: #b83232;
  border-color: rgba(255, 255, 255, 0.22);
}

button.danger:hover:not(:disabled) {
  background: #cf4040;
}

.table-stack-wrap {
  overflow-x: auto;
  max-width: 100%;
}

@media (max-width: 720px) {
  .table-stack-wrap.table-stack-enabled {
    overflow-x: visible;
  }

  table.table-stack.table-stack-enabled thead {
    display: none;
  }

  table.table-stack.table-stack-enabled tbody tr {
    display: block;
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
  }

  table.table-stack.table-stack-enabled tbody td {
    display: block;
    border: none;
    padding: 8px 0;
  }

  table.table-stack.table-stack-enabled tbody td[data-label]:before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
  }
}

.action-icon-btn .action-emoji {
  display: none;
}

.action-icon-btn .action-text {
  display: inline;
}

@media (max-width: 720px) {
  .action-icon-btn {
    padding: 8px 10px;
    min-width: 44px;
    min-height: 40px;
  }

  .action-icon-btn .action-emoji {
    display: inline;
    font-size: 18px;
    line-height: 1;
  }

  .action-icon-btn .action-text {
    display: none;
  }
}

/* Descargas admin: acciones solo icono / emoji */
.release-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

a.release-action-icon,
button.release-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 17px;
  line-height: 1;
  box-sizing: border-box;
}

a.release-action-icon {
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
}

a.release-action-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

button.release-action-icon.release-download-unavailable {
  opacity: 0.65;
  cursor: not-allowed;
  border-style: dashed;
}

/* Descargas: versiones cuyo .exe ya no está en disco */
.release-row-no-file td {
  opacity: 0.92;
}

.release-offline-badge {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.release-offline-badge--warn {
  color: #e8a854;
}

.session-boot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42vh;
  padding: 24px;
}

/* Máquinas: tabla fluida sin scroll horizontal doble; texto largo en tooltip / ellipsis */
.machines-table-wrap {
  overflow-x: visible;
  margin-left: 0;
  margin-right: 0;
  padding-bottom: 0;
}

table.dataTable.machines-table {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  table-layout: fixed;
}

.machines-cell-clip {
  overflow: hidden;
  max-width: 0;
  vertical-align: middle;
}

.machines-one-line {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.machines-cell-mac {
  font-size: 12px;
}

.machines-status-line {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.machines-seen-line {
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table.machines-table th:last-child,
table.machines-table td:last-child {
  white-space: nowrap;
  vertical-align: middle;
  max-width: none;
}

@media (max-width: 720px) {
  table.dataTable.machines-table {
    table-layout: auto;
  }

  .machines-cell-clip {
    max-width: none;
  }
}

.pagination-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

.pagination-nav .nav-label {
  display: inline;
}

.pagination-nav .nav-emoji {
  display: none;
}

@media (max-width: 520px) {
  .pagination-nav .nav-label {
    display: none;
  }

  .pagination-nav .nav-emoji {
    display: inline;
    font-size: 18px;
  }
}

.toolbar-recarga .label-full {
  display: inline;
}

.toolbar-recarga .label-emoji {
  display: none;
}

@media (max-width: 520px) {
  .toolbar-recarga .label-full {
    display: none;
  }

  .toolbar-recarga .label-emoji {
    display: inline;
    font-size: 16px;
  }
}

.notice-must-change {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 180, 80, 0.35);
  background: rgba(255, 180, 80, 0.1);
  color: var(--text);
  line-height: 1.45;
}

.notice-warn {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 140, 90, 0.35);
  background: rgba(255, 120, 60, 0.08);
  color: var(--text);
  line-height: 1.45;
}

.btn-logout-label {
  display: inline;
}

.btn-logout-emoji {
  display: none;
}

@media (max-width: 480px) {
  .btn-logout-label {
    display: none;
  }

  .btn-logout-emoji {
    display: inline;
    font-size: 18px;
  }
}

.landing-shell {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(900px 600px at 90% -10%, rgba(47, 111, 237, 0.18), transparent 60%),
    radial-gradient(700px 500px at -10% 30%, rgba(255, 204, 102, 0.08), transparent 60%),
    var(--bg);
}

.landing-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(11, 13, 18, 0.6);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.landing-topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.landing-topbar a.brand-home-link {
  color: inherit;
}

.landing-topbar .brand img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.landing-cta-pill {
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
}

.landing-cta-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.landing-main {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 22px 64px;
  display: grid;
  gap: 56px;
}

.landing-hero {
  text-align: center;
  padding: 24px 8px 0;
}

.landing-eyebrow {
  text-transform: uppercase;
  letter-spacing: 1.4px;
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.landing-hero h1 {
  margin: 0 0 16px;
  font-size: clamp(36px, 6vw, 64px);
  line-height: 1.05;
  letter-spacing: -1px;
  color: var(--text);
  font-weight: 800;
}

.landing-lead {
  margin: 0 auto;
  max-width: 640px;
  color: var(--text-muted);
  font-size: clamp(15px, 1.6vw, 18px);
  line-height: 1.55;
}

.landing-cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 28px;
}

.landing-cta-row--single {
  flex-direction: column;
  align-items: stretch;
}

.landing-cta-row--single .btn-primary {
  width: min(100%, 320px);
  margin-left: auto;
  margin-right: auto;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 22px;
  font-weight: 600;
  font-size: 15px;
}

.btn-primary:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 22px;
  font-weight: 600;
  font-size: 15px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}

.landing-features {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  scroll-margin-top: 88px;
}

@media (min-width: 720px) {
  .landing-features {
    grid-template-columns: repeat(2, 1fr);
  }
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
}

.feature-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.feature-card p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
  font-size: 14px;
}

.landing-bottom-cta {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 24px;
  display: grid;
  gap: 12px;
  justify-items: center;
}

.landing-bottom-cta h2 {
  margin: 0;
  font-size: clamp(22px, 3vw, 30px);
  color: var(--text);
  font-weight: 800;
}
