/* Mi oficina — estilos. Móvil primero; claro/oscuro con tokens. Sin estilos en línea (CSP estricta). */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --tile: #f1f2f5;
  --tile-hover: #e8eaf0;
  --border: #e1e4ea;
  --text: #14161c;
  --muted: #5a6272;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --accent-soft: #e6eeff;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --ok: #067647;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a20;
    --tile: #20242c;
    --tile-hover: #292e38;
    --border: #2a2f39;
    --text: #eceef2;
    --muted: #9aa3b2;
    --accent: #6c97ff;
    --accent-text: #0b0f1a;
    --accent-soft: #1d2740;
    --danger: #ff8b80;
    --danger-bg: #3a1c1a;
    --ok: #4ad295;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a20;
  --tile: #20242c;
  --tile-hover: #292e38;
  --border: #2a2f39;
  --text: #eceef2;
  --muted: #9aa3b2;
  --accent: #6c97ff;
  --accent-text: #0b0f1a;
  --accent-soft: #1d2740;
  --danger: #ff8b80;
  --danger-bg: #3a1c1a;
  --ok: #4ad295;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}
h1, h2, p { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.ico { display: inline-flex; width: 1.5em; height: 1.5em; }
.ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.centro { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- acceso ---------- */
.tarjeta-login {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 28px 22px 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
}
.marca-grande { width: 54px; height: 54px; border-radius: 16px; background: var(--accent); color: var(--accent-text); display: flex; align-items: center; justify-content: center; margin: 0 auto 6px; font-size: 26px; }
.tarjeta-login h1 { text-align: center; font-size: 24px; }
.sub { text-align: center; color: var(--muted); margin-bottom: 10px; }
.tarjeta-login label { font-size: 14px; font-weight: 600; margin-top: 6px; }
.tarjeta-login input {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 12px; min-height: 46px;
}
.tarjeta-login input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-primario {
  margin-top: 14px; min-height: 48px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-text);
  font-family: inherit; font-weight: 600; font-size: 16px; line-height: 1; cursor: pointer;
}
.btn-primario:disabled { opacity: .6; cursor: progress; }
.pie-login { text-align: center; font-size: 14px; margin-top: 10px; }
.aviso { background: var(--accent-soft); color: var(--text); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.error { color: var(--danger); background: var(--danger-bg); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.bloque-error { margin: 0 0 16px; }

/* ---------- barra ---------- */
.barra { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top); }
.barra-in { max-width: 960px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 56px; }
.barra-marca { display: flex; align-items: center; gap: 10px; font-size: 17px; min-width: 0; }
.marca-chica { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-text); display: inline-flex; align-items: center; justify-content: center; font-size: 17px; flex: none; }
.chip-beta { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 8px; }
.barra-acciones { display: flex; align-items: center; gap: 6px; min-width: 0; }
.barra-nombre { color: var(--muted); font-size: 14px; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-icono { width: 44px; height: 44px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 20px; }
.btn-icono:hover { background: var(--tile); }

/* ---------- inicio ---------- */
.envoltura { max-width: 960px; margin: 0 auto; padding: 18px 16px calc(40px + env(safe-area-inset-bottom)); }
.portada { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 16px; text-align: center; box-shadow: var(--shadow); margin-bottom: 18px; }
.portada-marca { width: 46px; height: 46px; margin: 0 auto 8px; color: var(--accent); font-size: 36px; display: flex; align-items: center; justify-content: center; }
.portada h1 { font-size: 26px; letter-spacing: .06em; }
.portada-sub { color: var(--muted); margin-top: 4px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.chips:empty { display: none; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--tile); border: 1px solid var(--border); color: var(--text); }
.chip-rol { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }

.grupo { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 14px 14px; margin-bottom: 16px; box-shadow: var(--shadow); }
.grupo h2 { font-size: 15px; letter-spacing: .03em; text-transform: uppercase; margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.h-sub { color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 14px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  min-height: 112px; padding: 14px 10px; border-radius: 14px; background: var(--tile); color: var(--text); text-decoration: none;
  border: 1px solid transparent; font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
a.tile:hover, a.tile:focus-visible { background: var(--tile-hover); border-color: var(--border); }
.tile .ico { font-size: 28px; color: var(--accent); }
.tile-titulo { font-weight: 650; font-size: 15px; line-height: 1.2; overflow-wrap: anywhere; }
.tile-desc { color: var(--muted); font-size: 12.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-prox { cursor: default; opacity: .62; }
.tile-prox .ico { color: var(--muted); }
.insignia { position: absolute; top: 8px; right: 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px; }
.tiles-admin { grid-template-columns: 1fr; }
.tiles-admin .tile { flex-direction: row; justify-content: flex-start; text-align: left; min-height: 76px; gap: 14px; padding: 12px 16px; }
.tiles-admin .tile-texto { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

@media (min-width: 640px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .portada { padding: 28px 24px; }
  .grupo { padding: 20px 20px 18px; }
  .barra-nombre { max-width: 260px; }
}
@media (min-width: 960px) { .tiles { gap: 14px; } .tile { min-height: 124px; } }

/* ajustes de pantallas muy angostas: la marca no se parte y el nombre (ya en el saludo) cede su lugar */
.barra-marca strong { white-space: nowrap; }
@media (max-width: 519px) { .barra-nombre { display: none; } .tile-desc { -webkit-line-clamp: 3; line-clamp: 3; } }
