/* ==========================================================================
   Componentes
   ========================================================================== */

/* ---------- Marca ---------- */

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--c-text);
  text-decoration: none;
}
.logo-mark {
  flex: none;
  height: 30px;
  width: auto;
  display: block;
}
.logo-mark-on-dark {
  display: none;
}
:root[data-theme="dark"] .logo-mark-on-light {
  display: none;
}
:root[data-theme="dark"] .logo-mark-on-dark {
  display: block;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-mark-on-light {
    display: none;
  }
  :root:not([data-theme="light"]) .logo-mark-on-dark {
    display: block;
  }
}
.logo-text {
  font-size: 1.28rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.logo-dark {
  color: #fff;
}

/* ---------- Botones ---------- */

.btn {
  --btn-h: var(--tap);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--btn-h);
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 0.95rem;
  font-weight: 560;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}
.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.btn .icon {
  margin-left: -2px;
}
.btn > .icon:last-child:not(:first-child) {
  margin-left: 0;
  margin-right: -4px;
  transition: transform var(--dur-2) var(--ease-spring);
}
.btn:hover:not(:disabled) > .icon:last-child:not(:first-child) {
  transform: translateX(3px);
}

.btn-primary {
  color: #fff;
  background: var(--g-brand);
  background-size: 160% 100%;
  background-position: 0% 50%;
  box-shadow: var(--e-accent), inset 0 1px 0 rgb(255 255 255 / 0.22);
  transition:
    background-position var(--dur-4) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}
.btn-primary:hover:not(:disabled) {
  color: #fff;
  background-position: 100% 50%;
  box-shadow: 0 14px 34px -10px rgb(79 70 229 / 0.7), inset 0 1px 0 rgb(255 255 255 / 0.25);
}

.btn-secondary {
  color: var(--c-text);
  background: var(--c-surface);
  border-color: var(--c-border-strong);
  box-shadow: var(--e-1);
}
.btn-secondary:hover:not(:disabled) {
  color: var(--c-text);
  border-color: var(--c-accent-line);
  background: var(--c-surface-2);
}

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

.btn-danger {
  color: #fff;
  background: var(--c-danger);
  box-shadow: 0 8px 22px -10px rgb(190 18 60 / 0.6);
}
:root[data-theme="dark"] .btn-danger {
  color: #1a0710;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-danger {
    color: #1a0710;
  }
}
.btn-danger:hover:not(:disabled) {
  filter: brightness(1.07);
}

.btn-sm {
  --btn-h: 34px;
  padding: 0 var(--sp-3);
  font-size: 0.875rem;
  border-radius: 9px;
}
@media (pointer: coarse) {
  .btn-sm {
    --btn-h: 44px;
  }
}
.btn-lg {
  --btn-h: 52px;
  font-size: 1.02rem;
  border-radius: var(--r-md);
}
.btn-block {
  width: 100%;
}

.link-button {
  display: inline;
  text-align: left;
  white-space: normal;
  padding: 0;
  border: 0;
  background: none;
  color: var(--c-accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.22em;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  opacity: 0.8;
  animation: hm-rotate 0.7s linear infinite;
}
.spinner-inline {
  width: 15px;
  height: 15px;
}

/* ---------- Distintivos de estado ---------- */

.badge {
  --b-fg: var(--c-neutral);
  --b-bg: var(--c-neutral-soft);
  --b-dot: var(--c-neutral-vivid);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--b-bg);
  color: var(--b-fg);
  font-size: 0.78rem;
  font-weight: 560;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--b-dot);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--b-dot) 18%, transparent);
}
.badge-success {
  --b-fg: var(--c-success);
  --b-bg: var(--c-success-soft);
  --b-dot: var(--c-success-vivid);
}
.badge-warning {
  --b-fg: var(--c-warning);
  --b-bg: var(--c-warning-soft);
  --b-dot: var(--c-warning-vivid);
}
.badge-danger {
  --b-fg: var(--c-danger);
  --b-bg: var(--c-danger-soft);
  --b-dot: var(--c-danger-vivid);
}
.badge-info {
  --b-fg: var(--c-info);
  --b-bg: var(--c-info-soft);
  --b-dot: var(--c-info-vivid);
}
.badge-accent {
  --b-fg: var(--c-violet);
  --b-bg: var(--c-violet-soft);
  --b-dot: var(--c-violet-vivid);
}
.badge-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------- Avisos ---------- */

.alert {
  --a-fg: var(--c-info);
  --a-bg: var(--c-info-soft);
  --a-line: var(--c-info-line);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-3);
  align-items: start;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--a-line);
  border-radius: var(--r-md);
  background: var(--a-bg);
  color: var(--c-text);
  font-size: 0.95rem;
  animation: hm-rise var(--dur-3) var(--ease-out);
}
.alert-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-top: -2px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--a-fg) 14%, transparent);
  color: var(--a-fg);
}
.alert-content {
  min-width: 0;
  padding-top: 1px;
}
.alert-title {
  display: block;
  margin-bottom: 2px;
  color: var(--a-fg);
  font-weight: 600;
}
.alert .btn {
  vertical-align: middle;
}
.alert-success {
  --a-fg: var(--c-success);
  --a-bg: var(--c-success-soft);
  --a-line: var(--c-success-line);
}
.alert-warning {
  --a-fg: var(--c-warning);
  --a-bg: var(--c-warning-soft);
  --a-line: var(--c-warning-line);
}
.alert-danger {
  --a-fg: var(--c-danger);
  --a-bg: var(--c-danger-soft);
  --a-line: var(--c-danger-line);
}
.alert-neutral {
  --a-fg: var(--c-neutral);
  --a-bg: var(--c-neutral-soft);
  --a-line: var(--c-neutral-line);
}
.alert-accent {
  --a-fg: var(--c-violet);
  --a-bg: var(--c-violet-soft);
  --a-line: var(--c-violet-line);
}

/* ---------- Formularios ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
}
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.form-actions-left {
  justify-content: flex-start;
}
.inline-form {
  flex-direction: row;
  align-items: flex-end;
  flex-wrap: wrap;
}
.inline-form .field {
  flex: 1 1 240px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field-label {
  font-size: 0.875rem;
  font-weight: 560;
  color: var(--c-text-2);
}
.field-hint {
  font-size: 0.85rem;
  color: var(--c-muted);
  line-height: 1.45;
}
.field-error-text {
  font-size: 0.85rem;
  color: var(--c-danger);
  font-weight: 500;
}

input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"])),
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 1rem;
  line-height: 1.35;
  box-shadow: inset 0 1px 1px rgb(11 16 40 / 0.03);
  transition:
    border-color var(--dur-1) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out),
    background-color var(--dur-1) var(--ease-out);
}
input::placeholder,
textarea::placeholder {
  color: var(--c-faint);
}
input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"])):hover,
select:hover,
textarea:hover {
  border-color: color-mix(in srgb, var(--c-accent) 35%, var(--c-border-strong));
}
input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"])):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 4px var(--c-accent-soft);
}
input:disabled,
select:disabled,
textarea:disabled,
textarea[readonly] {
  background: var(--c-surface-2);
  color: var(--c-muted);
  cursor: not-allowed;
}
textarea {
  resize: vertical;
  min-height: 88px;
}
select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d93ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  cursor: pointer;
}
input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}
input[type="file"] {
  padding: 10px;
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  font-size: 0.95rem;
}
input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border: 1px solid var(--c-border-strong);
  border-radius: 8px;
  background: var(--c-surface);
  color: var(--c-text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

.plain-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.checkbox,
.radio {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-height: 28px;
  font-size: 0.95rem;
  line-height: 1.45;
  cursor: pointer;
}
.checkbox input,
.radio input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--c-accent);
  cursor: pointer;
}

/* Interruptor: sigue siendo un checkbox nativo (rol, teclado), con otro aspecto. */
.checkbox.switch input {
  appearance: none;
  position: relative;
  width: 42px;
  height: 24px;
  margin-top: 0;
  border-radius: var(--r-pill);
  background: var(--c-surface-3);
  border: 1px solid var(--c-border-strong);
  transition:
    background-color var(--dur-2) var(--ease-out),
    border-color var(--dur-2) var(--ease-out);
}
.checkbox.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(11 16 40 / 0.3);
  transition: transform var(--dur-3) var(--ease-spring);
}
.checkbox.switch input:checked {
  background: var(--g-brand);
  border-color: transparent;
}
.checkbox.switch input:checked::after {
  transform: translateX(18px);
}
.checkbox.switch input:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
}
.checkbox.switch {
  align-items: center;
  padding: var(--sp-2) 0;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--sp-2) var(--sp-4);
}

/* ---------- Tarjetas y cabeceras ---------- */

.card {
  position: relative;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  box-shadow: var(--e-1);
  animation: hm-rise var(--dur-4) var(--ease-out) both;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-6) 0;
}
.card-header h2 {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.92rem;
}
.card-actions a {
  font-weight: 560;
  text-decoration: none;
}
.card-body {
  padding: var(--sp-5) var(--sp-6) var(--sp-6);
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-4) var(--sp-6);
  animation: hm-rise var(--dur-4) var(--ease-out) both;
}
.page-heading {
  min-width: 0;
  flex: 1 1 360px;
}
.page-header h1 {
  font-size: var(--fs-display);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: var(--track-display);
  overflow-wrap: anywhere;
}
.page-eyebrow {
  margin-bottom: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  background: var(--g-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  width: fit-content;
}
.page-back {
  margin-bottom: var(--sp-3);
}
.page-back a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px 0 10px;
  border-radius: var(--r-pill);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text-2);
  font-size: 0.875rem;
  font-weight: 550;
  text-decoration: none;
  transition: border-color var(--dur-1), color var(--dur-1), transform var(--dur-2) var(--ease-out);
}
.page-back a:hover {
  color: var(--c-text);
  border-color: var(--c-accent-line);
  transform: translateX(-2px);
}
.page-subtitle {
  margin: var(--sp-3) 0 0;
  max-width: 62ch;
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--c-muted);
}
.subtitle-row {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  font-size: 0.95rem;
}
.mono-id {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
.page-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
}
.section-head h2 {
  font-size: var(--fs-xl);
  letter-spacing: -0.02em;
}
.section-head select {
  width: auto;
}
.subhead {
  margin: var(--sp-6) 0 var(--sp-3);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--c-muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-6);
}
.grid-2 > .card + .card {
  animation-delay: 60ms;
}
@container content (min-width: 880px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
  .grid-detail {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  }
}

/* ---------- Lista de descripción ---------- */

.desc-list {
  margin: 0;
  display: grid;
}
.desc-list > div {
  display: grid;
  grid-template-columns: minmax(120px, 34%) 1fr;
  gap: var(--sp-4);
  padding: 11px 0;
  border-bottom: 1px solid var(--c-border);
}
.desc-list > div:first-child {
  padding-top: 0;
}
.desc-list > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.desc-list dt {
  color: var(--c-muted);
  font-size: 0.9rem;
}
.desc-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---------- Tablas (y tarjetas en móvil) ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  box-shadow: var(--e-1);
}
.card .table-wrap {
  border-radius: var(--r-md);
  box-shadow: none;
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95rem;
}
.table th {
  position: sticky;
  top: 0;
  padding: 12px 14px;
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
  color: var(--c-muted);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}
.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
  min-width: 0;
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table tbody tr {
  animation: hm-rise var(--dur-3) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * var(--stagger));
  transition: background-color var(--dur-1) var(--ease-out);
}
.table tbody tr:hover {
  background: color-mix(in srgb, var(--c-accent-soft) 55%, transparent);
}
.table tbody tr.clickable {
  cursor: pointer;
}
.table td.num,
.table th.num {
  text-align: right;
}
.table td.actions {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}
.table td a {
  font-weight: 550;
  text-decoration: none;
}
.table td a:hover {
  text-decoration: underline;
}
.table .truncate {
  max-width: 260px;
}
@container content (min-width: 720px) and (max-width: 1199.98px) {
  .table .col-xl {
    display: none;
  }
}
@container content (max-width: 1100px) {
  .table .truncate {
    max-width: 200px;
  }
  .table th {
    white-space: normal;
  }
}
.row-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 2px;
}
.ok-mark,
.ko-mark {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
}
.ok-mark {
  background: var(--c-success-soft);
  color: var(--c-success);
}
.ko-mark {
  background: var(--c-danger-soft);
  color: var(--c-danger);
}

@media (max-width: 719.98px) {
  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .table,
  .table tbody {
    display: block;
  }
  .table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .table tbody {
    display: grid;
    gap: var(--sp-3);
  }
  .table tbody tr {
    display: grid;
    grid-template-columns: 1fr;
    padding: var(--sp-4);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    background: var(--c-surface);
    box-shadow: var(--e-1);
  }
  .table tbody tr.clickable:active {
    transform: scale(0.99);
  }
  .table td {
    display: flow-root;
    padding: 7px 0;
    border: 0;
    text-align: right;
    min-height: 32px;
    overflow-wrap: anywhere;
  }
  .table td[data-label]::before {
    content: attr(data-label);
    float: left;
    margin: 3px var(--sp-3) 0 0;
    max-width: 45%;
    color: var(--c-muted);
    font-size: var(--fs-2xs);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: left;
  }
  .table td.cell-title {
    order: -1;
    display: block;
    padding: 0 0 var(--sp-2);
    margin-bottom: var(--sp-1);
    border-bottom: 1px solid var(--c-border);
    text-align: left;
    font-size: 1.02rem;
    font-weight: 560;
  }
  .table td.cell-title::before {
    content: none;
  }
  .table td.cell-hide-mobile {
    display: none;
  }
  .table td.num {
    text-align: right;
  }
  .table td.actions {
    display: flex;
    width: auto;
    justify-content: flex-end;
    padding-top: var(--sp-3);
    margin-top: var(--sp-1);
    border-top: 1px solid var(--c-border);
  }
  .table td.actions:empty {
    display: none;
  }
  .table .truncate {
    max-width: 100%;
    white-space: normal;
  }
  .row-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
  font-size: 0.9rem;
}

/* ---------- Filtros ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  animation: hm-rise var(--dur-4) var(--ease-out) 40ms both;
}
.filters > input,
.filters > select {
  width: auto;
  flex: 0 1 200px;
  border-radius: var(--r-pill);
  padding-left: 16px;
}
.search-field {
  position: relative;
  flex: 1 1 280px;
  min-width: 0;
}
.search-field .icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-faint);
  pointer-events: none;
}
.search-field input {
  padding-left: 44px;
  border-radius: var(--r-pill);
}
.filters > .filter-search:not(.search-field) {
  flex: 1 1 280px;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 36px;
  padding: 0 6px 0 14px;
  border-radius: var(--r-pill);
  background: var(--c-accent-soft);
  color: var(--c-accent);
  font-size: 0.9rem;
  font-weight: 550;
}
.filter-chip button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1.1rem;
}
.filter-chip button:hover {
  background: color-mix(in srgb, var(--c-accent) 16%, transparent);
}
@media (max-width: 719.98px) {
  .filters > input,
  .filters > select {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }
}

/* ---------- Pestañas y selector segmentado ---------- */

.tabs {
  display: flex;
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  position: relative;
  flex: none;
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border: 0;
  background: transparent;
  color: var(--c-muted);
  font-size: 0.95rem;
  font-weight: 550;
  transition: color var(--dur-1) var(--ease-out);
}
.tab::after {
  content: "";
  position: absolute;
  left: var(--sp-2);
  right: var(--sp-2);
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--g-brand);
  transform: scaleX(0);
  transition: transform var(--dur-3) var(--ease-out);
}
.tab:hover:not(:disabled) {
  color: var(--c-text);
}
.tab-active {
  color: var(--c-text);
}
.tab-active::after {
  transform: scaleX(1);
}
.tab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  background: var(--c-surface-2);
}
.segmented button {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--c-muted);
  font-size: 0.9rem;
  font-weight: 560;
  white-space: nowrap;
  transition:
    background-color var(--dur-2) var(--ease-out),
    color var(--dur-2) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out);
}
@media (pointer: coarse) {
  .segmented button {
    min-height: 40px;
  }
}
.segmented button:hover {
  color: var(--c-text);
}
.segmented button.active {
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--e-2);
}

/* ---------- Estado vacío y esqueletos ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--sp-10) var(--sp-6);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--r-lg);
  background:
    radial-gradient(420px 200px at 50% 0%, var(--c-accent-soft), transparent 70%),
    var(--c-surface);
  animation: hm-rise var(--dur-4) var(--ease-out) both;
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: var(--sp-5);
  border-radius: 20px;
  background: var(--g-brand);
  color: #fff;
  box-shadow: var(--e-accent);
  transform: rotate(-6deg);
}
.empty h3 {
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
}
.empty p {
  max-width: 46ch;
  margin: var(--sp-2) 0 0;
  color: var(--c-muted);
}
.empty-action {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2);
  margin-top: var(--sp-6);
}

.loading {
  display: block;
}
.skeleton {
  display: block;
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--c-surface-2) 20%, var(--c-surface-3) 40%, var(--c-surface-2) 60%);
  background-size: 200% 100%;
  animation: hm-shimmer 1.4s linear infinite;
}
.skeleton-rows {
  display: grid;
  gap: 18px;
  padding: var(--sp-6);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-surface);
}
.skeleton-rows .skeleton {
  height: 16px;
}
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-4);
}
.skeleton-card {
  display: grid;
  gap: 14px;
  padding: var(--sp-5);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-surface);
}
.skeleton-card .skeleton:nth-child(2) {
  height: 34px;
}
.skeleton-detail > div {
  display: grid;
  gap: 14px;
}
.skeleton-detail > div > .skeleton:first-child {
  height: 44px;
}
.skeleton-detail .skeleton-card {
  margin-top: var(--sp-5);
}

/* ---------- Código y secretos ---------- */

.codeblock {
  position: relative;
  border-radius: var(--r-md);
  background:
    radial-gradient(400px 160px at 100% 0%, rgb(109 93 252 / 0.22), transparent 70%),
    var(--ink-1);
  border: 1px solid rgb(255 255 255 / 0.06);
  overflow: hidden;
}
.codeblock pre {
  margin: 0;
  padding: var(--sp-5) var(--sp-5) var(--sp-5);
  padding-right: 110px;
  overflow-x: auto;
  color: #dfe3ff;
  font-size: 0.82rem;
  line-height: 1.7;
}
.codeblock .copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  color: #dfe3ff;
  background: rgb(255 255 255 / 0.08);
}
.codeblock .copy-btn:hover {
  background: rgb(255 255 255 / 0.14);
  color: #fff;
}

.copy-btn.is-copied {
  color: var(--c-success);
  background: var(--c-success-soft);
}
.copy-btn.is-copied .icon {
  animation: hm-pop var(--dur-3) var(--ease-spring);
}
.codeblock .copy-btn.is-copied {
  color: #6ee7b7;
  background: rgb(52 211 153 / 0.14);
}
.copy-btn-icon {
  width: 34px;
  padding: 0;
}
@media (pointer: coarse) {
  .copy-btn-icon {
    width: 44px;
  }
}

.secret-box {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
  padding: var(--sp-4);
  border: 1px dashed var(--c-accent-line);
  border-radius: var(--r-md);
  background: var(--c-accent-soft);
}
.secret-box code {
  flex: 1;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.92rem;
  font-weight: 500;
  word-break: break-all;
}

.pre-box {
  margin: 0;
  max-height: 480px;
  overflow: auto;
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  font-size: 0.82rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.html-preview {
  display: block;
  width: 100%;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: #fff;
}

.remote-images-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2, 8px) var(--s-3, 12px);
  margin-bottom: var(--s-2, 8px);
}

/* ---------- Diálogos ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background: var(--c-scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: hm-fade var(--dur-2) var(--ease-out);
  overflow-y: auto;
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  background: var(--c-surface);
  box-shadow: var(--e-4);
  animation: hm-pop var(--dur-3) var(--ease-spring);
}
.modal:focus {
  outline: none;
}
.modal-wide {
  max-width: 760px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-6) var(--sp-2);
}
.modal-header h2 {
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
}
.modal-close {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  margin: -8px -10px -8px 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--c-muted);
  transition: background-color var(--dur-1), color var(--dur-1), transform var(--dur-2) var(--ease-spring);
}
.modal-close:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
  transform: rotate(90deg);
}
.modal-body {
  padding: var(--sp-3) var(--sp-6) var(--sp-6);
  overflow-y: auto;
  min-height: 0;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.confirm-message {
  color: var(--c-text-2);
}
.confirm-message p {
  margin-top: var(--sp-3);
}

@media (max-width: 719.98px) {
  .modal-backdrop {
    place-items: end stretch;
    padding: 0;
    padding-top: max(24px, env(safe-area-inset-top));
  }
  .modal,
  .modal-wide {
    max-width: none;
    max-height: calc(100dvh - 24px);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: hm-sheet var(--dur-3) var(--ease-out);
  }
  .modal-header {
    padding: var(--sp-5) var(--sp-5) var(--sp-2);
  }
  .modal-body {
    padding: var(--sp-2) var(--sp-5) var(--sp-5);
  }
  .modal-footer {
    padding: var(--sp-3) var(--sp-5);
    border-radius: 0;
  }
  .modal-footer .btn,
  .modal .form-actions .btn {
    flex: 1 1 0;
  }
}

/* ---------- Paleta de comandos ---------- */

.palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh var(--sp-4) var(--sp-4);
  background: var(--c-scrim);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: hm-fade var(--dur-2) var(--ease-out);
}
.palette {
  position: relative;
  width: min(680px, 100%);
  max-height: min(560px, 76vh);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  background: var(--c-surface);
  box-shadow: var(--e-4), 0 0 0 1px rgb(109 93 252 / 0.08);
  overflow: hidden;
  animation: hm-pop var(--dur-3) var(--ease-spring);
}
.palette::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--g-brand-wide);
  background-size: 300% 100%;
  animation: hm-shift 6s linear infinite;
}
.palette-search {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--c-border);
  color: var(--c-muted);
}
.palette-search input {
  flex: 1;
  min-height: 64px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 1.15rem;
  font-weight: 450;
}
.palette-search input:focus,
.palette-search input:hover {
  box-shadow: none;
  border: 0;
}
.palette-list {
  flex: 1;
  margin: 0;
  padding: var(--sp-2);
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.palette-group {
  padding: var(--sp-3) var(--sp-3) var(--sp-1);
  color: var(--c-muted);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
}
.palette-option {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 46px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--c-text-2);
  cursor: pointer;
  scroll-margin: 8px;
}
.palette-option-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  color: var(--c-muted);
  transition: background-color var(--dur-1), color var(--dur-1), border-color var(--dur-1);
}
.palette-option-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.98rem;
}
.palette-kbd {
  display: inline-flex;
  gap: 4px;
}
.palette-enter {
  color: var(--c-accent);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--dur-1), transform var(--dur-2) var(--ease-out);
}
.palette-option.is-active {
  background: var(--c-accent-soft);
  color: var(--c-text);
}
.palette-option.is-active .palette-option-icon {
  background: var(--g-brand);
  border-color: transparent;
  color: #fff;
}
.palette-option.is-active .palette-enter {
  opacity: 1;
  transform: none;
}
.palette-empty {
  padding: var(--sp-6);
  text-align: center;
  color: var(--c-muted);
}
.palette-foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-2);
  color: var(--c-muted);
  font-size: 0.8rem;
}
.palette-foot kbd {
  margin-right: 3px;
}
@media (max-width: 719.98px) {
  .palette-backdrop {
    padding: max(10px, env(safe-area-inset-top)) 10px 10px;
  }
  .palette {
    max-height: calc(100dvh - 20px);
    border-radius: var(--r-lg);
  }
  .palette-kbd,
  .palette-foot,
  .palette-esc {
    display: none;
  }
  .palette-option {
    min-height: 50px;
  }
}

/* ---------- Notificaciones ---------- */

.toaster {
  position: fixed;
  right: var(--sp-6);
  bottom: var(--sp-6);
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: min(400px, calc(100vw - 32px));
  padding: 10px 8px 10px 12px;
  border-radius: var(--r-md);
  background: var(--ink-2);
  color: var(--ink-text);
  box-shadow: var(--e-4);
  border: 1px solid rgb(255 255 255 / 0.08);
  overflow: hidden;
  pointer-events: auto;
  animation: hm-pop var(--dur-3) var(--ease-spring);
  transition:
    opacity var(--dur-2) var(--ease-out),
    transform var(--dur-2) var(--ease-out);
}
.toast-leaving {
  opacity: 0;
  transform: translateX(16px) scale(0.98);
}
.toast-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #06140e;
  background: #34d399;
}
.toast-danger .toast-icon {
  background: #fb7185;
  color: #1a0710;
}
.toast-info .toast-icon {
  background: #8f8cff;
  color: #0b0a26;
}
.toast-text {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
}
.toast-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
}
.toast-close:hover {
  background: rgb(255 255 255 / 0.08);
  color: #fff;
}
.toast-timer {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: var(--g-brand);
  transform-origin: left;
  animation: hm-timer 4.5s linear forwards;
}
.toast:hover .toast-timer,
.toast:focus-within .toast-timer {
  animation-play-state: paused;
}
@keyframes hm-timer {
  to {
    transform: scaleX(0);
  }
}
@media (max-width: 719.98px) {
  .toaster {
    left: var(--sp-4);
    right: var(--sp-4);
    bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom) + var(--sp-3));
    align-items: stretch;
  }
  .toast {
    width: 100%;
  }
}

/* ---------- KPI ---------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
}
@container content (min-width: 640px) {
  .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .kpis-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@container content (min-width: 1180px) {
  .kpis-overview {
    grid-template-columns: 1.5fr repeat(5, minmax(0, 1fr));
  }
}

.kpi {
  --tone: var(--c-accent);
  position: relative;
  min-width: 0;
  padding: var(--sp-5) var(--sp-5) var(--sp-6);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  box-shadow: var(--e-1);
  overflow: hidden;
  isolation: isolate;
  animation: hm-rise var(--dur-4) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 50ms);
  transition:
    transform var(--dur-2) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out),
    border-color var(--dur-2) var(--ease-out);
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--e-2);
  border-color: color-mix(in srgb, var(--tone) 30%, var(--c-border));
}
.kpi-label {
  color: var(--c-muted);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
}
.kpi-value {
  margin-top: var(--sp-2);
  font-size: var(--fs-kpi);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}
.kpi-sub {
  display: inline-flex;
  border-radius: 10px !important;
  margin-top: var(--sp-3);
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--tone) 12%, transparent);
  color: var(--tone);
  font-size: 0.8rem;
  font-weight: 600;
}
.kpi-sub:empty {
  display: none;
}
.kpi:has(.sparkline) {
  padding-bottom: 64px;
}
.kpi .sparkline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  width: 100%;
  height: 46px;
  opacity: 0.85;
}
.kpi-tone-accent {
  --tone: var(--c-accent);
}
.kpi-tone-success {
  --tone: var(--c-success);
}
.kpi-tone-danger {
  --tone: var(--c-danger);
}
.kpi-tone-warning {
  --tone: var(--c-warning);
}
.kpi-tone-info {
  --tone: var(--c-info);
}
.kpi-tone-violet {
  --tone: var(--c-violet);
}

.kpi-hero {
  --tone: #fff;
  border-color: transparent;
  color: #fff;
  background: var(--g-brand-wide);
  background-size: 300% 300%;
  animation:
    hm-rise var(--dur-4) var(--ease-out) both,
    hm-shift 14s var(--ease-in-out) infinite;
  box-shadow: var(--e-accent);
}

.kpi-hero .kpi-label {
  color: rgb(255 255 255 / 0.8);
}
.kpi-hero .kpi-value {
  font-weight: 500;
}
@container content (min-width: 1180px) {
  .kpi-hero .kpi-value {
    font-size: var(--fs-kpi-hero);
  }
}
.kpi-hero .kpi-sub {
  background: rgb(255 255 255 / 0.18);
  color: #fff;
}
.kpi-hero:hover {
  border-color: transparent;
}
.kpi-hero .spark-line {
  stroke: rgb(255 255 255 / 0.85);
}
.kpi-hero .spark-area {
  fill: rgb(255 255 255 / 0.14);
}
.kpi-warn {
  --tone: var(--c-warning);
  border-color: var(--c-warning-line);
  background: linear-gradient(180deg, var(--c-warning-soft), var(--c-surface) 70%);
}
.kpi-wide {
  grid-column: 1 / -1;
}
.kpi-wide .badge-row {
  margin-top: var(--sp-3);
}

/* Minigráfico */
.spark-line {
  fill: none;
  stroke: var(--tone, var(--c-accent));
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: hm-draw var(--dur-5) var(--ease-out) 200ms both;
}
.spark-area {
  fill: color-mix(in srgb, var(--tone, var(--c-accent)) 10%, transparent);
  animation: hm-fade var(--dur-5) var(--ease-out) 400ms both;
}

/* ---------- Anillo de uso ---------- */

.usage-ring {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  flex-wrap: wrap;
}
.ring {
  --ring: var(--c-accent);
  position: relative;
  flex: none;
  width: 156px;
  height: 156px;
}
.ring.meter-warning {
  --ring: var(--c-warning-vivid);
}
.ring.meter-danger {
  --ring: var(--c-danger-vivid);
}
.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring-track {
  fill: none;
  stroke: var(--c-surface-3);
  stroke-width: 11;
}
.ring-value {
  fill: none;
  stroke: var(--ring);
  stroke-width: 11;
  stroke-linecap: round;
  animation: hm-ring var(--dur-5) var(--ease-out) 150ms both;
  filter: drop-shadow(0 4px 10px color-mix(in srgb, var(--ring) 40%, transparent));
}
@keyframes hm-ring {
  from {
    stroke-dashoffset: var(--ring-c);
  }
}
.ring-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}
.ring-pct {
  font-size: 2.1rem;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
}
.ring-caption {
  margin-top: 4px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--c-muted);
}
.usage-ring-text {
  display: grid;
  gap: 4px;
  min-width: 180px;
  flex: 1;
}
.usage-ring-count {
  font-size: 1rem;
  color: var(--c-muted);
}
.usage-ring-count strong {
  display: block;
  color: var(--c-text);
  font-size: 2rem;
  line-height: 1.1;
  font-weight: 560;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.usage-ring-month::first-letter {
  text-transform: uppercase;
}
.usage-over {
  margin-top: var(--sp-2);
  color: var(--c-danger);
  font-weight: 560;
  font-size: 0.92rem;
}

/* Barra de uso (Facturación) */
.usage-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}
.usage-head strong {
  font-size: 1.5rem;
  font-weight: 560;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.usage-foot {
  margin-top: var(--sp-2);
  font-size: 0.9rem;
}
.meter {
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--c-surface-3);
  overflow: hidden;
}
.meter > div {
  height: 100%;
  border-radius: inherit;
  background: var(--g-brand);
  transform-origin: left;
  animation: hm-meter var(--dur-5) var(--ease-out) 150ms both;
}
.meter-warning > div {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.meter-danger > div {
  background: linear-gradient(90deg, #e11d48, #fb7185);
}
@keyframes hm-meter {
  from {
    transform: scaleX(0);
  }
}

/* ---------- Medidor de reputación ---------- */

.gauge {
  --g: var(--c-success-vivid);
  width: 100%;
  max-width: 220px;
}
.gauge-warning {
  --g: var(--c-warning-vivid);
}
.gauge-danger {
  --g: var(--c-danger-vivid);
}
.gauge svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.gauge-track {
  fill: none;
  stroke: var(--c-surface-3);
  stroke-width: 10;
  stroke-linecap: round;
}
.gauge-fill {
  fill: none;
  stroke: var(--g);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 1;
  animation: hm-draw var(--dur-5) var(--ease-out) 200ms both;
}
.gauge-tick {
  stroke-width: 2.5;
  stroke-linecap: round;
}
.gauge-tick-warn {
  stroke: var(--c-warning-vivid);
}
.gauge-tick-danger {
  stroke: var(--c-danger-vivid);
}
.gauge-marker {
  transform-box: view-box;
  transform-origin: 60px 58px;
  transform: rotate(var(--angle));
  animation: hm-needle var(--dur-5) var(--ease-out) 200ms both;
}
@keyframes hm-needle {
  from {
    transform: rotate(0deg);
  }
}
.gauge-marker circle {
  fill: var(--c-surface);
  stroke: var(--g);
  stroke-width: 3.5;
  filter: drop-shadow(0 2px 4px rgb(11 16 40 / 0.25));
}

/* ---------- Gráfico diario ---------- */

.chart-plot {
  position: relative;
  border-radius: var(--r-sm);
}
.chart-plot:focus-visible {
  outline-offset: 6px;
}
.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart-grid {
  stroke: var(--c-border);
  stroke-dasharray: 2 4;
}
.chart-axis {
  fill: var(--c-muted);
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 500;
}
.chart-hit {
  fill: transparent;
}
.chart-grad-a {
  stop-color: var(--brand-1);
}
.chart-grad-b {
  stop-color: var(--brand-2);
}
.chart-bar-sent {
  fill: var(--c-surface-3);
}
.chart-bar-bounced {
  fill: var(--c-danger-vivid);
}
.chart-day rect:not(.chart-hit) {
  transform-box: fill-box;
  transform-origin: bottom;
  animation: hm-grow var(--dur-4) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 12ms + 80ms);
  transition: opacity var(--dur-1) var(--ease-out);
}
.chart-plot:has(.is-active) .chart-day:not(.is-active) rect:not(.chart-hit) {
  opacity: 0.38;
}
.chart-day.is-active .chart-bar-sent {
  fill: var(--c-border-strong);
}
.chart-tip {
  position: absolute;
  top: 0;
  z-index: 5;
  min-width: 176px;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--ink-2);
  color: var(--ink-text);
  box-shadow: var(--e-3);
  font-size: 0.85rem;
  transform: translateX(12px);
  pointer-events: none;
  animation: hm-fade var(--dur-1) var(--ease-out);
}
.chart-tip-left {
  transform: translateX(calc(-100% - 12px));
}
.chart-tip strong {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}
.chart-tip dl {
  margin: 0;
  display: grid;
  gap: 3px;
}
.chart-tip dl > div {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
}
.chart-tip dt {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
}
.chart-tip dt::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
}
.chart-tip dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 560;
}
.tip-sent dt::before {
  background: #7a82a8;
}
.tip-delivered dt::before {
  background: var(--brand-1);
}
.tip-bounced dt::before {
  background: #fb7185;
}
.tip-complained dt::before {
  background: #fbbf24;
}
.tip-opened dt::before {
  background: #60a5fa;
}
.tip-clicked dt::before {
  background: #a78bfa;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  margin-top: var(--sp-4);
  color: var(--c-muted);
  font-size: 0.875rem;
}
.chart-range {
  order: 9;
  flex-basis: 100%;
  font-size: 0.8rem;
}
.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.swatch-sent {
  background: var(--c-surface-3);
  box-shadow: inset 0 0 0 1px var(--c-border-strong);
}
.swatch-delivered {
  background: var(--g-brand);
}
.swatch-bounced {
  background: var(--c-danger-vivid);
}
.chart-empty {
  padding: var(--sp-9) 0;
  text-align: center;
}

/* ---------- Cronología ---------- */

.timeline {
  position: relative;
  margin: 0;
  padding: 0 0 0 44px;
  list-style: none;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 14px;
  bottom: 14px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--c-accent-line), var(--c-border) 80%);
}
.timeline > li {
  --t: var(--c-info);
  --t-soft: var(--c-info-soft);
  position: relative;
  padding: 0 0 var(--sp-6);
  animation: hm-rise var(--dur-3) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 70ms + 100ms);
}
.timeline > li:last-child {
  padding-bottom: 0;
}
.tl-dot {
  position: absolute;
  left: -44px;
  top: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--c-surface);
  border: 2px solid var(--t);
  color: var(--t);
  box-shadow: 0 0 0 4px var(--t-soft);
}
.tl-success {
  --t: var(--c-success);
  --t-soft: var(--c-success-soft);
}
.tl-warning {
  --t: var(--c-warning);
  --t-soft: var(--c-warning-soft);
}
.tl-danger {
  --t: var(--c-danger);
  --t-soft: var(--c-danger-soft);
}
.tl-accent {
  --t: var(--c-violet);
  --t-soft: var(--c-violet-soft);
}
.tl-neutral {
  --t: var(--c-neutral);
  --t-soft: var(--c-neutral-soft);
}
.tl-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  min-height: 32px;
}
.event-data {
  margin: var(--sp-2) 0 0;
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  font-size: 0.82rem;
  display: grid;
  gap: 4px;
}
.event-data > div {
  display: grid;
  grid-template-columns: minmax(90px, auto) 1fr;
  gap: var(--sp-3);
}
.event-data dt {
  font-family: var(--font-mono);
  color: var(--c-muted);
}
.event-data dd {
  margin: 0;
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}
