/* ==========================================================================
   Pain Panel — hoja de estilos
   Tema oscuro, superficies planas, un solo acento (rojo Pain) y tipografía
   de sistema. Sin degradados chillones ni brillos: se ve como una herramienta
   de trabajo, no como una landing.
   ========================================================================== */

:root {
  --bg: #0b0c0f;
  --bg-soft: #101217;
  --surface: #14161c;
  --surface-2: #191c23;
  --surface-3: #1e222a;
  --line: #242833;
  --line-soft: #1c1f27;
  --text: #e6e8ed;
  --text-2: #b3b8c4;
  --muted: #8a909d;
  --muted-2: #6b7180;

  --accent: #e8453c;
  --accent-hover: #f2564c;
  --accent-soft: rgba(232, 69, 60, 0.12);
  --accent-line: rgba(232, 69, 60, 0.34);
  --accent-2: #ff8a3d;

  --success: #34c48b;
  --success-soft: rgba(52, 196, 139, 0.12);
  --info: #4aa6f0;
  --info-soft: rgba(74, 166, 240, 0.12);
  --warn: #e3ae3c;
  --warn-soft: rgba(227, 174, 60, 0.12);
  --danger: #ef4d4d;
  --danger-soft: rgba(239, 77, 77, 0.12);

  --radius: 12px;
  --radius-sm: 9px;
  --radius-lg: 16px;

  --sidebar-w: 254px;
  --sidebar-w-collapsed: 74px;
  --topbar-h: 62px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", "Apple Color Emoji", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--text);
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

svg {
  width: 18px;
  height: 18px;
  flex: none;
}

::selection {
  background: var(--accent-soft);
  color: #fff;
}

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

/* ── Utilidades ─────────────────────────────────────────────────────────── */
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12.5px;
}

.tiny {
  font-size: 11.5px;
}

.nowrap {
  white-space: nowrap;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.grow {
  flex: 1;
  min-width: 0;
}

.hidden {
  display: none !important;
}

.mobile-only {
  display: none !important;
}

.right {
  text-align: right;
}

.text-success {
  color: var(--success);
}

.text-warn {
  color: var(--warn);
}

.text-danger {
  color: var(--danger);
}

.text-accent {
  color: var(--accent);
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Boot ───────────────────────────────────────────────────────────────── */
.boot {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  color: var(--muted);
}

.boot-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}

.boot-mark svg {
  width: 100%;
  height: 100%;
}

.boot-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  flex: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Marca ──────────────────────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  overflow: hidden;
  flex: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-text {
  min-width: 0;
}

.brand-name {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ── Botones ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.1s ease;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn:hover {
  background: var(--surface-3);
  border-color: #2e3340;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: rgba(239, 77, 77, 0.3);
  color: #ff9a9a;
}

.btn-danger:hover {
  background: rgba(239, 77, 77, 0.18);
  border-color: rgba(239, 77, 77, 0.45);
}

.btn-success {
  background: var(--success-soft);
  border-color: rgba(52, 196, 139, 0.3);
  color: #7ee2b8;
}

.btn-sm {
  height: 32px;
  padding: 0 11px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.icon-btn.sm {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.icon-btn.sm svg {
  width: 15px;
  height: 15px;
}

.icon-btn.danger:hover {
  color: #ff9a9a;
  border-color: rgba(239, 77, 77, 0.4);
  background: var(--danger-soft);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Formularios ────────────────────────────────────────────────────────── */
.field {
  display: grid;
  gap: 7px;
  margin-bottom: 15px;
}

.label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-2);
}

.hint {
  font-size: 11.5px;
  color: var(--muted-2);
  line-height: 1.5;
}

.hint b {
  color: var(--text-2);
  font-weight: 600;
}

.input,
.select,
.textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-2);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: #2e3340;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent-line);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input:disabled,
.select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.textarea {
  height: auto;
  min-height: 88px;
  padding: 11px 13px;
  resize: vertical;
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-icon {
  position: relative;
}

.input-icon > svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted-2);
  pointer-events: none;
}

.input-icon .input {
  padding-left: 36px;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.55;
  cursor: pointer;
  margin-bottom: 15px;
}

.check input {
  margin-top: 2px;
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  flex: none;
}

.check b {
  color: var(--text);
  font-weight: 600;
}

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
}

.form-error,
.form-success {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.form-error svg,
.form-success svg {
  width: 16px;
  height: 16px;
}

.form-error {
  background: var(--danger-soft);
  border: 1px solid rgba(239, 77, 77, 0.28);
  color: #ffa3a3;
}

.form-success {
  background: var(--success-soft);
  border: 1px solid rgba(52, 196, 139, 0.28);
  color: #86e3bd;
}

.form-error.show,
.form-success.show {
  display: flex;
}

/* ── Acceso ─────────────────────────────────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}

.auth-brand {
  position: relative;
  padding: 40px 48px;
  background:
    radial-gradient(900px 420px at 12% 0%, rgba(232, 69, 60, 0.14), transparent 62%),
    var(--bg-soft);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow: hidden;
}

.auth-hero {
  max-width: 520px;
  margin-top: auto;
  margin-bottom: auto;
  padding: 24px 0;
}

.auth-logo {
  display: block;
  width: min(420px, 100%);
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  margin-bottom: 26px;
}

.auth-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  margin-bottom: 18px;
  background: var(--surface);
}

.auth-kicker .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.auth-title {
  font-size: clamp(28px, 3.4vw, 38px);
  line-height: 1.12;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
}

.auth-lead {
  max-width: 460px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.65;
}

.auth-features {
  list-style: none;
  margin: 30px 0 0;
  padding: 0;
  display: grid;
  gap: 2px;
  max-width: 460px;
}

.auth-features li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 11px 0;
  border-top: 1px solid var(--line-soft);
}

.auth-features li:last-child {
  border-bottom: 1px solid var(--line-soft);
}

.auth-features .fi {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--accent);
  flex: none;
}

.auth-features .fi svg {
  width: 15px;
  height: 15px;
}

.auth-features b {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.auth-features span {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-meta {
  margin-top: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted-2);
  font-size: 11.5px;
}

.auth-meta .sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line);
}

.auth-pane {
  display: grid;
  place-items: center;
  padding: 40px 32px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 396px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.auth-card-head {
  margin-bottom: 20px;
}

.auth-card-head h2 {
  font-size: 20px;
  margin-bottom: 6px;
}

.auth-card-head p {
  color: var(--muted);
  font-size: 13px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  margin-bottom: 20px;
}

.auth-tab {
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

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

.auth-tab.active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.auth-submit {
  margin-top: 6px;
}

.auth-legal {
  margin-top: 14px;
  color: var(--muted-2);
  font-size: 11px;
  text-align: center;
  line-height: 1.5;
}

/* ── Shell ──────────────────────────────────────────────────────────────── */
.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  z-index: 40;
  transition: width 0.18s ease, transform 0.2s ease;
}

.sidebar-brand {
  padding: 4px 6px 18px;
}

.nav {
  display: grid;
  gap: 2px;
  overflow-y: auto;
  padding-right: 2px;
  align-content: start;
}

.nav-section {
  margin: 16px 0 6px;
  padding: 0 10px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 38px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.14s ease, color 0.14s ease;
}

.nav-link svg {
  width: 17px;
  height: 17px;
  color: var(--muted);
  transition: color 0.14s ease;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link:hover svg {
  color: var(--text-2);
}

.nav-link.active {
  background: var(--accent-soft);
  color: #ffd9d6;
}

.nav-link.active svg {
  color: var(--accent);
}

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  min-width: 20px;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
}

.nav-link.active .nav-badge {
  background: rgba(232, 69, 60, 0.18);
  border-color: var(--accent-line);
  color: #ffc9c5;
}

.sidebar-foot {
  margin-top: auto;
  padding: 13px 10px 4px;
  border-top: 1px solid var(--line-soft);
}

.sidebar-foot .hint {
  margin-bottom: 6px;
}

.public-url {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-2);
  font-size: 11.5px;
  font-family: var(--mono);
  overflow: hidden;
}

.public-url svg {
  width: 14px;
  height: 14px;
  color: var(--muted-2);
}

.public-url span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 9, 0.62);
  z-index: 35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.18s ease;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  min-height: var(--topbar-h);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(11, 12, 15, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  flex: none;
}

.topbar-toggle:hover {
  background: var(--surface-3);
  color: var(--text);
}

.topbar-title {
  min-width: 0;
}

.topbar-title h1 {
  font-size: 16px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title p {
  font-size: 12px;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
}

.uc-name {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
}

.uc-role {
  font-size: 11px;
  color: var(--muted-2);
  line-height: 1.25;
}

.content {
  padding: 24px;
  width: 100%;
  max-width: 1360px;
  flex: 1;
}

/* Sidebar plegado (escritorio) */
.app-shell.sidebar-collapsed .sidebar {
  width: var(--sidebar-w-collapsed);
  padding: 16px 10px;
}

.app-shell.sidebar-collapsed .main {
  margin-left: var(--sidebar-w-collapsed);
}

.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .nav-section,
.app-shell.sidebar-collapsed .sidebar-foot .hint,
.app-shell.sidebar-collapsed .public-url span {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-brand {
  display: flex;
  justify-content: center;
  padding: 4px 0 18px;
}

.app-shell.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 0;
  gap: 0;
}

.app-shell.sidebar-collapsed .nav-badge {
  position: absolute;
  transform: translate(14px, -12px);
  min-width: 17px;
  height: 17px;
  font-size: 10px;
}

.app-shell.sidebar-collapsed .nav-link {
  position: relative;
}

.app-shell.sidebar-collapsed .sidebar-foot {
  display: flex;
  justify-content: center;
  padding: 13px 0 4px;
}

.app-shell.sidebar-collapsed .public-url svg {
  width: 16px;
  height: 16px;
}

/* ── Cabecera de página ─────────────────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-head h2 {
  font-size: 21px;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.page-head p {
  color: var(--muted);
  font-size: 13px;
}

.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Cards y stats ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.card-head h3 {
  font-size: 14.5px;
  margin-bottom: 3px;
}

.card-head p {
  font-size: 12px;
  color: var(--muted-2);
}

.card-body {
  padding: 18px;
}

.card-body.tight {
  padding: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

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

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.stat-icon svg {
  width: 16px;
  height: 16px;
}

.stat-accent .stat-icon {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.stat-green .stat-icon {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(52, 196, 139, 0.24);
}

.stat-cyan .stat-icon {
  color: var(--info);
  background: var(--info-soft);
  border-color: rgba(74, 166, 240, 0.24);
}

.stat-amber .stat-icon {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: rgba(227, 174, 60, 0.24);
}

.stat-red .stat-icon {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(239, 77, 77, 0.24);
}

.stat-violet .stat-icon {
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(167, 139, 250, 0.24);
}

.stat-value {
  margin: 12px 0 2px;
  font-size: 25px;
  line-height: 1;
  letter-spacing: -0.035em;
  font-weight: 680;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.stat-foot {
  margin-top: 9px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted-2);
  font-size: 11px;
}

/* ── Tablas ─────────────────────────────────────────────────────────────── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  vertical-align: middle;
}

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

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.015);
}

.cell-main {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.cell-title {
  font-weight: 570;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-sub {
  font-size: 11.5px;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  flex: none;
}

.row-icon svg {
  width: 16px;
  height: 16px;
}

.row-icon.green {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(52, 196, 139, 0.24);
}

.row-icon.amber {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: rgba(227, 174, 60, 0.24);
}

.row-icon.red {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(239, 77, 77, 0.24);
}

.row-icon.cyan {
  color: var(--info);
  background: var(--info-soft);
  border-color: rgba(74, 166, 240, 0.24);
}

.actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 560;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
}

.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge.success {
  background: var(--success-soft);
  border-color: rgba(52, 196, 139, 0.26);
  color: #74dfb2;
}

.badge.info {
  background: var(--info-soft);
  border-color: rgba(74, 166, 240, 0.26);
  color: #93c9f7;
}

.badge.warn {
  background: var(--warn-soft);
  border-color: rgba(227, 174, 60, 0.26);
  color: #f0cd7d;
}

.badge.danger {
  background: var(--danger-soft);
  border-color: rgba(239, 77, 77, 0.26);
  color: #ff9d9d;
}

.badge.accent {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: #ffb3ae;
}

.badge.neutral {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--muted);
}

/* ── Sesiones: filtros y selección ─────────────────────────────────────── */
.check-col {
  width: 42px;
  text-align: center;
}

.row-check {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-soft);
}

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 520;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  color: var(--text);
  border-color: #2e3340;
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: #ffb3ae;
}

.chip-count {
  font-size: 11px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

.chip.active .chip-count {
  color: inherit;
}

.selection-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Comunidades ────────────────────────────────────────────────────────── */
.community-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.community-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}

.community-head {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.community-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  flex: none;
}

.community-icon svg {
  width: 18px;
  height: 18px;
}

.community-list {
  display: grid;
}

.community-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.community-row:last-child {
  border-bottom: 0;
}

.community-row.off {
  opacity: 0.55;
}

.community-row .actions {
  align-items: center;
  flex: none;
}

/* ── Empty / loading ────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 38px 20px;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.empty-icon svg {
  width: 20px;
  height: 20px;
}

.empty h4 {
  font-size: 15px;
  margin-bottom: 6px;
}

.empty p {
  color: var(--muted);
  font-size: 13px;
  max-width: 380px;
  margin: 0 auto 16px;
  line-height: 1.6;
}

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.08);
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

.sk-line {
  height: 12px;
  margin: 8px 0;
}

.sk-card {
  height: 96px;
  border-radius: var(--radius);
}

/* ── Pairing ────────────────────────────────────────────────────────────── */
.link-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 18px;
  align-items: start;
}

.pairing-card {
  padding: 24px;
}

.pairing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.pairing-head h3 {
  font-size: 15px;
  margin-bottom: 3px;
}

.pairing-head p {
  font-size: 12.5px;
  color: var(--muted);
}

.code-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 22px 16px;
  text-align: center;
}

.code-kicker {
  color: var(--muted-2);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.code-value {
  margin: 10px 0 6px;
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text);
}

.code-value.pending {
  font-size: 17px;
  letter-spacing: 0;
  color: var(--muted);
}

.code-sub {
  color: var(--muted);
  font-size: 11.5px;
}

.code-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.countdown {
  margin-top: 18px;
}

.countdown-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11.5px;
}

.countdown-top b {
  font-family: var(--mono);
  color: var(--text-2);
}

.progress {
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.9s linear;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.step-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
  flex: none;
}

.steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
}

.steps b {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

.steps span:not(.step-num) {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
}

.pairing-alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.pairing-alert svg {
  width: 16px;
  height: 16px;
  color: var(--muted-2);
  margin-top: 1px;
}

.pairing-alert b {
  color: var(--text-2);
}

/* ── Tabs admin ─────────────────────────────────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.admin-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 12px;
  border-radius: 9px 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 520;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.admin-tab svg {
  width: 15px;
  height: 15px;
}

.admin-tab:hover {
  color: var(--text);
  background: var(--surface);
}

.admin-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: var(--surface);
}

/* ── Sistema / auditoría ────────────────────────────────────────────────── */
.system-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.system-item {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--bg-soft);
  min-width: 0;
}

.si-label {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 4px;
}

.si-value {
  font-size: 15px;
  font-weight: 620;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.si-value small {
  font-size: 11px;
  color: var(--muted-2);
  font-weight: 500;
}

.worker-list {
  display: grid;
  gap: 8px;
}

.worker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--bg-soft);
}

.wr-name {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-2);
}

.wr-meta {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted-2);
}

.timeline {
  position: relative;
  display: grid;
  gap: 0;
  padding-left: 18px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--line);
}

.timeline-item {
  position: relative;
  padding: 0 0 15px 8px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -18px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 2px solid var(--bg);
}

.timeline-item.ok::before {
  background: var(--success);
}

.timeline-item.warn::before {
  background: var(--warn);
}

.timeline-item.bad::before {
  background: var(--danger);
}

.ti-action {
  font-size: 13px;
  font-weight: 560;
}

.ti-meta {
  font-size: 11.5px;
  color: var(--muted-2);
  margin-top: 2px;
}

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 8, 0.7);
  backdrop-filter: blur(3px);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.modal-root,
#modal-root.open .modal-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: fixed;
  z-index: 61;
  top: 50%;
  left: 50%;
  width: min(480px, calc(100vw - 32px));
  transform: translate(-50%, -50%) scale(0.97);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

#modal-root.open .modal {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.modal.wide {
  width: min(720px, calc(100vw - 32px));
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 15px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-head h3 {
  font-size: 15.5px;
}

.modal-head p {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}

.modal-body {
  padding: 19px 20px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-soft);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Toasts ─────────────────────────────────────────────────────────────── */
#toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  gap: 9px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  animation: toast-in 0.18s ease;
}

.toast svg {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  color: var(--muted);
}

.toast span {
  flex: 1;
  line-height: 1.5;
}

.toast.success {
  border-color: rgba(52, 196, 139, 0.3);
}

.toast.success svg {
  color: var(--success);
}

.toast.error {
  border-color: rgba(239, 77, 77, 0.32);
}

.toast.error svg {
  color: var(--danger);
}

.toast.warn {
  border-color: rgba(227, 174, 60, 0.3);
}

.toast.warn svg {
  color: var(--warn);
}

.toast-close {
  border: 0;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}

.toast-close svg {
  width: 14px;
  height: 14px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ── Bot principal ──────────────────────────────────────────────────────── */
.main-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  flex-wrap: wrap;
}

.main-hero-logo {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  flex: none;
  background: var(--surface-2);
}

.main-hero-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.main-hero-info {
  min-width: 190px;
  flex: 1 1 220px;
}

.main-hero-info h3 {
  font-size: 16px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.main-hero-info p {
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-word;
}

.main-hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.notice {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.6;
}

.notice svg {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--muted-2);
  flex: none;
}

.notice.warn {
  border-color: rgba(227, 174, 60, 0.28);
  background: var(--warn-soft);
}

.notice.warn svg {
  color: var(--warn);
}

.notice.danger {
  border-color: rgba(239, 77, 77, 0.28);
  background: var(--danger-soft);
}

.notice.danger svg {
  color: var(--danger);
}

.notice b {
  color: var(--text);
  font-weight: 600;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-2,
  .link-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-brand {
    padding: 28px 24px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .auth-hero {
    margin: 0;
    padding: 0;
  }

  .auth-logo {
    width: min(300px, 100%);
  }

  .auth-features {
    display: none;
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
    box-shadow: var(--shadow-lg);
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app-shell.sidebar-open .sidebar-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .main,
  .app-shell.sidebar-collapsed .main {
    margin-left: 0;
  }

  .app-shell.sidebar-collapsed .sidebar {
    width: var(--sidebar-w);
    padding: 16px 12px;
  }

  .app-shell.sidebar-collapsed .brand-text,
  .app-shell.sidebar-collapsed .nav-label,
  .app-shell.sidebar-collapsed .nav-section,
  .app-shell.sidebar-collapsed .sidebar-foot .hint,
  .app-shell.sidebar-collapsed .public-url span {
    display: revert;
  }

  .app-shell.sidebar-collapsed .sidebar-brand {
    display: block;
    padding: 4px 6px 18px;
  }

  .app-shell.sidebar-collapsed .nav-link {
    justify-content: flex-start;
    padding: 0 10px;
    gap: 11px;
  }

  .app-shell.sidebar-collapsed .nav-badge {
    position: static;
    transform: none;
    min-width: 20px;
    height: 19px;
    font-size: 11px;
  }

  .app-shell.sidebar-collapsed .sidebar-foot {
    display: block;
    padding: 13px 10px 4px;
  }

  .content {
    padding: 18px 16px 28px;
  }

  .topbar {
    padding: 10px 16px;
  }

  .uc-name,
  .uc-role {
    display: none;
  }

  .user-chip {
    padding: 4px;
  }
}

@media (max-width: 640px) {
  .system-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-head h2 {
    font-size: 19px;
  }

  .auth-pane {
    padding: 24px 16px 40px;
  }

  .auth-card {
    padding: 22px 18px;
  }

  .code-value {
    font-size: 26px;
  }

  #toast-root {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
  }
}

@media (max-width: 420px) {
  .stats {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar-title p {
    display: none;
  }

  .page-actions .btn {
    flex: 1;
  }
}
