/*
  Alfy API Portal — tema fintech oscuro.
  Replica el diseno del template v0 (slate profundo + acento cyan,
  con tokens de estado verde/rojo/ambar). Forzamos modo oscuro.
*/

:root {
  --background: oklch(0.16 0.012 250);
  --foreground: oklch(0.95 0.005 240);
  --card: oklch(0.2 0.014 250);
  --card-foreground: oklch(0.95 0.005 240);
  --popover: oklch(0.2 0.014 250);
  --primary: oklch(0.7 0.14 205);
  --primary-foreground: oklch(0.16 0.02 240);
  --secondary: oklch(0.26 0.016 250);
  --secondary-foreground: oklch(0.95 0.005 240);
  --muted: oklch(0.24 0.014 250);
  --muted-foreground: oklch(0.66 0.015 250);
  --accent: oklch(0.28 0.03 215);
  --accent-foreground: oklch(0.92 0.02 205);
  --destructive: oklch(0.65 0.2 22);
  --success: oklch(0.72 0.15 158);
  --warning: oklch(0.78 0.15 75);
  --border: oklch(0.3 0.014 250);
  --input: oklch(0.3 0.014 250);
  --ring: oklch(0.7 0.14 205);
  --chart-success: oklch(0.72 0.15 158);
  --chart-errors: oklch(0.68 0.18 25);
  --sidebar: oklch(0.18 0.013 250);
  --sidebar-border: oklch(0.28 0.014 250);
  --radius: 0.75rem;
  --font-sans: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, SFMono-Regular,
    Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
  border-color: var(--border);
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.01em;
}

code,
.mono {
  font-family: var(--font-mono);
}

.icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.icon-sm {
  width: 0.875rem;
  height: 0.875rem;
}
.icon-lg {
  width: 1.25rem;
  height: 1.25rem;
}

.muted {
  color: var(--muted-foreground);
}
.text-success {
  color: var(--success);
}
.text-destructive {
  color: var(--destructive);
}
.text-warning {
  color: var(--warning);
}
.text-primary {
  color: var(--primary);
}

/* ---------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  height: 2.25rem;
  padding: 0 0.9rem;
  border-radius: calc(var(--radius) * 0.8);
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover {
  filter: brightness(1.08);
}
.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--foreground);
}
.btn-outline:hover {
  background: var(--secondary);
  filter: none;
}
.btn-ghost {
  background: transparent;
  color: var(--foreground);
}
.btn-ghost:hover {
  background: var(--secondary);
  filter: none;
}
.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}
.btn-secondary:hover {
  filter: none;
  background: var(--accent);
}
.btn-destructive {
  background: var(--destructive);
  color: #fff;
}
.btn-sm {
  height: 1.9rem;
  padding: 0 0.7rem;
  font-size: 0.8rem;
}
.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}
.btn-icon-sm {
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
}
.btn-icon-xs {
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border-radius: 0.4rem;
}
.btn-block {
  width: 100%;
}

/* ---------------------------------------------------------------- Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-success {
  border-color: color-mix(in oklch, var(--success) 25%, transparent);
  background: color-mix(in oklch, var(--success) 15%, transparent);
  color: var(--success);
}
.badge-warning {
  border-color: color-mix(in oklch, var(--warning) 30%, transparent);
  background: color-mix(in oklch, var(--warning) 15%, transparent);
  color: var(--warning);
}
.badge-destructive {
  border-color: color-mix(in oklch, var(--destructive) 25%, transparent);
  background: color-mix(in oklch, var(--destructive) 15%, transparent);
  color: var(--destructive);
}
.badge-primary {
  border-color: color-mix(in oklch, var(--primary) 25%, transparent);
  background: color-mix(in oklch, var(--primary) 15%, transparent);
  color: var(--primary);
}
.badge-method {
  min-width: 3.6rem;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.72rem;
}

/* ---------------------------------------------------------------- Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
}
.card-desc {
  font-size: 0.85rem;
  color: var(--muted-foreground);
}
.card-body {
  padding: 0 1.5rem 1.5rem;
}
.card-body.flush {
  padding: 0;
}
.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ---------------------------------------------------------------- Forms */
.input,
.select,
.textarea {
  width: 100%;
  height: 2.25rem;
  padding: 0 0.7rem;
  border-radius: calc(var(--radius) * 0.8);
  border: 1px solid var(--input);
  background: var(--background);
  color: var(--foreground);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea {
  height: auto;
  min-height: 5rem;
  padding: 0.5rem 0.7rem;
  resize: vertical;
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 25%, transparent);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2399a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.field-label {
  font-size: 0.82rem;
  font-weight: 500;
}
.field-desc {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group .input {
  padding-left: 2.1rem;
}
.input-group .addon {
  position: absolute;
  left: 0.65rem;
  display: flex;
  color: var(--muted-foreground);
  pointer-events: none;
}
.input-group .addon-end {
  left: auto;
  right: 0.4rem;
  pointer-events: auto;
}
.input-group.has-end .input {
  padding-right: 2.4rem;
}

/* ---------------------------------------------------------------- Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 16rem;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}
.sidebar-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  padding: 0 0.6rem 0.5rem;
}
.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.6rem;
  border-radius: calc(var(--radius) * 0.7);
  color: var(--foreground);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s ease;
}
.sidebar-link:hover {
  background: var(--secondary);
}
.sidebar-link.active {
  background: color-mix(in oklch, var(--primary) 15%, transparent);
  color: var(--primary);
}
.sidebar-link .icon {
  color: var(--muted-foreground);
}
.sidebar-link.active .icon {
  color: var(--primary);
}
.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--sidebar-border);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem;
  border-radius: calc(var(--radius) * 0.7);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 4rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklch, var(--background) 80%, transparent);
  backdrop-filter: blur(8px);
}
.topbar h1 {
  font-size: 0.9rem;
  font-weight: 600;
}
.topbar .sep {
  width: 1px;
  height: 1.5rem;
  background: var(--border);
}
.content {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ---------------------------------------------------------------- Avatar */
.avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--muted);
  color: var(--muted-foreground);
  flex-shrink: 0;
}
.avatar-primary {
  background: color-mix(in oklch, var(--primary) 15%, transparent);
  color: var(--primary);
}
.avatar-sm {
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.65rem;
}
.avatar-lg {
  width: 4rem;
  height: 4rem;
  font-size: 1.1rem;
}

/* ---------------------------------------------------------------- Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.logo-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: calc(var(--radius) * 0.8);
  background: var(--primary);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.logo-text strong {
  font-size: 0.875rem;
  font-weight: 600;
}
.logo-text span {
  font-size: 0.7rem;
  color: var(--muted-foreground);
}

/* ---------------------------------------------------------------- Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.stat-card .card-header {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.5rem;
}
.stat-card .card-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted-foreground);
}
.stat-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: calc(var(--radius) * 0.7);
  border: 1px solid var(--border);
  background: var(--muted);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.stat-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  margin-top: 0.25rem;
}
.trend {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  font-weight: 500;
}

/* ---------------------------------------------------------------- Tables */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.tbl thead th {
  text-align: left;
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--muted-foreground);
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr:last-child td {
  border-bottom: none;
}
.tbl tbody tr:hover {
  background: color-mix(in oklch, var(--muted) 40%, transparent);
}
.cell-stack {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.cell-stack .sub {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
.cell-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.text-right {
  text-align: right;
}
.tabular {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

/* ---------------------------------------------------------------- Page head */
.page-head {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.page-head h2 {
  font-size: 1.25rem;
  font-weight: 600;
}
.page-head p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}
.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.card-header.row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

/* ---------------------------------------------------------------- Grids */
.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}
.empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted-foreground);
}
.empty strong {
  display: block;
  color: var(--foreground);
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

/* ---------------------------------------------------------------- Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 2.4rem;
  height: 1.35rem;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 0.95rem;
  height: 0.95rem;
  left: 0.18rem;
  top: 0.13rem;
  background: var(--foreground);
  border-radius: 9999px;
  transition: transform 0.15s ease;
}
.switch input:checked + .slider {
  background: var(--primary);
  border-color: var(--primary);
}
.switch input:checked + .slider::before {
  transform: translateX(1.02rem);
  background: var(--primary-foreground);
}

/* ---------------------------------------------------------------- Toggle row */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}
.toggle-row + .toggle-row {
  border-top: 1px solid var(--border);
}
.toggle-row .label {
  font-weight: 500;
}
.toggle-row .desc {
  font-size: 0.82rem;
  color: var(--muted-foreground);
}

/* ---------------------------------------------------------------- Tabs */
.tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--muted);
  border-radius: calc(var(--radius) * 0.8);
}
.tab {
  padding: 0.4rem 0.9rem;
  border-radius: calc(var(--radius) * 0.6);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted-foreground);
  cursor: pointer;
  background: transparent;
  border: none;
  font-family: inherit;
}
.tab.active {
  background: var(--card);
  color: var(--foreground);
}
.tab-panel {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.tab-panel.active {
  display: flex;
}

/* ---------------------------------------------------------------- Dialog */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.dialog-backdrop.open {
  display: flex;
}
.dialog {
  width: 100%;
  max-width: 28rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}
.dialog-header {
  padding: 1.25rem 1.5rem 0.5rem;
}
.dialog-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
}
.dialog-header p {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}
.dialog-body {
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.dialog-footer {
  padding: 0.75rem 1.5rem 1.25rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ---------------------------------------------------------------- Code box */
.code-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.7);
  background: color-mix(in oklch, var(--muted) 40%, transparent);
}
.code-box code {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}
.alert {
  border: 1px solid color-mix(in oklch, var(--warning) 30%, transparent);
  background: color-mix(in oklch, var(--warning) 12%, transparent);
  border-radius: calc(var(--radius) * 0.7);
  padding: 0.75rem 0.9rem;
}
.alert strong {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}
.alert p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted-foreground);
}

/* ---------------------------------------------------------------- Service health */
.service-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.7);
  background: color-mix(in oklch, var(--muted) 40%, transparent);
}
.service-row + .service-row {
  margin-top: 0.6rem;
}
.dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 9999px;
  display: inline-block;
}
.dot-operational {
  background: var(--success);
}
.dot-degraded {
  background: var(--warning);
}
.dot-down {
  background: var(--destructive);
}

/* ---------------------------------------------------------------- Flash / toast */
.toasts {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 22rem;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  border-radius: calc(var(--radius) * 0.7);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-size: 0.85rem;
  animation: toast-in 0.2s ease;
}
.toast.success {
  border-color: color-mix(in oklch, var(--success) 35%, transparent);
}
.toast.error {
  border-color: color-mix(in oklch, var(--destructive) 40%, transparent);
}
.toast .icon {
  margin-top: 0.1rem;
}
.toast.success .icon {
  color: var(--success);
}
.toast.error .icon {
  color: var(--destructive);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

/* ---------------------------------------------------------------- Login */
.login-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}
.login-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2.5rem;
  border-right: 1px solid var(--border);
  background: var(--card);
  overflow: hidden;
}
.login-brand .dots {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: radial-gradient(
    circle at 1px 1px,
    var(--foreground) 1px,
    transparent 0
  );
  background-size: 28px 28px;
  pointer-events: none;
}
.login-brand .content {
  position: relative;
  z-index: 1;
  gap: 2rem;
  padding: 0;
}
.pill {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid color-mix(in oklch, var(--primary) 25%, transparent);
  background: color-mix(in oklch, var(--primary) 10%, transparent);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 500;
}
.login-brand h2 {
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1.2;
}
.highlight {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.highlight .mark {
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border-radius: calc(var(--radius) * 0.7);
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.highlight .t {
  font-weight: 500;
}
.highlight .d {
  font-size: 0.85rem;
  color: var(--muted-foreground);
}
.login-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
}
.login-form {
  width: 100%;
  max-width: 24rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.note {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.7);
  background: var(--card);
  font-size: 0.75rem;
  color: var(--muted-foreground);
  line-height: 1.5;
}

/* ---------------------------------------------------------------- Misc */
.row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.ml-auto {
  margin-left: auto;
}
.grid-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.bordered-box {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.7);
  padding: 0.85rem;
}
.dropdown {
  position: relative;
}
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  min-width: 11rem;
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.7);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  padding: 0.3rem;
  display: none;
  z-index: 30;
}
.dropdown.open .dropdown-menu {
  display: block;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: calc(var(--radius) * 0.5);
  font-size: 0.85rem;
  background: transparent;
  border: none;
  color: var(--foreground);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.dropdown-item:hover {
  background: var(--secondary);
}
.dropdown-item.danger {
  color: var(--destructive);
}
.dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: 0.3rem 0;
}

/* ---------------------------------------------------------------- Docs públicas */
.docs-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 4rem;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklch, var(--background) 85%, transparent);
  backdrop-filter: blur(8px);
}
.docs-layout {
  display: flex;
  gap: 2rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem;
}
.docs-nav {
  width: 16rem;
  flex-shrink: 0;
  position: sticky;
  top: 5.5rem;
  align-self: flex-start;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.docs-nav-group {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  padding: 0.75rem 0.6rem 0.3rem;
}
.docs-nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: calc(var(--radius) * 0.6);
  color: var(--muted-foreground);
  font-size: 0.85rem;
}
.docs-nav-link:hover {
  background: var(--secondary);
  color: var(--foreground);
}
.docs-main {
  flex: 1;
  min-width: 0;
  max-width: 48rem;
}
.docs-section {
  margin-bottom: 2.5rem;
}
.docs-section h1 {
  font-size: 1.6rem;
  font-weight: 600;
}
.docs-group-title {
  font-size: 1.2rem;
  font-weight: 600;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.ep-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  scroll-margin-top: 5.5rem;
}
.ep-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.ep-path {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
}
.ep-name {
  font-weight: 600;
  margin-top: 0.75rem;
}
.ep-block {
  margin-top: 1rem;
}
.ep-note {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid color-mix(in oklch, var(--primary) 25%, transparent);
  background: color-mix(in oklch, var(--primary) 8%, transparent);
  border-radius: calc(var(--radius) * 0.7);
  font-size: 0.85rem;
}
.code-pre {
  margin: 0.5rem 0 0;
  padding: 0.85rem 1rem;
  background: color-mix(in oklch, var(--muted) 45%, transparent);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.7);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre;
}
.tryit {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.tryit-summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--primary);
  list-style: none;
}
.tryit-summary::-webkit-details-marker {
  display: none;
}
.tryit-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
}
.tryit-status {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
}
.docs-footer {
  padding: 2rem 0;
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}
@media (max-width: 900px) {
  .docs-nav {
    display: none;
  }
  .docs-layout {
    padding: 1rem;
  }
}

/* ---------------------------------------------------------------- Animaciones */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Entrada de cada bloque de la página (sensación de transición entre páginas) */
.content > * {
  animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.content > *:nth-child(1) { animation-delay: 0.02s; }
.content > *:nth-child(2) { animation-delay: 0.10s; }
.content > *:nth-child(3) { animation-delay: 0.18s; }
.content > *:nth-child(4) { animation-delay: 0.26s; }
.content > *:nth-child(5) { animation-delay: 0.34s; }

.login-form {
  animation: fadeInUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Stagger de las stat cards */
.stat-grid .stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-grid .stat-card:nth-child(2) { animation-delay: 0.12s; }
.stat-grid .stat-card:nth-child(3) { animation-delay: 0.19s; }
.stat-grid .stat-card:nth-child(4) { animation-delay: 0.26s; }

/* Hover / profesionalización */
.card {
  transition: border-color 0.2s ease, box-shadow 0.25s ease, transform 0.25s ease;
}
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  border-color: color-mix(in oklch, var(--primary) 30%, var(--border));
}
.stat-card .stat-icon {
  transition: transform 0.25s ease, background 0.2s ease;
}
.stat-card:hover .stat-icon {
  transform: scale(1.08);
  background: color-mix(in oklch, var(--primary) 18%, var(--muted));
}
.btn,
.badge,
.dropdown-item,
.sidebar-link {
  transition: background 0.15s ease, color 0.15s ease, filter 0.15s ease,
    transform 0.12s ease, border-color 0.15s ease;
}
.btn:active {
  transform: translateY(1px) scale(0.99);
}
.tbl tbody tr {
  transition: background 0.15s ease;
}
.avatar {
  transition: transform 0.2s ease;
}
.stat-value {
  font-variant-numeric: tabular-nums;
}
.ep-card {
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
}
.ep-card:hover {
  border-color: color-mix(in oklch, var(--primary) 25%, var(--border));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* ---------------------------------------------------------------- Mobile: drawer */
.hamburger {
  display: none;
}
.sidebar-overlay {
  display: none;
}

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 880px) {
  .login-shell {
    grid-template-columns: 1fr;
  }
  .login-brand {
    display: none;
  }
  .grid-form {
    grid-template-columns: 1fr;
  }
  .stat-grid {
    grid-template-columns: 1fr;
  }

  /* Sidebar como drawer deslizable */
  .hamburger {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 70;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 65;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
  }
  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
  }
  body.sidebar-open {
    overflow: hidden;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 1rem;
    gap: 1rem;
  }
  .topbar {
    padding: 0 1rem;
    gap: 0.5rem;
  }
  .page-head h2 {
    font-size: 1.15rem;
  }
  .card-header,
  .card-body,
  .card-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .card-header.row {
    align-items: stretch;
  }
  /* Toolbars: controles full width y apilados */
  .toolbar {
    width: 100%;
  }
  .toolbar > * {
    flex: 1 1 100%;
    width: 100% !important;
  }
  .toolbar .input-group {
    width: 100% !important;
  }
  /* Aire en la topbar */
  .topbar > .badge {
    display: none;
  }
  .topbar .dropdown [data-dropdown-toggle] span {
    display: none;
  }
  .stat-value {
    font-size: 1.4rem;
  }
  .docs-layout {
    padding: 1rem;
  }
  .dialog {
    max-width: 100%;
  }
  .docs-top {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
  .ep-card {
    padding: 1rem;
  }
  .ep-head {
    gap: 0.4rem;
  }
}

/* Respeta usuarios que prefieren menos movimiento */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
