/* =====================================================================
   Lanzadera — estilos
   CSS moderno nativo: oklch, light-dark(), nesting, :has(), popover,
   @starting-style y View Transitions. Sin preprocesadores ni build.
   ===================================================================== */

@layer reset, tokens, base, components, views, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { margin: 0; min-height: 100%; }
  button, input, select, textarea { font: inherit; color: inherit; }
  img, svg { display: block; }
  [hidden] { display: none !important; }
}

/* ---------------------------------------------------------------- tokens */
@layer tokens {
  @property --spot { syntax: "<number>"; inherits: false; initial-value: 0; }   /* brillo animable de las tarjetas */

  :root {
    color-scheme: light dark;
    /* Color corporativo INELCOM: rgb(0,193,213). Todo el acento de la interfaz se deriva de él. */
    --brand: rgb(0 193 213);
    --brand-deep: oklch(from var(--brand) calc(l - 0.2) c calc(h + 14));    /* teal profundo */
    --brand-blue: oklch(from var(--brand) calc(l - 0.12) calc(c + 0.03) calc(h + 38)); /* hacia azul */
    --on-brand: oklch(19% 0.04 225);                                       /* texto sobre el cian */
    --hue: 222;   /* tinte de grises y fondos: azul frío que armoniza con el cian */

    --bg:        light-dark(oklch(98.4% 0.004 var(--hue)), oklch(15.5% 0.012 var(--hue)));
    --surface:   light-dark(oklch(100% 0 0),               oklch(19.5% 0.014 var(--hue)));
    --surface-2: light-dark(oklch(96.6% 0.006 var(--hue)), oklch(23.5% 0.016 var(--hue)));
    --surface-3: light-dark(oklch(93.5% 0.008 var(--hue)), oklch(28% 0.018 var(--hue)));
    --border:    light-dark(oklch(91.5% 0.007 var(--hue)), oklch(29% 0.016 var(--hue)));
    --border-strong: light-dark(oklch(85% 0.01 var(--hue)), oklch(37% 0.02 var(--hue)));
    --text:      light-dark(oklch(21% 0.02 var(--hue)),    oklch(96% 0.006 var(--hue)));
    --text-2:    light-dark(oklch(48% 0.02 var(--hue)),    oklch(72% 0.016 var(--hue)));
    --text-3:    light-dark(oklch(62% 0.016 var(--hue)),   oklch(58% 0.016 var(--hue)));

    /* En claro el acento es un cian más oscuro para que el texto sea legible (AA); en oscuro, el corporativo puro */
    --accent:    light-dark(oklch(from var(--brand) 0.52 calc(c * 0.85) h), var(--brand));
    --accent-2:  var(--brand-blue);
    --accent-fg: var(--on-brand);
    --accent-soft: color-mix(in oklch, var(--accent) 13%, transparent);
    --ring: color-mix(in oklch, var(--accent) 50%, transparent);
    --danger:    light-dark(oklch(56% 0.2 25),             oklch(72% 0.16 25));
    --danger-soft: color-mix(in oklch, var(--danger) 12%, transparent);
    --star: oklch(80% 0.16 85);

    --shadow-c: light-dark(oklch(30% 0.03 var(--hue) / 0.10), oklch(0% 0 0 / 0.45));
    --shadow-sm: 0 1px 2px var(--shadow-c);
    --shadow-md: 0 1px 2px var(--shadow-c), 0 8px 24px -8px var(--shadow-c);
    --shadow-lg: 0 2px 6px var(--shadow-c), 0 24px 64px -16px var(--shadow-c);

    --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;
    --font: "Inter var", "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-display: "Inter var", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
    --ease: cubic-bezier(.2, .8, .2, 1);
    --sidebar-w: 248px;
  }
  :root[data-theme="light"] { color-scheme: light; }
  :root[data-theme="dark"]  { color-scheme: dark; }
}

/* ---------------------------------------------------------------- base */
@layer base {
  body {
    background: var(--bg);
    color: var(--text);
    font: 14.5px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "cv11", "ss01";
  }
  h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.015em; margin: 0; }
  a { color: var(--accent); }
  ::selection { background: var(--accent-soft); }
  :focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

  .i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .i.sm { width: 15px; height: 15px; }
  .i.lg { width: 22px; height: 22px; }

  kbd {
    font: 500 11px/1 var(--font); padding: 3px 6px; border-radius: 6px;
    background: var(--surface); border: 1px solid var(--border); border-bottom-width: 2px; color: var(--text-2);
  }
}

/* ---------------------------------------------------------------- componentes */
@layer components {
  /* Botones */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px; padding: 0 14px; border-radius: var(--r-sm);
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font-weight: 500; font-size: 13.5px; text-decoration: none; white-space: nowrap; cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
    &:hover { background: var(--surface-2); border-color: var(--border-strong); }
    &:active { transform: translateY(1px); }
    &:disabled { opacity: .6; cursor: progress; }
    &.primary {
      position: relative; overflow: hidden; isolation: isolate;
      background: linear-gradient(135deg, oklch(from var(--brand) calc(l + 0.06) c calc(h - 8)), var(--brand) 55%, oklch(from var(--brand) calc(l - 0.06) c calc(h + 12)));
      border-color: transparent; color: var(--on-brand); font-weight: 600;
      box-shadow: 0 1px 2px var(--shadow-c), 0 6px 18px -8px color-mix(in oklch, var(--brand) 70%, transparent), inset 0 1px 0 oklch(100% 0 0 / .3);
      &:hover { filter: brightness(1.05); box-shadow: 0 1px 2px var(--shadow-c), 0 10px 26px -8px color-mix(in oklch, var(--brand) 85%, transparent), inset 0 1px 0 oklch(100% 0 0 / .3); }
      /* destello que cruza el botón al pasar el ratón */
      &::after {
        content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
        background: linear-gradient(110deg, transparent 30%, oklch(100% 0 0 / .45) 50%, transparent 70%);
        translate: -120% 0; transition: translate .7s var(--ease);
      }
      &:hover::after { translate: 120% 0; }
    }
    &.ghost { background: transparent; border-color: transparent; box-shadow: none; &:hover { background: var(--surface-2); } }
    &.danger { color: var(--danger); &:hover { background: var(--danger-soft); border-color: transparent; } }
    &.sm { height: 30px; padding: 0 10px; font-size: 13px; }
  }
  .icon-btn {
    display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm);
    border: 0; background: transparent; color: var(--text-2); cursor: pointer; text-decoration: none;
    transition: background .15s, color .15s;
    &:hover { background: var(--surface-3); color: var(--text); }
    &.danger:hover { background: var(--danger-soft); color: var(--danger); }
  }

  /* Campos */
  .field { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
  .input, .field input:not([type=checkbox], [type=radio], [type=file], .bare), .field select {
    width: 100%; height: 38px; padding: 0 12px; border-radius: var(--r-sm);
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    font-weight: 400; font-size: 14px; transition: border-color .15s, box-shadow .15s;
    &::placeholder { color: var(--text-3); }
    &:hover { border-color: var(--border-strong); }
    &:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  }
  .with-icon {
    position: relative;
    & > .i { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--text-3); pointer-events: none; }
    & > input { padding-left: 38px !important; }
  }
  .check {
    display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; color: var(--text); cursor: pointer;
    & input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
    &:has(input:disabled) { opacity: .5; cursor: default; }
  }

  /* Control segmentado (radios o botones) */
  .segmented {
    display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px;
    background: var(--surface-2); border: 1px solid var(--border);
    & > label, & > button {
      display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: 1;
      height: 30px; padding: 0 12px; border-radius: 7px; border: 0; background: transparent;
      color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
      transition: background .15s, color .15s, box-shadow .15s;
      &:hover { color: var(--text); }
    }
    & > label:has(input:checked), & > button[aria-pressed="true"] {
      background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
    }
    & input { position: absolute; opacity: 0; pointer-events: none; }
    &.icons > button { padding: 0; width: 32px; flex: none; }
  }

  /* Chips de etiquetas */
  .chip {
    display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
    border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
    color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
    transition: all .15s var(--ease);
    & .n { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
    &:hover { border-color: var(--border-strong); color: var(--text); }
    &[aria-pressed="true"] {
      background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600;
      box-shadow: 0 4px 14px -6px color-mix(in oklch, var(--brand) 80%, transparent);
      & .n { color: color-mix(in oklch, var(--on-brand) 70%, transparent); }
    }
    &.ghost { border-style: dashed; background: transparent; }
  }
  .pill {
    display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 999px;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
    font-size: 11.5px; font-weight: 500; white-space: nowrap;
  }
  .badge {
    margin-left: auto; min-width: 22px; padding: 0 7px; height: 20px; border-radius: 999px;
    display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 600;
    background: var(--surface-3); color: var(--text-2); font-variant-numeric: tabular-nums;
  }

  /* Icono de app (tile con degradado o emoji) */
  .tile {
    --h: 260; --s: 44px;
    flex: none; width: var(--s); height: var(--s); border-radius: calc(var(--s) * .28);
    display: grid; place-items: center;
    background: linear-gradient(140deg, oklch(72% 0.15 var(--h)), oklch(55% 0.19 calc(var(--h) + 40)));
    color: white; font-weight: 650; font-size: calc(var(--s) * .36); letter-spacing: -.02em;
    box-shadow: inset 0 1px 0 oklch(100% 0 0 / .25), 0 2px 6px -2px oklch(50% .15 var(--h) / .5);
    &.emoji {
      background: light-dark(oklch(95.5% 0.035 var(--h)), oklch(30% 0.05 var(--h)));
      font-size: calc(var(--s) * .52); box-shadow: inset 0 0 0 1px light-dark(oklch(90% .04 var(--h)), oklch(36% .05 var(--h)));
    }
    &.sm { --s: 34px; }
    &.xs { --s: 28px; }
  }

  /* Diálogos (animados con @starting-style) */
  dialog {
    width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 48px);
    padding: 0; border: 1px solid var(--border); border-radius: var(--r-xl);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
    opacity: 0; scale: .97; translate: 0 6px;
    transition: opacity .2s var(--ease), scale .2s var(--ease), translate .2s var(--ease),
                display .2s allow-discrete, overlay .2s allow-discrete;
    &[open] { opacity: 1; scale: 1; translate: 0 0; @starting-style { opacity: 0; scale: .97; translate: 0 6px; } }
    &::backdrop {
      background: oklch(18% 0.02 var(--hue) / 0); backdrop-filter: blur(0);
      transition: background .2s, backdrop-filter .2s, display .2s allow-discrete, overlay .2s allow-discrete;
    }
    &[open]::backdrop { background: oklch(18% 0.02 var(--hue) / .45); backdrop-filter: blur(3px);
      @starting-style { background: oklch(18% 0.02 var(--hue) / 0); backdrop-filter: blur(0); } }
  }
  .dlg { display: flex; flex-direction: column; max-height: inherit; }
  .dlg-head {
    display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px;
    & h2 { font-size: 17px; font-weight: 650; flex: 1; }
  }
  .dlg-body { padding: 4px 20px 16px; display: grid; gap: 16px; overflow-y: auto; }
  .dlg-foot {
    display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 20px;
    border-top: 1px solid var(--border); background: var(--surface-2);
    border-radius: 0 0 var(--r-xl) var(--r-xl);
    & .error { margin-right: auto; }
  }
  .group {
    display: grid; gap: 10px; padding: 14px; border-radius: var(--r-md);
    background: var(--surface-2); border: 1px solid var(--border);
    & > .title { font-size: 13px; font-weight: 600; color: var(--text); }
  }
  .checks { display: flex; flex-wrap: wrap; gap: 8px 18px; &:empty::after { content: "Todavía no hay grupos."; color: var(--text-3); font-size: 13px; } }
  .row { display: flex; gap: 12px; & > .grow { flex: 1; } }

  /* Zona para soltar ficheros */
  .dropzone {
    position: relative; display: grid; place-items: center; gap: 6px; padding: 22px 16px; text-align: center;
    border: 1.5px dashed var(--border-strong); border-radius: var(--r-md); background: var(--surface-2);
    color: var(--text-2); font-size: 13px; cursor: pointer; transition: all .15s;
    & .i { width: 26px; height: 26px; color: var(--accent); }
    & b { color: var(--text); font-weight: 600; }
    & input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
    &:hover, &.over { border-color: var(--accent); background: var(--accent-soft); }
    &:has(input:focus-visible) { outline: 2px solid var(--ring); outline-offset: 2px; }
  }

  /* Caja de etiquetas */
  .tagbox {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 40px; padding: 5px 6px;
    border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); cursor: text;
    &:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
    & input { flex: 1; min-width: 140px; border: 0; outline: 0; background: transparent; height: 28px; padding: 0 6px; font-size: 14px; font-weight: 400; color: var(--text); }
    & .pill { height: 26px; padding: 0 4px 0 10px; font-size: 12.5px; background: var(--accent-soft); color: var(--accent); border-color: transparent; }
    & .pill button { display: grid; place-items: center; width: 18px; height: 18px; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; padding: 0; &:hover { background: color-mix(in oklch, var(--accent) 20%, transparent); } }
  }

  /* Menú emergente (Popover API + anchor positioning con alternativa) */
  .menu {
    margin: 0; padding: 6px; min-width: 220px; border-radius: var(--r-md);
    border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
    inset: auto auto 76px 12px; position: fixed;
    opacity: 0; translate: 0 4px;
    transition: opacity .15s, translate .15s, display .15s allow-discrete, overlay .15s allow-discrete;
    &:popover-open { opacity: 1; translate: 0 0; @starting-style { opacity: 0; translate: 0 4px; } }
    & .menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
    & .menu-head b { display: block; }
    & .menu-head span { font-size: 12.5px; color: var(--text-2); }
    & a, & button {
      display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
      border: 0; background: none; color: var(--text); text-decoration: none; cursor: pointer; font-size: 13.5px; text-align: left;
      & .i { color: var(--text-2); }
      &:hover { background: var(--surface-2); }
    }
  }

  /* Notificaciones */
  .toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: grid; gap: 8px; pointer-events: none; }
  .toast {
    display: flex; align-items: center; gap: 10px; padding: 11px 16px; max-width: min(420px, calc(100vw - 32px));
    border-radius: var(--r-md); background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg);
    font-size: 13.5px; font-weight: 500; pointer-events: auto;
    transition: opacity .25s var(--ease), translate .25s var(--ease);
    @starting-style { opacity: 0; translate: 0 10px; }
    &.err { background: var(--danger); color: white; }
    &.out { opacity: 0; translate: 0 10px; }
  }

  .error { color: var(--danger); font-size: 13px; min-height: 1em; margin: 0; }
  .muted { color: var(--text-2); }
  .hint { color: var(--text-3); font-size: 12.5px; font-weight: 400; }

  .empty {
    display: grid; place-items: center; gap: 10px; padding: 64px 16px; text-align: center; color: var(--text-2);
    & .i { width: 40px; height: 40px; color: var(--text-3); stroke-width: 1.4; }
    & b { color: var(--text); font-size: 15px; }
  }
}

/* ---------------------------------------------------------------- vistas */
@layer views {
  /* ----- Acceso */
  .auth {
    min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; position: relative;
    background:
      radial-gradient(60rem 40rem at 10% -10%, color-mix(in oklch, var(--accent) 18%, transparent), transparent 60%),
      radial-gradient(50rem 36rem at 110% 110%, color-mix(in oklch, var(--accent-2) 14%, transparent), transparent 60%),
      var(--bg);
    & .theme-float { position: absolute; top: 16px; right: 16px; }
  }
  .auth-card {
    width: 100%; max-width: 380px; display: grid; gap: 16px; padding: 32px 28px 28px;
    border-radius: var(--r-xl); background: color-mix(in oklch, var(--surface) 85%, transparent);
    border: 1px solid var(--border); box-shadow: var(--shadow-lg); backdrop-filter: blur(16px);
    & h1 { font-size: 22px; font-weight: 700; }
    & .btn { height: 42px; margin-top: 4px; }
  }
  .logo {
    width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: white;
    background: linear-gradient(140deg, var(--accent), var(--accent-2));
    box-shadow: inset 0 1px 0 oklch(100% 0 0 / .25), 0 6px 16px -6px var(--accent);
    & .i { width: 22px; height: 22px; }
    &.sm { width: 32px; height: 32px; border-radius: 9px; & .i { width: 17px; height: 17px; } }
  }

  /* ----- Estructura principal */
  .shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100dvh; }

  .sidebar {
    position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 4px;
    padding: 16px 12px 12px; border-right: 1px solid var(--border);
    background: color-mix(in oklch, var(--surface) 55%, var(--bg));
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 14px; font-family: var(--font-display); font-weight: 700; font-size: 16.5px; letter-spacing: -.02em; }
  .nav {
    display: grid; gap: 2px; overflow-y: auto;
    & a {
      display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--r-sm);
      color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 13.5px;
      transition: background .15s, color .15s;
      &:hover { background: var(--surface-2); color: var(--text); }
      &[aria-current="page"] {
        background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border);
        & .i { color: var(--accent); }
      }
    }
    & .sep { padding: 18px 10px 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); }
  }
  .sidebar-foot { margin-top: auto; display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
  .sidebar-foot .segmented { width: 100%; & > button { flex: 1; } }
  .userbtn {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border-radius: var(--r-sm);
    border: 0; background: none; cursor: pointer; text-align: left; anchor-name: --user;
    &:hover { background: var(--surface-2); }
    & .who { flex: 1; min-width: 0; line-height: 1.25; }
    & .who b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    & .who span { font-size: 12px; color: var(--text-2); }
  }
  .avatar {
    width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: 13px;
  }
  @supports (position-area: top) {
    #menu-user { position-anchor: --user; position-area: top span-right; inset: auto; margin-bottom: 6px; }
  }

  .main { min-width: 0; display: flex; flex-direction: column; }
  .topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
    height: 64px; padding: 0 28px; border-bottom: 1px solid transparent;
    background: color-mix(in oklch, var(--bg) 80%, transparent); backdrop-filter: saturate(1.4) blur(14px);
    & h1 { font-size: 19px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  }
  .search-trigger {
    display: flex; align-items: center; gap: 10px; width: min(340px, 40vw); height: 38px; padding: 0 8px 0 12px;
    border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface);
    color: var(--text-3); font-size: 13.5px; cursor: pointer; box-shadow: var(--shadow-sm);
    & span { flex: 1; text-align: left; }
    &:hover { border-color: var(--border-strong); color: var(--text-2); }
  }
  .content { padding: 8px 28px 48px; view-transition-name: content; }
  .only-mobile { display: none; }

  /* ----- Catálogo */
  .filterbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
  .filterbar .with-icon { flex: 1; min-width: 220px; max-width: 520px; }
  .count { color: var(--text-3); font-size: 13px; margin-left: auto; font-variant-numeric: tabular-nums; }
  .tagbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; &:empty { display: none; } }

  .grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
  .card {
    position: relative; display: flex; flex-direction: column; gap: 12px; padding: 16px;
    border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border);
    color: inherit; text-decoration: none; box-shadow: var(--shadow-sm);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s;
    content-visibility: auto; contain-intrinsic-size: auto 150px;   /* fluido con miles de apps */
    &:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
    &:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
    & .card-top { display: flex; align-items: flex-start; justify-content: space-between; }
    & .name { font-weight: 600; font-size: 14.5px; letter-spacing: -.005em; display: flex; align-items: center; gap: 6px; }
    & .name .i { color: var(--text-3); }
    & .desc { color: var(--text-2); font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    & .pills { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; }
    & .body { display: grid; gap: 3px; min-width: 0; }
  }
  .fav {
    display: grid; place-items: center; width: 30px; height: 30px; margin: -4px -4px 0 0; border-radius: 8px;
    border: 0; background: none; color: var(--text-3); cursor: pointer; opacity: 0; transition: opacity .15s, background .15s, color .15s;
    & .i { width: 17px; height: 17px; }
    &:hover { background: var(--surface-2); color: var(--text); }
    &.on { opacity: 1; color: var(--star); & .i { fill: currentColor; } }
  }
  .card:hover .fav, .card:focus-within .fav { opacity: 1; }
  @media (hover: none) { .fav { opacity: 1; } }

  /* Vista en lista */
  .grid.list {
    grid-template-columns: 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--r-lg);
    background: var(--surface); overflow: hidden; box-shadow: var(--shadow-sm);
    & .card {
      flex-direction: row; align-items: center; gap: 14px; padding: 10px 14px; border: 0; border-radius: 0;
      border-bottom: 1px solid var(--border); box-shadow: none; contain-intrinsic-size: auto 58px;
      &:last-child { border-bottom: 0; }
      &:hover { transform: none; background: var(--surface-2); box-shadow: none; }
      & .card-top { display: contents; }
      & .tile { --s: 34px; order: 0; }
      & .body { flex: 1; grid-template-columns: minmax(160px, 260px) 1fr; align-items: center; gap: 16px; order: 1; }
      & .desc { -webkit-line-clamp: 1; }
      & .pills { margin: 0; order: 2; flex-wrap: nowrap; }
      & .fav { order: 3; margin: 0; }
    }
  }

  /* ----- App abierta */
  .runner {
    position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg);
    view-transition-name: runner;
  }
  .runbar {
    display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 14px;
    border-bottom: 1px solid var(--border); background: var(--surface);
    & .title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  }
  #frame { flex: 1; width: 100%; border: 0; background: white; }

  /* ----- Administración */
  .toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; & .with-icon { flex: 1; min-width: 200px; max-width: 420px; } & .spacer { flex: 1; } }
  .panel { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); overflow: auto; }
  .table {
    width: 100%; border-collapse: collapse; font-size: 13.5px;
    & th {
      position: sticky; top: 0; z-index: 1; text-align: left; padding: 10px 16px; background: var(--surface-2);
      font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3);
      border-bottom: 1px solid var(--border);
    }
    & td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
    & tbody tr { transition: background .12s; &:hover { background: var(--surface-2); } &:last-child td { border-bottom: 0; } }
    & .actions { text-align: right; white-space: nowrap; width: 1%; }
    & .appcell { display: flex; align-items: center; gap: 12px; min-width: 220px; }
    & .appcell .sub { color: var(--text-2); font-size: 12.5px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    & .pills { display: flex; gap: 4px; flex-wrap: wrap; }
  }
  .status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
    &::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: oklch(70% .17 150); }
    &.off::before { background: var(--text-3); } }
  .tag-access { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); & .i { width: 15px; height: 15px; } }
  .intro { color: var(--text-2); font-size: 13.5px; margin: 0 0 16px; max-width: 70ch; }

  /* ----- Paleta de búsqueda (Ctrl+K) */
  #d-palette {
    width: min(640px, calc(100vw - 24px)); margin-top: 12vh; border-radius: var(--r-xl);
    & .pal-search { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border);
      & .i { color: var(--text-3); width: 20px; height: 20px; }
      & input { flex: 1; height: 58px; border: 0; outline: 0; background: none; font-size: 16px; }
    }
    & .pal-list { max-height: min(420px, 55dvh); overflow-y: auto; padding: 8px; margin: 0; list-style: none; }
    & .pal-sec { padding: 10px 10px 6px; font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
    & .pal-item {
      display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer;
      & .t { flex: 1; min-width: 0; }
      & .t b { display: block; font-weight: 550; font-size: 14px; }
      & .t span { display: block; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
      & .go { color: var(--text-3); opacity: 0; }
      &[aria-selected="true"] { background: var(--accent-soft); & .go { opacity: 1; color: var(--accent); } }
    }
    & .pal-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 12px; color: var(--text-3); border-radius: 0 0 var(--r-xl) var(--r-xl);
      & span { display: inline-flex; align-items: center; gap: 6px; } }
    & .pal-empty { padding: 32px; text-align: center; color: var(--text-2); }
  }

  /* ----- Responsive */
  @media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar {
      position: fixed; z-index: 60; left: 0; top: 0; width: min(86vw, 290px);
      background: var(--surface); box-shadow: var(--shadow-lg);
      translate: -105% 0; transition: translate .25s var(--ease);
    }
    .shell.nav-open .sidebar { translate: 0 0; }
    .scrim { position: fixed; inset: 0; z-index: 55; background: oklch(18% .02 var(--hue) / .4); opacity: 0; pointer-events: none; transition: opacity .25s; }
    .shell.nav-open .scrim { opacity: 1; pointer-events: auto; }
    .only-mobile { display: inline-grid; }
    .topbar { padding: 0 12px; height: 58px; gap: 8px; }
    .search-trigger { width: auto; & span, & kbd { display: none; } }
    .content { padding: 4px 14px 40px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
    .grid.list .card .body { grid-template-columns: 1fr; gap: 0; }
    .grid.list .card .pills { display: none; }
    .runbar .hide-sm { display: none; }
  }
  @media (min-width: 901px) { .scrim { display: none; } }
}

/* ---------------------------------------------------------------- añadidos: pie, iconos, categorías, ajustes */
@layer views {
  :root { interpolate-size: allow-keywords; }   /* permite animar hasta height:auto */

  .main > .content { flex: 1; }

  /* ----- Pie de página: aspecto fijo (oscuro) en ambos temas, casi transparente hasta pasar el ratón */
  .footbar {
    display: flex; align-items: center; gap: 30px; min-height: 46px; padding: 7px 18px 7px 22px;
    border-radius: 12px; border: 1px solid rgb(148 163 184 / .17);
    background: rgb(14 20 32 / .95);
    box-shadow: 0 10px 30px -12px rgb(0 0 0 / .55), inset 0 1px 0 rgb(255 255 255 / .03);
    color: #98a3b3; font: 400 13px/1.35 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; letter-spacing: .005em;
    opacity: .16; transition: opacity .3s var(--ease);
    container-type: inline-size;
    &:hover, &:focus-within { opacity: 1; }
    &.static { opacity: 1; }
    & > * { white-space: nowrap; }
    & b { color: #eef2f7; font-weight: 700; }
    & .fb-owner b { letter-spacing: .03em; }
    & .fb-spacer { flex: 1; }
    & .fb-ai {
      display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 15px 0 4px; border-radius: 999px;
      border: 1.5px solid #1fc8e3; background: rgb(31 200 227 / .07); color: #e3fbff;
      font-weight: 600; font-size: 13.5px; white-space: nowrap;
      box-shadow: 0 0 16px -3px rgb(31 200 227 / .55), inset 0 0 10px -4px rgb(31 200 227 / .5);
      & .dot {
        width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #ffffff;
        background: radial-gradient(circle at 35% 30%, #6eeafc, #0aa5c2 70%);
        box-shadow: 0 0 10px rgb(34 211 238 / .65);
      }
      & .i { width: 14px; height: 14px; stroke-width: 2.2; fill: rgb(255 255 255 / .35); }
    }
    & .fb-link {
      color: #c8d1dd; white-space: nowrap; text-decoration: underline; text-underline-offset: 3px;
      text-decoration-color: rgb(200 209 221 / .5);
    }
    & a.fb-link:hover { color: #fff; text-decoration-color: #fff; }
  }
  .main > .footbar { position: sticky; bottom: 10px; z-index: 15; margin: 0 16px 10px; }
  .auth > .footbar { position: absolute; left: 16px; right: 16px; bottom: 10px; }
  /* El pie se adapta a su propio ancho (container queries), no al de la ventana */
  @container (max-width: 1250px) { .fb-rights-long { display: none; } }
  @container (max-width: 920px) { .fb-owner { display: none; } }
  @container (max-width: 600px) { .fb-ai { display: none; } }
  .footbar .fb-link { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  @media (max-width: 900px) { .footbar { gap: 14px; font-size: 12px; padding: 6px 12px; } }

  /* ----- Iconos del catálogo dentro de la tesela */
  .tile.glyph .i { width: 52%; height: 52%; stroke-width: 2; color: white; }

  /* ----- Selector de icono */
  .icon-pick {
    width: 46px; height: 38px; display: grid; place-items: center; padding: 0; cursor: pointer;
    border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    &:hover { border-color: var(--border-strong); }
    &[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  }
  .iconpicker {
    display: grid; gap: 10px; padding: 12px; border-radius: var(--r-md);
    border: 1px solid var(--border); background: var(--surface-2);
    & .ip-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
    & .ip-head .with-icon { flex: 1; min-width: 160px; }
    & #ip-emoji { width: 130px; }
  }
  .ip-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px;
    max-height: 196px; overflow-y: auto; padding: 2px;
    & button {
      aspect-ratio: 1; display: grid; place-items: center; padding: 0; cursor: pointer;
      border: 1px solid transparent; border-radius: 9px; background: var(--surface); color: var(--text-2);
      transition: all .12s;
      & .i { width: 20px; height: 20px; }
      &:hover { border-color: var(--border-strong); color: var(--text); }
      &[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
    }
  }

  /* ----- Botón conmutador (Agrupar por categorías) */
  .btn.toggle[aria-pressed="true"] {
    background: var(--accent-soft); color: var(--accent);
    border-color: color-mix(in oklch, var(--accent) 40%, transparent);
  }

  /* ----- Secciones por categoría (details plegables y animados) */
  .cat {
    margin-bottom: 18px;
    & > summary {
      list-style: none; display: flex; align-items: center; gap: 10px; padding: 6px 2px; margin-bottom: 8px;
      cursor: pointer; user-select: none; font: 650 15px/1.3 var(--font-display); letter-spacing: -.01em;
      &::-webkit-details-marker { display: none; }
      & .chev { color: var(--text-3); transition: rotate .2s var(--ease); }
      & .fi { color: var(--accent); }
      & .badge { margin-left: 0; }
      & .line { flex: 1; height: 1px; background: var(--border); }
      &:hover .chev { color: var(--text); }
    }
    &:not([open]) > summary .chev { rotate: -90deg; }
    &::details-content { block-size: 0; overflow: clip; transition: block-size .25s var(--ease), content-visibility .25s allow-discrete; }
    &[open]::details-content { block-size: auto; }
    & > .grid { padding: 2px; }
  }

  /* ----- Ajustes */
  .settings { display: grid; gap: 16px; max-width: 820px; }
  .panel.pad { padding: 20px; display: grid; gap: 14px; overflow: visible; & h2 { font-size: 15px; font-weight: 650; } }
  .row.wrap { flex-wrap: wrap; }
  .preview {
    display: grid; gap: 8px; padding: 16px; border-radius: var(--r-md); border: 1px dashed var(--border-strong);
    background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 18px 18px;
  }
  .settings-actions { display: flex; align-items: center; gap: 12px; justify-content: flex-end; & .error { margin-right: auto; } }
}

/* ---------------------------------------------------------------- registro de cambios y auditoría */
@layer views {
  /* El nombre+versión del pie es un botón que abre el registro de cambios */
  .footbar button.fb-link { border: 0; background: none; padding: 0; font: inherit; cursor: pointer; }
  .footbar button.fb-link:hover { color: #fff; text-decoration-color: #fff; }

  code { font: 500 .9em/1 ui-monospace, "Cascadia Code", Consolas, monospace; padding: 2px 5px; border-radius: 5px; background: var(--surface-3); }

  /* ----- Registro de cambios: línea de tiempo */
  .changelog { gap: 0; padding-top: 0; }
  .cl-ver {
    position: relative; padding: 0 0 22px 26px; border-left: 2px solid var(--border);
    margin-left: 6px;
    &:last-child { border-left-color: transparent; padding-bottom: 4px; }
    &::before {
      content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%;
      background: var(--surface); border: 2px solid var(--border-strong);
    }
    &.current::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
    & header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
    & .v { font: 700 16px/1.2 var(--font-display); letter-spacing: -.01em; }
    & time { color: var(--text-3); font-size: 13px; }
    & h4 { margin: 10px 0 4px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
    & ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--text-2); font-size: 13.5px; }
    & li::marker { color: var(--text-3); }
    & li b { color: var(--text); }
  }
  .pill.now { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
  .tone-add { color: light-dark(oklch(52% .15 150), oklch(75% .15 150)); }
  .tone-chg { color: var(--accent); }
  .tone-fix { color: light-dark(oklch(58% .14 70), oklch(80% .14 80)); }
  .tone-del { color: var(--danger); }
  .tone-sec { color: light-dark(oklch(52% .17 300), oklch(75% .13 300)); }

  /* ----- Auditoría */
  .audit-filters {
    & select.input { width: auto; min-width: 170px; }
    & .date-range { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
    & .date-range input { width: 150px; }
  }
  .entity-filter {
    display: flex; align-items: center; gap: 8px; margin: -4px 0 14px; font-size: 13.5px; color: var(--text-2);
    & .chip { height: 28px; }
  }
  .table.audit {
    & th, & td { padding-inline: 12px; }
    & td { vertical-align: top; }
    & .when { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; }
    & .who { white-space: nowrap; font-weight: 550; }
    & .ip { white-space: nowrap; color: var(--text-3); font: 12px/1.4 ui-monospace, Consolas, monospace; }
    & .ent { display: flex; align-items: flex-start; gap: 6px; min-width: 120px; & .i { color: var(--text-3); margin-top: 2px; } }
    & .ent small { color: var(--text-3); margin-left: 2px; }
    & .det { font-size: 13px; color: var(--text-2); min-width: 200px; max-width: 520px; display: grid; gap: 3px; overflow-wrap: anywhere; }
    & .det .f { color: var(--text); font-weight: 550; }
    & .det del { color: var(--danger); text-decoration-color: color-mix(in oklch, var(--danger) 50%, transparent); }
    & .det ins { color: light-dark(oklch(48% .14 150), oklch(76% .15 150)); text-decoration: none; }
    & .det .i { width: 14px; height: 14px; display: inline-block; vertical-align: -2px; }
  }
  .act {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 999px;
    font-size: 12.5px; font-weight: 600; white-space: nowrap;
    background: color-mix(in oklch, currentColor 12%, transparent);
    & .i { width: 14px; height: 14px; }
    &.tone-neutral { color: var(--text-2); }
  }
  .loadmore { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
}

/* ---------------------------------------------------------------- marca INELCOM y animaciones */
@layer views {
  /* ----- Logo con degradado corporativo en movimiento */
  .logo {
    color: white;
    background: linear-gradient(135deg, oklch(from var(--brand) calc(l + 0.08) c calc(h - 10)), var(--brand) 45%, var(--brand-blue)) 0 0 / 220% 220%;
    box-shadow: inset 0 1px 0 oklch(100% 0 0 / .3), 0 8px 20px -8px var(--brand);
    animation: logo-flow 7s ease-in-out infinite alternate;
  }
  @keyframes logo-flow { to { background-position: 100% 100%; } }
  @keyframes float { 50% { translate: 0 -5px; } }

  /* ----- Pantalla de acceso: aurora animada con los colores corporativos */
  .auth { overflow: hidden; isolation: isolate; }
  .auth::before, .auth::after {
    content: ""; position: absolute; z-index: -1; width: 62vmax; height: 62vmax; border-radius: 50%;
    filter: blur(60px); pointer-events: none;
  }
  .auth::before {
    top: -26vmax; left: -16vmax; opacity: .5;
    background: radial-gradient(circle, var(--brand), transparent 65%);
    animation: aurora-a 18s ease-in-out infinite alternate;
  }
  .auth::after {
    bottom: -32vmax; right: -22vmax; opacity: .4;
    background: radial-gradient(circle, var(--brand-blue), transparent 65%);
    animation: aurora-b 23s ease-in-out infinite alternate;
  }
  @keyframes aurora-a { to { transform: translate(20vmax, 14vmax) scale(1.18); } }
  @keyframes aurora-b { to { transform: translate(-18vmax, -12vmax) scale(.88); } }
  .auth-card { animation: rise-in .7s var(--ease) both; }
  .auth-card .logo { width: 52px; height: 52px; border-radius: 15px; animation: logo-flow 7s ease-in-out infinite alternate, float 5s ease-in-out infinite; }
  @keyframes rise-in { from { opacity: 0; translate: 0 22px; scale: .97; } }

  /* ----- Resplandor corporativo que deriva lentamente detrás del contenido */
  .main { position: relative; isolation: isolate; }
  .main::before {
    content: ""; position: fixed; z-index: -1; top: -220px; right: -140px; width: 680px; height: 460px;
    background: radial-gradient(closest-side, color-mix(in oklch, var(--brand) 24%, transparent), transparent);
    filter: blur(10px); pointer-events: none;
    animation: glow-drift 18s ease-in-out infinite alternate;
  }
  @keyframes glow-drift { to { translate: -260px 120px; scale: 1.15; } }

  /* ----- Navegación: indicador corporativo en la sección activa */
  .nav a[aria-current="page"] {
    position: relative;
    &::before {
      content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
      background: var(--brand); box-shadow: 0 0 10px var(--brand);
      animation: bar-in .35s var(--ease) both;
    }
    & .i { color: var(--accent); }
  }
  @keyframes bar-in { from { scale: 1 0; } }

  /* ----- Tarjetas: brillo corporativo que sigue al ratón (--mx/--my desde JS) */
  .card {
    background:
      radial-gradient(380px circle at var(--mx, 50%) var(--my, 0%), color-mix(in oklch, var(--brand) calc(var(--spot) * 18%), transparent), transparent 55%),
      var(--surface);
    transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s, --spot .4s;
    &:hover {
      --spot: 1;
      transform: translateY(-3px);
      border-color: color-mix(in oklch, var(--brand) 45%, var(--border));
      box-shadow: var(--shadow-md), 0 14px 34px -16px color-mix(in oklch, var(--brand) 60%, transparent);
    }
    & .tile { transition: transform .45s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s; }
    &:hover .tile { transform: scale(1.1) rotate(-5deg); }
  }
  .grid.list .card:hover { transform: none; }

  /* ----- Entrada escalonada al cambiar de vista (clase .enter puesta desde JS durante 1 s) */
  #results.enter .card, #results.enter .cat > summary, #results.enter .pin-head {
    animation: card-in .55s var(--ease) both;
    animation-delay: calc(var(--i, 0) * 28ms);
  }
  @keyframes card-in { from { opacity: 0; translate: 0 16px; scale: .96; } }

  /* ----- Favoritas fijadas arriba */
  .pinned { margin-bottom: 24px; }
  .pin-head {
    display: flex; align-items: center; gap: 10px; margin: 2px 2px 10px;
    font: 650 15px/1.3 var(--font-display); letter-spacing: -.01em;
    & .i { color: var(--star); fill: currentColor; }
    & .line { flex: 1; height: 1px; background: linear-gradient(90deg, color-mix(in oklch, var(--star) 50%, transparent), var(--border) 40%); }
  }

  /* ----- Icono con color elegido: degradado calculado desde ese color (color relativo de CSS) */
  .tile.custom {
    background: linear-gradient(140deg, oklch(from var(--c) calc(l + 0.1) c calc(h - 12)), oklch(from var(--c) calc(l - 0.08) calc(c + 0.02) calc(h + 28)));
    color: oklch(from var(--c) clamp(0, (0.8 - l) * 1000, 1) 0 0);   /* blanco o negro según lo claro que sea */
    box-shadow: inset 0 1px 0 oklch(100% 0 0 / .25), 0 3px 10px -3px color-mix(in oklch, var(--c) 65%, transparent);
  }
  .tile.custom.glyph .i { color: inherit; }
  .tile.custom.emoji {
    background: color-mix(in oklch, var(--c) 20%, var(--surface));
    box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--c) 40%, transparent);
  }

  /* ----- Selector de color */
  .ip-colors { display: grid; gap: 8px; }
  .ip-colors .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
  .swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .swatch {
    position: relative; width: 28px; height: 28px; padding: 0; border-radius: 50%; cursor: pointer;
    border: 2px solid var(--surface); background: var(--sw);
    box-shadow: 0 0 0 1px var(--border-strong);
    transition: transform .18s cubic-bezier(.34, 1.56, .64, 1), box-shadow .15s;
    &:hover { transform: scale(1.15); }
    &[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); transform: scale(1.08); }
    &.auto { background: conic-gradient(oklch(72% .15 0), oklch(72% .15 90), oklch(72% .15 180), oklch(72% .15 270), oklch(72% .15 360)); }
    &.corp { width: auto; padding: 0 12px 0 30px; border-radius: 999px; font: 600 12px/24px var(--font); color: var(--on-brand);
      background: radial-gradient(circle at 14px 50%, white 0 4px, transparent 5px), var(--brand); }
    &.pick { display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
    & input[type=color] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }
  }

  /* ----- Pie: distintivo con el cian corporativo exacto */
  .footbar .fb-ai {
    border-color: rgb(0 193 213); background: rgb(0 193 213 / .08);
    box-shadow: 0 0 16px -3px rgb(0 193 213 / .6), inset 0 0 10px -4px rgb(0 193 213 / .55);
    & .dot { background: radial-gradient(circle at 35% 30%, #7af0ff, rgb(0 193 213) 55%, #008a9c); box-shadow: 0 0 10px rgb(0 193 213 / .7); }
  }

  /* ----- Registro de cambios: marca de punto solo para administradores */
  .pill.adm { height: 18px; margin-left: 6px; padding: 0 6px; font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; vertical-align: 1px; }
  .cl-legend { margin: 0 0 14px; }

  /* ----- Botón conmutador activo y selección con la marca */
  .btn.toggle[aria-pressed="true"] { background: color-mix(in oklch, var(--brand) 16%, transparent); border-color: color-mix(in oklch, var(--brand) 50%, transparent); }
  ::selection { background: color-mix(in oklch, var(--brand) 30%, transparent); }
}

/* ---------------------------------------------------------------- logotipo, perfil y pantalla completa */
@layer views {
  /* ----- Logotipo de la empresa (dos variantes: tema claro / tema oscuro) */
  .brand-logo { display: block; object-fit: contain; object-position: left center; }
  [data-brandmark="sm"] .brand-logo { height: 30px; max-width: 200px; }
  [data-brandmark="lg"] .brand-logo { height: 54px; max-width: 260px; animation: rise-in .7s var(--ease) both; }
  .brand-logo.on-dark { display: none; }
  :root[data-theme="dark"] {
    & .brand-logo.on-light { display: none; }
    & .brand-logo.on-dark { display: block; }
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      & .brand-logo.on-light { display: none; }
      & .brand-logo.on-dark { display: block; }
    }
  }
  /* Con logo, el nombre de la aplicación pasa debajo, más discreto */
  .brand.has-logo {
    flex-direction: column; align-items: flex-start; gap: 6px; padding-bottom: 16px;
    & [data-app-name] { font-size: 12.5px; font-weight: 600; color: var(--text-2); letter-spacing: 0; }
  }

  /* ----- Ajustes: huecos para subir el logotipo, con fondo claro y oscuro reales */
  .logo-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
  .logo-slot {
    display: grid; gap: 8px;
    & .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
    & [data-logo-remove] { justify-self: start; }
  }
  .logo-drop {
    position: relative; height: 116px; display: grid; place-items: center; overflow: hidden; cursor: pointer;
    border-radius: var(--r-md); border: 1.5px dashed var(--border-strong);
    transition: border-color .15s, box-shadow .15s;
    &:hover, &.over { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 20%, transparent); }
    &.light-bg { background: #ffffff; color: #64748b; }
    &.dark-bg { background: #0e1520; color: #94a3b8; }
    & input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
    & img { max-height: 72px; max-width: 86%; object-fit: contain; }
    & .ph { display: grid; place-items: center; gap: 6px; font-size: 12.5px; text-align: center; }
    & .ph .i { width: 24px; height: 24px; color: rgb(0 193 213); }
  }

  /* ----- Perfil de usuario */
  .profile-fields { display: grid; gap: 12px; }
  .table .person { display: flex; align-items: center; gap: 12px; min-width: 200px; }
  .table .person .sub { color: var(--text-3); font-size: 12.5px; }
  .pill.warn { background: color-mix(in oklch, var(--danger) 12%, transparent); color: var(--danger); border-color: transparent; }

  /* ----- Pantalla completa */
  .runner:fullscreen { width: 100vw; height: 100vh; }
  :root:fullscreen .footbar { bottom: 6px; }
}

/* ---------------------------------------------------------------- 1.7: menú editable, mercado y actividad */
@layer views {
  .field textarea {
    width: 100%; min-height: 96px; padding: 10px 12px; resize: vertical; border-radius: var(--r-sm);
    background: var(--surface); border: 1px solid var(--border); color: var(--text); font: 400 14px/1.5 var(--font);
    &:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  }

  /* ----- Ajustes: nombres del menú */
  .nav-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 14px; }
  .nav-names .field { gap: 4px; }
  .nav-names .field > span { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }

  /* ----- Formulario de app: imágenes del mercado */
  .media-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
  .media-item {
    position: relative; aspect-ratio: 16 / 10; border-radius: var(--r-sm); overflow: hidden;
    border: 1px solid var(--border); background: var(--surface-2);
    & img { width: 100%; height: 100%; object-fit: cover; display: block; }
    & .tools { position: absolute; inset: auto 4px 4px 4px; display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity .15s; }
    &:hover .tools, &:focus-within .tools { opacity: 1; }
    & .tools button { width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 7px; cursor: pointer;
      background: oklch(15% .02 230 / .75); color: white; backdrop-filter: blur(4px); & .i { width: 14px; height: 14px; } &:hover { background: oklch(15% .02 230 / .95); } }
    & .cover { position: absolute; top: 4px; left: 4px; }
    &.pending { opacity: .55; }
  }
  @media (hover: none) { .media-item .tools { opacity: 1; } }
  .media-add {
    position: relative; aspect-ratio: 16 / 10; display: grid; place-items: center; text-align: center; cursor: pointer;
    border-radius: var(--r-sm); border: 1.5px dashed var(--border-strong); color: var(--text-2); font-size: 12px;
    transition: border-color .15s, background .15s;
    & .i { width: 22px; height: 22px; color: var(--accent); margin: 0 auto 4px; }
    & input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
    &:hover, &.over { border-color: var(--brand); background: color-mix(in oklch, var(--brand) 8%, transparent); }
  }
  .pill.brand { background: var(--brand); color: var(--on-brand); border-color: transparent; font-weight: 700; }

  /* ----- Mercado: carrusel de destacadas */
  .mk-hero {
    position: relative; height: clamp(250px, 34vw, 360px); margin: 4px 0 24px; border-radius: var(--r-xl); overflow: hidden;
    background: var(--surface-2); box-shadow: var(--shadow-md); isolation: isolate;
    &:empty { display: none; }
  }
  .mk-slide {
    position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: center; gap: 28px;
    padding: 28px 36px; opacity: 0; visibility: hidden; transition: opacity .8s var(--ease), visibility .8s;
    &.on { opacity: 1; visibility: visible; }
    & .bg {
      position: absolute; inset: -40px; z-index: -1; background-size: cover; background-position: center;
      filter: blur(36px) saturate(1.3) brightness(.55); transform: scale(1.1);
    }
    & .bg.grad { filter: none; transform: none; inset: 0; }
    &::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, oklch(14% .03 230 / .82) 0%, oklch(14% .03 230 / .35) 60%, transparent); }
    & .txt { color: white; display: grid; gap: 10px; align-content: center; min-width: 0; }
    & .txt h2 { font-size: clamp(22px, 2.6vw, 34px); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
    & .txt p { margin: 0; color: oklch(92% .01 230); font-size: 14.5px; max-width: 46ch; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
    & .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: oklch(86% .02 230); }
    & .actions { display: flex; gap: 10px; margin-top: 6px; }
    & .btn.glass { background: oklch(100% 0 0 / .14); border-color: oklch(100% 0 0 / .25); color: white; backdrop-filter: blur(8px); box-shadow: none; &:hover { background: oklch(100% 0 0 / .24); } }
    & .shot {
      justify-self: end; width: 100%; max-width: 560px; aspect-ratio: 16 / 10; border-radius: 12px; overflow: hidden;
      background: oklch(18% .02 230); box-shadow: 0 30px 60px -20px oklch(0% 0 0 / .6), 0 0 0 1px oklch(100% 0 0 / .12);
      transform: perspective(1200px) rotateY(-8deg) rotateX(2deg); transition: transform .8s var(--ease);
      & .chrome { height: 22px; display: flex; align-items: center; gap: 5px; padding: 0 9px; background: oklch(24% .02 230); }
      & .chrome i { width: 8px; height: 8px; border-radius: 50%; background: oklch(45% .02 230); }
      & img { width: 100%; height: calc(100% - 22px); object-fit: cover; display: block; }
      & .tile { --s: 110px; margin: auto; }
      & .ph { height: calc(100% - 22px); display: grid; place-items: center; }
    }
    &.on .shot { animation: shot-in 1s var(--ease) both; }
    &.on .shot img { animation: kenburns 9s ease-out both; }
    &.on .txt > * { animation: rise-in .7s var(--ease) both; }
    &.on .txt > :nth-child(2) { animation-delay: .08s; }
    &.on .txt > :nth-child(3) { animation-delay: .16s; }
    &.on .txt > :nth-child(4) { animation-delay: .24s; }
    &.on .txt > :nth-child(5) { animation-delay: .32s; }
  }
  @keyframes shot-in { from { opacity: 0; transform: perspective(1200px) rotateY(-18deg) translateX(40px); } }
  @keyframes kenburns { from { scale: 1.12; } to { scale: 1; } }
  .mk-dots { position: absolute; left: 36px; bottom: 18px; display: flex; gap: 6px; z-index: 2; }
  .mk-dots button {
    width: 8px; height: 8px; border-radius: 99px; border: 0; padding: 0; cursor: pointer; background: oklch(100% 0 0 / .4);
    transition: width .3s var(--ease), background .3s;
    &[aria-current="true"] { width: 26px; background: var(--brand); }
  }
  .mk-arrow {
    position: absolute; top: 50%; translate: 0 -50%; z-index: 2; width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
    display: grid; place-items: center; color: white; background: oklch(100% 0 0 / .14); backdrop-filter: blur(8px); opacity: 0; transition: opacity .2s, background .2s;
    &.prev { left: 10px; } &.next { right: 10px; }
    &:hover { background: oklch(100% 0 0 / .28); }
  }
  .mk-hero:hover .mk-arrow, .mk-hero:focus-within .mk-arrow { opacity: 1; }
  @media (max-width: 760px) {
    .mk-slide { grid-template-columns: 1fr; padding: 22px; & .shot { display: none; } }
    .mk-dots { left: 22px; }
  }

  /* ----- Mercado: tarjetas */
  .mk-section { margin-bottom: 28px; }
  .mk-section > h3 { display: flex; align-items: center; gap: 10px; margin: 0 2px 12px; font-size: 16px; font-weight: 700; }
  .mk-section > h3 .line { flex: 1; height: 1px; background: var(--border); }
  .mk-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .mk-card {
    position: relative; display: flex; flex-direction: column; border-radius: var(--r-lg); overflow: hidden; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); color: inherit; text-align: left; padding: 0; font: inherit;
    transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s;
    content-visibility: auto; contain-intrinsic-size: auto 290px;
    &:hover { transform: translateY(-4px); border-color: color-mix(in oklch, var(--brand) 45%, var(--border));
      box-shadow: var(--shadow-md), 0 18px 40px -18px color-mix(in oklch, var(--brand) 65%, transparent); }
    &:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
    & .cover { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-2); }
    & .cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: scale .6s var(--ease); }
    &:hover .cover img { scale: 1.06; }
    & .cover .gen { position: absolute; inset: 0; display: grid; place-items: center; }
    & .cover .gen .tile { --s: 76px; }
    & .cover .count { position: absolute; right: 8px; bottom: 8px; }
    & .body { display: grid; gap: 6px; padding: 14px 16px 16px; }
    & .head { display: flex; align-items: center; gap: 10px; min-width: 0; }
    & .head b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    & .head small { display: block; color: var(--text-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    & .desc { color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
  }
  #mk-grid.enter .mk-card, #mk-grid.enter .mk-section > h3 { animation: card-in .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 35ms); }
  /* Portada generada (sin imágenes): degradado con el color de la app */
  .gen-cover { background: radial-gradient(120% 120% at 20% 10%, oklch(from var(--c, var(--brand)) calc(l + .1) c h / .55), transparent 60%),
      linear-gradient(140deg, oklch(from var(--c, var(--brand)) .32 calc(c * .6) h), oklch(from var(--c, var(--brand)) .2 calc(c * .5) calc(h + 30))); }

  /* ----- Mercado: ficha */
  .mk-dialog { width: min(980px, calc(100vw - 24px)); overflow-y: auto; & .dlg { max-height: none; } }
  .btn[data-mkfav][aria-pressed="true"] .i { color: var(--star); fill: currentColor; }
  .mk-detail-head {
    position: relative; display: flex; align-items: center; gap: 16px; padding: 22px 22px 18px; overflow: hidden; isolation: isolate;
    & .tile { --s: 64px; }
    & h2 { font-size: 22px; font-weight: 800; }
    & .sub { color: var(--text-2); font-size: 13.5px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
    & .acts { margin-left: auto; display: flex; gap: 8px; align-items: center; }
    &::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .5;
      background: radial-gradient(60% 140% at 0% 0%, color-mix(in oklch, var(--c, var(--brand)) 30%, transparent), transparent 70%); }
  }
  .mk-gallery { display: grid; gap: 10px; padding: 0 22px; }
  .mk-main {
    position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); cursor: zoom-in;
    border: 1px solid var(--border);
    & img { width: 100%; height: 100%; object-fit: contain; display: block; animation: fade-in .35s var(--ease); }
  }
  @keyframes fade-in { from { opacity: 0; } }
  .mk-thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
  .mk-thumbs button {
    flex: none; width: 104px; aspect-ratio: 16 / 10; padding: 0; border-radius: 8px; overflow: hidden; cursor: pointer;
    border: 2px solid transparent; background: var(--surface-2); opacity: .65; transition: opacity .15s, border-color .15s;
    & img { width: 100%; height: 100%; object-fit: cover; display: block; }
    &:hover { opacity: 1; }
    &[aria-current="true"] { border-color: var(--brand); opacity: 1; }
  }
  .mk-info { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(220px, 1fr); gap: 24px; padding: 18px 22px 24px; }
  .mk-info .prose { color: var(--text-2); font-size: 14px; line-height: 1.65; & p { margin: 0 0 10px; } & b { color: var(--text); } }
  .mk-facts { display: grid; gap: 12px; align-content: start; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border);
    & dt { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
    & dd { margin: 2px 0 0; font-size: 14px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; } }
  @media (max-width: 760px) { .mk-info { grid-template-columns: 1fr; } .mk-detail-head { flex-wrap: wrap; & .acts { margin-left: 0; } } }

  /* ----- Visor de imágenes a pantalla completa */
  .lightbox {
    width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0;
    background: oklch(10% .01 230 / .94); display: grid; place-items: center;
    &:not([open]) { display: none; }
    & img { max-width: 92vw; max-height: 86dvh; object-fit: contain; border-radius: 8px; box-shadow: 0 30px 80px oklch(0% 0 0 / .6); animation: lb-in .35s var(--ease); }
    & button { position: absolute; border: 0; cursor: pointer; display: grid; place-items: center; color: white; background: oklch(100% 0 0 / .12); border-radius: 50%; width: 44px; height: 44px;
      &:hover { background: oklch(100% 0 0 / .25); } }
    & .lb-nav.prev { left: 18px; top: 50%; } & .lb-nav.next { right: 18px; top: 50%; }
    & .lb-close { top: 16px; right: 16px; }
    & .lb-count { position: absolute; bottom: 16px; color: oklch(85% .01 230); font-size: 13px; }
    &::backdrop { background: transparent; }
  }
  @keyframes lb-in { from { opacity: 0; scale: .96; } }

  /* ----- Ficha de actividad por usuario */
  .act-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px;
    & .avatar { width: 48px; height: 48px; font-size: 17px; }
    & h2 { font-size: 20px; font-weight: 750; }
    & .sub { color: var(--text-2); font-size: 13.5px; }
    & .right { margin-left: auto; display: flex; gap: 8px; align-items: center; } }
  .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
  .kpi { padding: 14px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    & .k { font-size: 12px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
    & .k .i { width: 15px; height: 15px; color: var(--accent); }
    & .v { font: 750 26px/1.15 var(--font-display); letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
    & .s { font-size: 12.5px; color: var(--text-3); margin-top: 2px; } }
  .act-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
  @media (max-width: 1000px) { .act-grid { grid-template-columns: 1fr; } }
  .chart-card { padding: 16px 18px; & h3 { font-size: 14px; font-weight: 650; margin-bottom: 2px; } & .hint { display: block; margin-bottom: 14px; } }
  /* Barras por día: una sola serie (sin leyenda), color de acento con contraste AA, extremos redondeados de 4px anclados a la base */
  .daybars { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end; gap: 2px; height: 150px;
    border-bottom: 1px solid var(--border-strong); padding-top: 18px; }
  .daybars .b { position: relative; height: 100%; display: flex; align-items: flex-end; cursor: default; }
  .daybars .b span { display: block; width: 100%; min-height: 0; background: var(--accent); border-radius: 4px 4px 0 0; transform-origin: bottom; animation: grow .6s var(--ease) both; animation-delay: calc(var(--i) * 12ms); }
  .daybars .b.zero span { height: 2px !important; background: var(--border-strong); border-radius: 1px; }
  .daybars .b:hover span { filter: brightness(1.15); }
  .daybars .b:hover::after {
    content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; translate: -50% 0; z-index: 3; white-space: nowrap; pointer-events: none;
    padding: 5px 9px; border-radius: 7px; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 600; box-shadow: var(--shadow-md);
  }
  @keyframes grow { from { scale: 1 0; } }
  .daybars-axis { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
  /* Ranking de apps: barra horizontal + número en tinta de texto */
  .rank { display: grid; gap: 10px; }
  .rank .r { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13.5px; }
  .rank .r .tile { --s: 28px; }
  .rank .r .nm { min-width: 0; display: grid; gap: 4px; }
  .rank .r .nm b { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rank .r .track { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
  .rank .r .fill { height: 100%; border-radius: 99px; background: var(--accent); transform-origin: left; animation: grow-x .7s var(--ease) both; }
  .rank .r .n { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--text); }
  @keyframes grow-x { from { scale: 0 1; } }
  /* Cronología */
  .timeline { padding: 6px 18px 12px; }
  .tl-day { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 14px 0 6px; }
  .tl-item { display: grid; grid-template-columns: 60px 26px minmax(0, 1fr); gap: 10px; align-items: start; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13.5px;
    &:last-child { border-bottom: 0; }
    & .t { color: var(--text-3); font-variant-numeric: tabular-nums; padding-top: 3px; }
    & .ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); & .i { width: 14px; height: 14px; } }
    & .ic.open { background: color-mix(in oklch, var(--brand) 18%, transparent); color: var(--accent); }
    & .what b { font-weight: 600; }
    & .what .det { color: var(--text-3); font-size: 12.5px; margin-top: 2px; } }
}

/* ---------------------------------------------------------------- 1.8: estados y solicitudes de acceso */
@layer views {
  /* Distintivo de estado: el color del estado como punto + fondo suave */
  .st-badge {
    --c: #64748b;
    display: inline-flex; align-items: center; gap: 6px; height: 20px; padding: 0 8px 0 7px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600; white-space: nowrap;
    color: light-dark(oklch(from var(--c) min(l, .5) c h), oklch(from var(--c) max(l, .8) calc(c * .8) h));
    background: color-mix(in oklch, var(--c) 14%, transparent);
    border: 1px solid color-mix(in oklch, var(--c) 30%, transparent);
    &::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c);
      box-shadow: 0 0 0 3px color-mix(in oklch, var(--c) 22%, transparent); }
  }
  /* App visible pero que no se puede abrir (p. ej. en mantenimiento) */
  .card.off { cursor: not-allowed; & .tile { filter: grayscale(.85); opacity: .65; } & .name, & .desc { opacity: .7; }
    &:hover { transform: none; } }

  /* Mercado: etiquetas sobre la portada */
  .mk-card .cover-tags { position: absolute; top: 8px; left: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
  .mk-card .cover-tags .st-badge, .mk-card .cover-tags .pill { backdrop-filter: blur(8px); background: color-mix(in oklch, var(--surface) 82%, transparent); }
  .pill.req { color: var(--text); border-color: transparent; font-weight: 600; & .i { width: 12px; height: 12px; } }
  .pill.req.pending { color: var(--accent); }

  /* Ficha: bloque de acceso */
  .callout {
    display: flex; align-items: center; gap: 14px; margin: 0 22px 18px; padding: 14px 16px; border-radius: var(--r-md);
    border: 1px solid color-mix(in oklch, var(--brand) 40%, var(--border));
    background: linear-gradient(120deg, color-mix(in oklch, var(--brand) 12%, var(--surface)), var(--surface));
    animation: rise-in .4s var(--ease) both;
    & > .i { flex: none; width: 22px; height: 22px; color: var(--accent); }
    & .grow { flex: 1; min-width: 0; display: grid; gap: 4px; }
    & b { font-size: 14.5px; }
    & span { color: var(--text-2); font-size: 13px; }
    & .rejected { color: var(--danger); }
    & textarea { width: 100%; margin-top: 6px; }
    & .ask-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
    &.ask { align-items: flex-start; }
    &.info > .i { color: var(--accent); }
    &.warn { border-color: color-mix(in oklch, var(--danger) 35%, var(--border)); background: var(--danger-soft); & > .i { color: var(--danger); } }
  }
  @media (max-width: 640px) { .callout { flex-wrap: wrap; } }

  /* Diálogo de app: resumen de visibilidad */
  #state-hint .hint { margin: 0 0 8px; }
  .vis-map { display: flex; flex-wrap: wrap; gap: 6px; }
  .vis { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 12.5px;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-3); text-decoration: line-through; text-decoration-color: color-mix(in oklch, currentColor 50%, transparent);
    & .i { width: 13px; height: 13px; } & small { font-size: 11.5px; text-decoration: none; }
    &.on { color: var(--text); text-decoration: none; border-color: color-mix(in oklch, var(--brand) 45%, var(--border));
      background: color-mix(in oklch, var(--brand) 10%, var(--surface)); & .i:first-child { color: var(--accent); } } }
  #app-users { min-height: 40px; }
  #app-users select { border: 0; background: transparent; color: var(--text-2); min-width: 160px; flex: 1; outline: none; cursor: pointer; }

  /* Tablas de administración */
  .table .state-cell { display: grid; gap: 6px; justify-items: start; }
  .table .state-cell .muted { opacity: .6; }
  .table .access-cell { display: grid; gap: 4px; }
  .table .state-name { display: flex; align-items: center; gap: 8px; }
  .table td .sub { color: var(--text-3); font-size: 12.5px; margin-top: 3px; }
  .table .c, .table .flag-cell { text-align: center; }
  .table td.msg { max-width: 320px; color: var(--text-2); white-space: pre-line; }
  .table td.msg { min-width: 180px; }
  .table td.when { white-space: nowrap; color: var(--text-2); }
  .table .state-name .pill { height: 20px; font-size: 11px; padding: 0 8px; }
  .flag { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: var(--text-3); background: var(--surface-2);
    & .i { width: 13px; height: 13px; }
    &.on { color: var(--on-brand); background: var(--brand); box-shadow: 0 0 10px -3px var(--brand); } }
  .i.rot90 { rotate: 90deg; }
  .icon-btn:disabled { opacity: .35; cursor: default; pointer-events: none; }
  .req-status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text-2);
    & .i { width: 14px; height: 14px; }
    &.info { color: var(--accent); } &.ok { color: oklch(62% .17 150); } &.warn { color: var(--danger); } }
  .badge.hot { background: var(--brand); color: var(--on-brand); animation: pulse-hot 2.4s ease-in-out infinite; }
  @keyframes pulse-hot { 50% { box-shadow: 0 0 0 4px color-mix(in oklch, var(--brand) 25%, transparent); } }
}

/* ---------------------------------------------------------------- transiciones entre vistas */
@layer utilities {
  ::view-transition-old(content) { animation: vt-out .14s ease both; }
  ::view-transition-new(content) { animation: vt-in .22s var(--ease) both; }
  ::view-transition-new(runner) { animation: vt-up .26s var(--ease) both; }
  ::view-transition-old(runner) { animation: vt-down .18s ease both; }
  @keyframes vt-out { to { opacity: 0; } }
  @keyframes vt-in { from { opacity: 0; translate: 0 6px; } }
  @keyframes vt-up { from { opacity: 0; translate: 0 18px; } }
  @keyframes vt-down { to { opacity: 0; translate: 0 18px; } }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
      animation-duration: 0s !important; transition-duration: 0s !important;
    }
  }
}
