/* PiN Admin (prototipo) — tokens reales extraídos de los sistemas actuales:
   admin v2 (--pin-color-*), página web (.button_gradient, fondo #F0F0F0) y admin v1.
   Ver 00_Investigacion/02_Mapa_Sistemas_Y_Conexiones.md §5 */
:root {
  --pin-charcoal: #2d2926;
  --pin-dark: #1f1e1e;
  --pin-red: #ee2737;
  --pin-red-2: #e92639;
  --pin-magenta: #910e55;
  --pin-magenta-2: #890c59;
  --pin-maroon: #56092c;
  --pin-turquoise: #26ddd1;
  --pin-orange: #ff8000;
  --pin-orange-soft: #ffb950;
  --pin-green: #1dc228;
  --pin-green-ok: #53cf05;
  --pin-blue: #2664dd;
  --pin-violet: #a048f8;
  --pin-gray: #707070;
  --pin-silver: #bebebe;
  --pin-bg: #f0f0f0;
  --pin-card: #ffffff;
  --pin-line: #e3e0de;
  --pin-material-red: #f44336;
  --grad-brand: linear-gradient(135deg, #e92639, #910e55);
  --shadow-card: 0 1px 3px rgba(45, 41, 38, .10), 0 6px 18px rgba(45, 41, 38, .06);
  --r-card: 12px;
  --r-input: 10px;
  --r-pill: 30px;
  --font-title: "Montserrat", "Segoe UI", system-ui, sans-serif;
  --font-body: "Open Sans", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--pin-bg); color: var(--pin-charcoal);
  font-family: var(--font-body); font-size: 14.5px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-title); line-height: 1.2; margin: 0; }
a { color: var(--pin-magenta-2); }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid rgba(38, 100, 221, .55); outline-offset: 2px; border-radius: 4px; }
::selection { background: #f3c3d4; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #c9c4c1; border-radius: 6px; border: 2px solid var(--pin-bg); }
.skip-link { position: absolute; left: -999px; top: 0; background: #fff; padding: .5rem 1rem; z-index: 99; }
.skip-link:focus { left: .5rem; top: .5rem; }

/* ---------- Botones (pastilla como la página web PiN) ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem; border: 0;
  border-radius: var(--r-pill); padding: .55rem 1.15rem;
  font-weight: 700; font-size: .85rem; text-decoration: none; white-space: nowrap;
}
.btn-brand { background: var(--grad-brand); color: #fff; }
.btn-brand:hover { filter: brightness(1.08); }
.btn-dark { background: var(--pin-charcoal); color: #fff; }
.btn-dark:hover { background: #3d3b3b; }
.btn-ghost { background: #fff; color: var(--pin-charcoal); border: 1px solid var(--pin-line); }
.btn-ghost:hover { border-color: var(--pin-silver); background: #faf9f8; }
.btn-sm { padding: .35rem .8rem; font-size: .78rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem; border-radius: var(--r-pill);
  padding: .15rem .6rem; font-size: .72rem; font-weight: 700; letter-spacing: .01em;
}
.chip::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
.chip-ok { background: #e8f8e0; color: #256b0d; }
.chip-warn { background: #fff3e0; color: #8a5200; }
.chip-bad { background: #fde8ea; color: #9b1220; }
.chip-info { background: #e4edfd; color: #1c4aa3; }
.chip-neutral { background: #efedec; color: #5d5855; }
.chip-brand { background: #fbe4ee; color: var(--pin-magenta); }
.tag {
  display: inline-block; border-radius: 6px; padding: .08rem .45rem;
  font-size: .72rem; font-weight: 700; color: #fff;
}

/* ---------- Marco del admin (sidebar oscuro tipo admin v2) ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100dvh; }
.sidebar {
  background: var(--pin-dark); color: #e9e6e4; position: sticky; top: 0;
  height: 100dvh; overflow-y: auto; padding: 1rem .8rem 1.4rem;
  display: flex; flex-direction: column; gap: .2rem;
}
.brand { display: flex; align-items: center; gap: .65rem; padding: .35rem .5rem 1rem; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px; background: var(--pin-charcoal);
  display: grid; place-items: center; flex: none; border: 1px solid #3a3633;
}
.brand-name { font-family: var(--font-title); font-weight: 800; font-size: 1.18rem; color: #fff; letter-spacing: .01em; }
.brand-name em { font-style: normal; color: var(--pin-red); }
.brand-sub { font-size: .7rem; color: #b6b0ac; margin-top: -.15rem; }
.nav-group { margin: .85rem .5rem .3rem; font-size: .68rem; font-weight: 700; letter-spacing: .09em; color: #9a938e; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: .6rem; padding: .52rem .65rem;
  border-radius: 9px; color: #d9d4d1; text-decoration: none; font-size: .88rem; font-weight: 600;
}
.nav-item svg { flex: none; opacity: .85; }
.nav-item:hover { background: #2c2927; color: #fff; }
.nav-item.is-active { background: var(--grad-brand); color: #fff; }
.nav-badge { margin-left: auto; background: #3a3633; color: #f2c14e; border-radius: 999px; font-size: .68rem; font-weight: 800; padding: .05rem .42rem; }
.nav-item.is-active .nav-badge { background: rgba(255,255,255,.22); color: #fff; }
.sidebar-foot { margin-top: auto; padding: .8rem .5rem 0; border-top: 1px solid #33302e; font-size: .72rem; color: #9a938e; }
.proto-badge {
  display: inline-block; border: 1px dashed #f2c14e; color: #f2c14e; border-radius: 6px;
  padding: .1rem .45rem; font-size: .66rem; font-weight: 800; letter-spacing: .06em;
}
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.94);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--pin-line);
  display: flex; align-items: center; gap: 1rem; padding: .65rem 1.4rem;
}
.topbar-title { font-size: 1.02rem; font-weight: 700; }
.topbar-crumb { font-size: .76rem; color: var(--pin-gray); }
.searchbox {
  margin-left: auto; display: flex; align-items: center; gap: .5rem;
  background: #f4f2f1; border: 1px solid var(--pin-line); border-radius: var(--r-pill);
  padding: .42rem .9rem; min-width: min(320px, 38vw);
}
.searchbox input { border: 0; background: transparent; outline: none; width: 100%; font-size: .86rem; color: var(--pin-charcoal); }
.userbox { display: flex; align-items: center; gap: .65rem; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--grad-brand); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: .8rem; flex: none;
  font-family: var(--font-title);
}
.user-meta { line-height: 1.15; }
.user-meta b { font-size: .84rem; display: block; }
.user-meta span { font-size: .72rem; color: var(--pin-magenta-2); font-weight: 700; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--pin-line);
  background: #fff; display: grid; place-items: center; color: var(--pin-charcoal); position: relative;
}
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--pin-red); border: 2px solid #fff; }
.content { padding: 1.15rem 1.4rem 2.4rem; max-width: 1480px; width: 100%; margin: 0 auto; }
.menu-toggle { display: none; }

/* ---------- Vistas: encabezado, KPI, tarjetas ---------- */
.view-head { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-bottom: .95rem; }
.view-head h1 { font-size: 1.42rem; font-weight: 800; letter-spacing: -.01em; }
.view-actions { margin-left: auto; display: flex; gap: .55rem; flex-wrap: wrap; }
.origin-note { font-size: .74rem; color: #8a847f; margin-top: .35rem; }
.origin-note code { background: #e9e5e3; border-radius: 4px; padding: .05rem .32rem; font-size: .72rem; }
.card { background: var(--pin-card); border: 1px solid var(--pin-line); border-radius: var(--r-card); box-shadow: var(--shadow-card); }
.card-pad { padding: 1.05rem 1.15rem; }
.card h3 { font-size: .98rem; font-weight: 700; }
.card-sub { font-size: .8rem; color: #6f6a67; margin-top: .15rem; }
.grid { display: grid; gap: 1rem; }
.grid-kpis { grid-template-columns: repeat(auto-fit, minmax(212px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.kpi { padding: .92rem 1rem; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -20px; top: -20px; width: 60px; height: 60px; border-radius: 50%; background: var(--kpi-soft, #fbe4ee); opacity: .65; }
.kpi-label, .kpi-value, .kpi-delta { position: relative; z-index: 1; padding-right: 2.1rem; }
.kpi-label { font-size: .72rem; font-weight: 700; color: #6f6a67; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-family: var(--font-title); font-size: clamp(1.32rem, 1.8vw, 1.58rem); font-weight: 800; margin: .16rem 0 .04rem; white-space: nowrap; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: .78rem; font-weight: 700; }
.kpi-delta.up { color: #1e7a0a; } .kpi-delta.down { color: #b1111e; } .kpi-delta.flat { color: #6f6a67; }
.kpi-icon { position: absolute; right: .8rem; top: .8rem; z-index: 1; color: var(--kpi-color, var(--pin-magenta)); }
.section-title { display: flex; align-items: baseline; gap: .7rem; margin: 1.4rem 0 .7rem; }
.section-title h2 { font-size: 1.12rem; font-weight: 800; }
.section-title span { font-size: .8rem; color: #8a847f; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; font-size: .78rem; color: #5d5855; margin-top: .65rem; }
.legend i { width: .62rem; height: .62rem; border-radius: 3px; display: inline-block; margin-right: .32rem; }
canvas.chart { width: 100%; height: auto; display: block; margin-top: .55rem; }
.activity { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.activity li { display: flex; gap: .65rem; font-size: .86rem; }
.activity time { color: #8a847f; font-size: .76rem; white-space: nowrap; padding-top: .12rem; }
.alert-row { display: flex; gap: .7rem; align-items: start; padding: .65rem .8rem; border-radius: 9px; background: #fff8ec; border: 1px solid #f0dfba; font-size: .85rem; }
.alert-row.bad { background: #fdf0f1; border-color: #f3c6cb; }
.alert-row.info { background: #eef4fe; border-color: #cfdef9; }

/* ---------- Tablas, filtros, formularios ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--pin-line); }
.field { display: grid; gap: .28rem; font-size: .8rem; font-weight: 700; color: #5d5855; }
.field input, .field select, .field textarea, .input {
  border: 1px solid #cfc9c6; border-radius: var(--r-input); padding: .52rem .75rem;
  font: inherit; font-weight: 400; color: var(--pin-charcoal); background: #fff; min-width: 0;
}
.field input:focus, .field select:focus, .input:focus { border-color: var(--pin-magenta-2); outline: 3px solid rgba(137,12,89,.15); }
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: .87rem; }
table.data th {
  text-align: left; font-family: var(--font-title); font-size: .72rem; letter-spacing: .05em;
  text-transform: uppercase; color: #6f6a67; padding: .65rem .9rem; border-bottom: 2px solid var(--pin-line);
  white-space: nowrap; background: #fbfafa;
}
table.data th button { background: none; border: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; padding: 0; }
table.data td { padding: .55rem .9rem; border-bottom: 1px solid #efecea; vertical-align: middle; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: #fdf3f6; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th.num { text-align: right; }
.cell-main { font-weight: 700; }
.cell-sub { font-size: .76rem; color: #8a847f; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: .8rem; }
.pager { display: flex; gap: .5rem; align-items: center; padding: .7rem 1rem; font-size: .82rem; color: #6f6a67; }
.pager b { color: var(--pin-charcoal); }
.progress { height: 8px; border-radius: 99px; background: #eee9e7; overflow: hidden; min-width: 90px; }
.progress > i { display: block; height: 100%; background: var(--grad-brand); border-radius: 99px; }
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs button {
  border: 1px solid var(--pin-line); background: #fff; border-radius: var(--r-pill);
  padding: .42rem .95rem; font-weight: 700; font-size: .82rem; color: #5d5855;
}
.tabs button[aria-selected="true"] { background: var(--pin-charcoal); color: #fff; border-color: var(--pin-charcoal); }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; background: #d8d2cf; border-radius: 99px; transition: .18s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + i { background: var(--pin-magenta-2); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 3px solid rgba(38,100,221,.55); outline-offset: 2px; }

/* ---------- Kanban (prospectos / proyectos / tickets) ---------- */
.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(225px, 1fr)); gap: .85rem; align-items: start; }
.kanban-col { background: #e9e6e4; border-radius: var(--r-card); padding: .75rem; }
.kanban-col h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; display: flex; justify-content: space-between; color: #5d5855; margin-bottom: .65rem; }
.kanban-card { background: #fff; border: 1px solid var(--pin-line); border-radius: 9px; padding: .7rem .8rem; margin-bottom: .6rem; box-shadow: 0 1px 3px rgba(45,41,38,.07); }
.kanban-card b { font-size: .87rem; display: block; }
.kanban-card p { margin: .2rem 0 .45rem; font-size: .79rem; color: #6f6a67; }
.kanban-meta { display: flex; justify-content: space-between; gap: .5rem; font-size: .74rem; color: #8a847f; align-items: center; }

/* ---------- Drawer de detalle, toast, modal ---------- */
.drawer-veil { position: fixed; inset: 0; background: rgba(31,30,30,.45); z-index: 50; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100dvh; width: min(460px, 94vw); background: #fff;
  z-index: 51; box-shadow: -12px 0 32px rgba(31,30,30,.22); overflow-y: auto; padding: 1.2rem 1.25rem 2rem;
}
.drawer h2 { font-size: 1.15rem; font-weight: 800; padding-right: 2.2rem; }
.drawer-close { position: absolute; top: .9rem; right: .9rem; }
.kv { display: grid; grid-template-columns: 138px 1fr; gap: .45rem .8rem; font-size: .87rem; margin: 1rem 0; }
.kv dt { color: #8a847f; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; padding-top: .12rem; }
.kv dd { margin: 0; }
.drawer-actions { display: flex; gap: .55rem; flex-wrap: wrap; margin-top: 1.1rem; }
#toast-root { position: fixed; bottom: 1.1rem; right: 1.1rem; z-index: 80; display: grid; gap: .5rem; }
.toast { background: var(--pin-charcoal); color: #fff; border-radius: 10px; padding: .7rem 1rem; font-size: .85rem; box-shadow: var(--shadow-card); max-width: 360px; }
.toast b { color: #f7b2c8; }

/* ---------- Login (réplica modernizada del login actual) ---------- */
.login-shell { min-height: 100dvh; display: grid; grid-template-columns: minmax(380px, 44%) 1fr; }
.login-brand { background: var(--pin-dark); color: #fff; padding: 3rem clamp(2rem, 5vw, 4rem); display: flex; flex-direction: column; }
.login-brand .brand { padding-left: 0; }
.login-claim { margin-top: auto; }
.login-claim h1 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); font-weight: 800; line-height: 1.14; }
.login-claim h1 span { color: var(--pin-red); }
.login-claim p { color: #cfc9c6; max-width: 46ch; }
.login-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 2rem; }
.login-stats b { font-family: var(--font-title); font-size: 1.25rem; display: block; }
.login-stats span { font-size: .72rem; color: #a49d99; text-transform: uppercase; letter-spacing: .06em; }
.login-side { display: grid; place-items: center; padding: 2rem 1.2rem; }
.login-box {
  width: min(460px, 100%); background: #fff; border-radius: 14px; border: 1px solid var(--pin-line);
  box-shadow: 0 10px 34px rgba(45,41,38,.10); padding: 2rem 2rem 1.5rem;
}
.login-box h2 { font-size: 1.3rem; font-weight: 800; text-align: center; }
.login-box .sub { text-align: center; color: #6f6a67; font-size: .87rem; margin: .4rem 0 1.3rem; }
.login-form { display: grid; gap: .9rem; }
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .6rem; }
.role-grid button {
  border: 1px solid var(--pin-line); background: #fbfafa; border-radius: 9px; padding: .55rem .6rem;
  font-size: .79rem; font-weight: 700; color: var(--pin-charcoal); text-align: left;
}
.role-grid button:hover { border-color: var(--pin-magenta-2); background: #fdf3f6; }
.role-grid small { display: block; font-weight: 400; color: #8a847f; font-size: .7rem; }
.login-note { font-size: .76rem; color: #8a847f; text-align: center; margin-top: 1.1rem; }
.pass-wrap { position: relative; }
.pass-wrap button { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); border: 0; background: none; color: #8a847f; padding: .4rem; }

/* ---------- Contenido Jamstack: preview webview ---------- */
.phone {
  width: 250px; margin: 0 auto; border: 9px solid var(--pin-charcoal); border-radius: 30px;
  overflow: hidden; background: #fff; box-shadow: var(--shadow-card);
}
.phone-head { background: var(--grad-brand); color: #fff; padding: .9rem .9rem .7rem; font-family: var(--font-title); font-weight: 800; }
.phone-head small { display: block; font-weight: 600; font-family: var(--font-body); font-size: .7rem; opacity: .9; }
.phone-body { padding: .75rem; display: grid; gap: .55rem; background: #f7f5f4; min-height: 330px; }
.phone-card { background: #fff; border-radius: 9px; padding: .6rem .7rem; font-size: .76rem; border: 1px solid #eee9e7; }
.phone-card b { font-size: .8rem; }
.phone-tabs { display: flex; justify-content: space-around; background: #fff; border-top: 1px solid #eee9e7; padding: .5rem .2rem; font-size: .62rem; color: #8a847f; text-align: center; }
.phone-tabs .on { color: var(--pin-magenta); font-weight: 800; }
.perm-matrix td, .perm-matrix th { text-align: center; }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: left; }
.health-dot { width: .6rem; height: .6rem; border-radius: 50%; display: inline-block; }
.empty-state { padding: 2.2rem 1rem; text-align: center; color: #8a847f; font-size: .9rem; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 262px; z-index: 60; transform: translateX(-105%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 14px 0 34px rgba(0,0,0,.3); }
  .menu-toggle { display: grid; }
  .searchbox { display: none; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { padding: 1.6rem; }
  .login-claim { margin-top: 1.6rem; }
  .user-meta { display: none; }
  .content { padding: 1rem .8rem 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
