/* ============================================================
   AU · sistema de diseño compartido (au.aicons.pro)
   ------------------------------------------------------------
   Una sola hoja para las 4 páginas del portal. Reemplaza el
   bloque <style> con el aurora morado que cada página duplicaba.

   Tema: claro/oscuro AUTOMÁTICO según el sistema operativo.
   No hay toggle: los tokens viven en :root y se redefinen en
   @media (prefers-color-scheme: dark). Todo color de la UI sale
   de un token — si algo se ve mal en un tema, se arregla acá.

   Los tokens se declaran como "R G B" (sin rgb()) para que
   Tailwind pueda componer opacidad: rgb(var(--ink) / <alpha-value>).
   Por eso en HTML se usa text-ink/60, bg-surface/80, etc.
   ============================================================ */

:root {
  /* --- superficie --- */
  --bg:       250 248 244;   /* papel cálido */
  --surface:  255 255 255;   /* paneles */
  --sunken:   244 241 234;   /* inputs, celdas hundidas */
  --line:     228 222 210;   /* hairlines */
  --line-soft:238 233 224;

  /* --- texto --- */
  --ink:      26 25 21;      /* off-black cálido, nunca #000 */
  --muted:    108 103 92;
  --faint:    150 144 132;

  /* --- un solo acento (sienna quemado, sat ~59%) --- */
  --accent:   163 87 42;
  --accent-on:255 252 248;
  --accent-wash: 163 87 42;  /* se usa siempre con alpha baja */

  /* --- estados --- */
  --ok:       61 106 71;
  --warn:     158 114 24;
  --bad:      166 56 52;

  /* --- sombra tintada (nunca negro puro) --- */
  --shadow:   62 48 30;
  --shadow-a: 0.09;

  --grain-a:  0.055;
  --ring:     163 87 42;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       20 19 16;
    --surface:  28 26 22;
    --sunken:   35 32 27;
    --line:     48 44 37;
    --line-soft:40 37 31;

    --ink:      238 235 227;
    --muted:    156 150 138;
    --faint:    116 111 101;

    --accent:   224 138 82;
    --accent-on:28 20 12;
    --accent-wash: 224 138 82;

    --ok:       138 186 120;
    --warn:     216 168 78;
    --bad:      224 133 133;

    --shadow:   0 0 0;
    --shadow-a: 0.4;

    --grain-a:  0.035;
    --ring:     224 138 82;
  }
}

/* ============================================================
   BASE
   ============================================================ */

* { border-color: rgb(var(--line)); }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: rgb(var(--bg));
  color: rgb(var(--ink));
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  font-feature-settings: 'ss01';
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* Grano fijo: rompe la planitud digital sin costo de imagen.
   pointer-events:none para no comerse ningún click. */
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 100;
  pointer-events: none;
  opacity: var(--grain-a);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3, .display {
  font-family: 'Bricolage Grotesque', 'DM Sans', system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* Toda cifra en tabular para que las columnas no bailen. */
.tnum, td .tnum, .count { font-variant-numeric: tabular-nums; }

code, .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .92em; }

::selection { background: rgb(var(--accent) / .22); }

/* Foco visible en todo lo interactivo — requisito de accesibilidad. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid rgb(var(--ring));
  outline-offset: 2px;
  border-radius: 6px;
}

/* Salto al contenido para teclado/lectores. */
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: rgb(var(--surface)); color: rgb(var(--ink));
  padding: 10px 16px; border: 1px solid rgb(var(--line)); border-radius: 0 0 10px 0;
}
.skip:focus { left: 0; }

/* ============================================================
   SUPERFICIES
   ============================================================ */

.panel {
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--line));
  border-radius: 14px;
  box-shadow: 0 1px 2px rgb(var(--shadow) / calc(var(--shadow-a) * .5));
}

/* Panel sin elevación: solo delimita, no compite. */
.panel-flat {
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--line));
  border-radius: 14px;
}

.bar {
  background: rgb(var(--bg) / .82);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  border-bottom: 1px solid rgb(var(--line));
}

.sunken {
  background: rgb(var(--sunken));
  border: 1px solid rgb(var(--line));
}

.hairline { border-bottom: 1px solid rgb(var(--line-soft)); }

/* ============================================================
   TIPOGRAFÍA DE APOYO
   ============================================================ */

.eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgb(var(--faint));
}

.lede { color: rgb(var(--muted)); max-width: 62ch; line-height: 1.6; text-wrap: pretty; }

/* ============================================================
   CONTROLES
   ============================================================ */

.field {
  width: 100%;
  background: rgb(var(--sunken));
  border: 1px solid rgb(var(--line));
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 13.5px;
  color: rgb(var(--ink));
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.field::placeholder { color: rgb(var(--faint)); }
.field:hover { border-color: rgb(var(--muted) / .45); }
.field:focus {
  outline: none;
  background: rgb(var(--surface));
  border-color: rgb(var(--accent) / .65);
  box-shadow: 0 0 0 3px rgb(var(--accent) / .14);
}
/* El select nativo necesita su propia flecha para no heredar la del SO. */
select.field {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23968f83' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M5 9l7 7 7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid rgb(var(--line));
  background: rgb(var(--surface));
  color: rgb(var(--ink));
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, transform .1s ease, color .16s ease;
}
.btn:hover { background: rgb(var(--sunken)); border-color: rgb(var(--muted) / .4); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-accent {
  background: rgb(var(--accent));
  border-color: rgb(var(--accent));
  color: rgb(var(--accent-on));
  font-weight: 600;
}
.btn-accent:hover { background: rgb(var(--accent) / .88); border-color: rgb(var(--accent) / .88); }

.btn-quiet { background: transparent; border-color: transparent; color: rgb(var(--muted)); }
.btn-quiet:hover { background: rgb(var(--ink) / .05); color: rgb(var(--ink)); border-color: transparent; }

.btn-danger { color: rgb(var(--bad)); border-color: rgb(var(--bad) / .35); background: transparent; }
.btn-danger:hover { background: rgb(var(--bad) / .1); border-color: rgb(var(--bad) / .5); }

.btn-sm { padding: 5px 10px; font-size: 11.5px; border-radius: 7px; }

/* ============================================================
   BADGES — cuadrados, no píldoras genéricas
   ============================================================ */

.tag {
  display: inline-flex; align-items: center;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tag-neutral { background: rgb(var(--ink) / .06);   color: rgb(var(--muted)); border-color: rgb(var(--line)); }
.tag-accent  { background: rgb(var(--accent) / .12); color: rgb(var(--accent)); border-color: rgb(var(--accent) / .28); }
.tag-ok      { background: rgb(var(--ok) / .12);     color: rgb(var(--ok));     border-color: rgb(var(--ok) / .3); }
.tag-warn    { background: rgb(var(--warn) / .13);   color: rgb(var(--warn));   border-color: rgb(var(--warn) / .3); }
.tag-bad     { background: rgb(var(--bad) / .12);    color: rgb(var(--bad));    border-color: rgb(var(--bad) / .3); }

/* ============================================================
   LISTAS / FILAS
   Un archivo no necesita ser una tarjeta con borde y sombra:
   50 tarjetas iguales = ruido. Filas con hairline, acciones al hover.
   ============================================================ */

.rows > * + * { border-top: 1px solid rgb(var(--line-soft)); }

.row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 13px 16px;
  transition: background .14s ease;
}
.row:hover { background: rgb(var(--accent) / .04); }
.row .row-actions { opacity: 0; transition: opacity .14s ease; }
.row:hover .row-actions,
.row:focus-within .row-actions { opacity: 1; }
@media (hover: none) { .row .row-actions { opacity: 1; } }

/* Migas de carpeta */
.crumb {
  display: inline-flex; align-items: center;
  font-size: 11px;
  color: rgb(var(--muted));
  background: rgb(var(--ink) / .045);
  border-radius: 5px;
  padding: 1.5px 6px;
}
.crumb-sep { color: rgb(var(--faint)); font-size: 11px; padding: 0 3px; }

/* ============================================================
   ÁRBOL DE CARPETAS
   ============================================================ */

.node {
  display: flex; align-items: center; gap: 4px;
  border-radius: 8px;
  padding-right: 8px;
  border-left: 2px solid transparent;
  transition: background .14s ease, border-color .14s ease;
}
.node:hover { background: rgb(var(--ink) / .045); }
.node-active {
  background: rgb(var(--accent) / .1);
  border-left-color: rgb(var(--accent));
}
.node-active .node-label { color: rgb(var(--accent)); font-weight: 600; }
.caret { transition: transform .16s ease; }
.caret.open { transform: rotate(90deg); }

/* ============================================================
   TABLAS
   ============================================================ */

/* display:table explícito a propósito. La clase se llamaba .grid y chocaba con la
   utilidad .grid de Tailwind (display:grid), que convertía la tabla en una grilla CSS:
   thead y tbody quedaban como items independientes, cada uno calculando sus propias
   columnas — de ahí que los títulos no cuadraran con los datos. */
table.tabla { display: table; border-collapse: separate; border-spacing: 0; width: 100%; }
table.tabla th {
  position: sticky; top: 0; z-index: 1;
  background: rgb(var(--surface));
  border-bottom: 1px solid rgb(var(--line));
  padding: 9px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: rgb(var(--faint));
  white-space: nowrap;
}
table.tabla td {
  padding: 9px 12px;
  border-bottom: 1px solid rgb(var(--line-soft));
  font-size: 13px;
  vertical-align: middle;
}
table.tabla tbody tr:hover td { background: rgb(var(--accent) / .04); }
table.tabla tbody tr:last-child td { border-bottom: 0; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: rgb(var(--ink)); }
.sort-arrow { opacity: .3; }
th.sort-asc .sort-arrow, th.sort-desc .sort-arrow { opacity: 1; color: rgb(var(--accent)); }

/* ============================================================
   ESTADOS: carga / vacío / error
   ============================================================ */

/* Skeleton con la forma del contenido real, no un spinner genérico. */
.sk { background: rgb(var(--ink) / .07); border-radius: 6px; position: relative; overflow: hidden; }
.sk::after {
  content: ''; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgb(var(--ink) / .05), transparent);
  animation: sk 1.4s infinite;
}
@keyframes sk { 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .sk::after { animation: none; } }

.empty { padding: 48px 24px; text-align: center; }
.empty-mark {
  width: 42px; height: 42px; margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: rgb(var(--accent) / .1);
  color: rgb(var(--accent));
}
.empty-title { font-weight: 600; font-size: 14px; }
.empty-hint { font-size: 12.5px; color: rgb(var(--muted)); margin-top: 5px; }

.notice { font-size: 12px; border-radius: 9px; padding: 9px 12px; border: 1px solid; }
.notice-bad { background: rgb(var(--bad) / .08); border-color: rgb(var(--bad) / .3); color: rgb(var(--bad)); }
.notice-ok  { background: rgb(var(--ok) / .09);  border-color: rgb(var(--ok) / .3);  color: rgb(var(--ok)); }

/* Punto de autoguardado por campo (users.php). */
.dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; transition: background .2s ease; flex: none; }
.dot.dirty  { background: rgb(var(--warn)); }
.dot.saving { background: rgb(var(--accent)); animation: pulse 1s infinite; }
.dot.saved  { background: rgb(var(--ok)); }
.dot.error  { background: rgb(var(--bad)); }
@keyframes pulse { 50% { opacity: .3; } }

/* ============================================================
   ENTRADA ESCALONADA — nunca montar todo de golpe
   ============================================================ */

.rise { animation: rise .42s cubic-bezier(.22,.9,.3,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } }
@media (prefers-reduced-motion: reduce) { .rise { animation: none; } }

/* ============================================================
   SCROLLBARS
   ============================================================ */

.scroll::-webkit-scrollbar { width: 9px; height: 9px; }
.scroll::-webkit-scrollbar-thumb { background: rgb(var(--ink) / .16); border-radius: 5px; }
.scroll::-webkit-scrollbar-thumb:hover { background: rgb(var(--ink) / .26); }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll { scrollbar-width: thin; scrollbar-color: rgb(var(--ink) / .18) transparent; }
