/* ==========================================================================
   Domina tu Sector — Portal de cliente (app-like)
   Prefijo de clases nuevas: .pt-*  · usa tokens + componentes (no los redefine)
   ========================================================================== */

/* El portal ocupa la franja entre header y footer, sobre fondo profundo. */
.page-template-page-portal #main {
  background:
    radial-gradient(1100px 520px at 88% -8%, rgba(46, 232, 105, .07), transparent 60%),
    var(--bg-deep);
}

/* ==========================================================================
   1. ACCESO (login)
   ========================================================================== */
.pt-login {
  position: relative;
  min-height: clamp(560px, 78vh, 860px);
  display: grid;
  place-items: center;
  padding: var(--section-y) var(--pad-x);
  overflow: clip;
}
.pt-login__bg {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(680px 420px at 18% 12%, rgba(46, 232, 105, .12), transparent 62%),
    radial-gradient(720px 520px at 86% 96%, rgba(46, 232, 105, .07), transparent 60%);
  -webkit-mask-image: linear-gradient(#000, #000);
}
.pt-login__bg::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(540px 420px at 50% 38%, #000, transparent 72%);
          mask-image: radial-gradient(540px 420px at 50% 38%, #000, transparent 72%);
  opacity: .5;
}
.pt-login__card {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px;
  padding: clamp(26px, 4vw, 42px);
  box-shadow: var(--shadow);
}
.pt-login__brand { text-align: center; margin-bottom: 22px; }
.pt-login__sub { color: var(--ink-mute); font-size: var(--fs-xs); letter-spacing: .04em; margin-top: 8px; }
.pt-login__sub strong { color: var(--ink-soft); }
.pt-login__icon {
  margin: 4px auto 18px;
  width: 60px; height: 60px;
  box-shadow: var(--glow-sm);
}
.pt-login__title {
  font-family: var(--font-display); font-size: clamp(1.5rem, 3.4vw, 2rem);
  text-align: center; line-height: 1.1; margin-bottom: 8px;
}
.pt-login__lead {
  text-align: center; color: var(--ink-soft); font-size: var(--fs-sm);
  max-width: 34ch; margin: 0 auto 22px; line-height: 1.6;
}
.pt-login__error { margin-bottom: 18px; }
.pt-login__error.callout {
  background: rgba(255, 106, 106, .08);
  border-color: rgba(255, 106, 106, .32);
  color: var(--ink-soft);
}
.pt-login__error .dts-ico { color: var(--danger); }
.pt-login__form { margin-top: 4px; }
.pt-login__remember {
  display: flex; align-items: center; gap: 9px;
  font-size: var(--fs-sm); color: var(--ink-soft);
  margin: 4px 0 18px; cursor: pointer; user-select: none;
}
.pt-login__remember input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.pt-login__forgot {
  display: block; text-align: center; margin-top: 18px;
  font-size: var(--fs-sm);
}

/* ==========================================================================
   2. SHELL (dashboard: sidebar + main)
   ========================================================================== */
.pt-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: clamp(20px, 3vw, 36px);
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(22px, 4vw, 44px) var(--pad-x) clamp(56px, 7vw, 96px);
  align-items: start;
}

/* ---- Sidebar ----------------------------------------------------------- */
.pt-side {
  position: sticky; top: 92px;
  display: flex; flex-direction: column; gap: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 16px;
}
.pt-side__brand { padding: 4px 6px 2px; }
.pt-side__brand .brand__mark { font-size: .82rem; }

.pt-side__user {
  display: flex; align-items: center; gap: 11px;
  padding: 12px; border-radius: var(--r);
  background: var(--bg-deep); border: 1px solid var(--line);
}
.pt-avatar {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  font-family: var(--font-display); font-size: 1.05rem;
  color: var(--brand-ink); background: var(--brand);
  box-shadow: var(--glow-sm);
}
.pt-side__usermeta { display: grid; gap: 2px; min-width: 0; }
.pt-side__company {
  font-size: var(--fs-sm); color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pt-side__hello { font-size: var(--fs-xs); color: var(--ink-mute); }

/* ---- Nav --------------------------------------------------------------- */
.pt-nav { display: grid; gap: 4px; }
.pt-nav__item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: var(--r-sm);
  color: var(--ink-soft); font-weight: 600; font-size: var(--fs-sm);
  transition: color var(--t) var(--ease), background var(--t) var(--ease);
}
.pt-nav__item:hover { color: var(--ink); background: rgba(242, 242, 242, .04); }
.pt-nav__ico { display: inline-grid; place-items: center; }
.pt-nav__ico .dts-ico { width: 19px; height: 19px; }
.pt-nav__item.is-active {
  color: var(--brand); background: rgba(46, 232, 105, .08);
}
.pt-nav__item.is-active::before {
  content: ""; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 0 3px 3px 0;
  background: var(--brand); box-shadow: var(--glow-sm);
}
.pt-nav__logout {
  margin-top: 8px; padding-top: 14px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  color: var(--ink-mute);
}
.pt-nav__logout:hover { color: var(--danger); background: rgba(255, 106, 106, .06); }

/* ---- Main panel -------------------------------------------------------- */
.pt-main { min-width: 0; display: grid; gap: clamp(20px, 3vw, 30px); align-content: start; }

.pt-head { display: grid; gap: 10px; }
.pt-head .pill { justify-self: start; }
.pt-head__title { font-family: var(--font-display); font-size: var(--fs-h1); line-height: 1.05; }
.pt-head__lead { color: var(--ink-soft); font-size: var(--fs-lead); max-width: 60ch; line-height: 1.55; }

/* ==========================================================================
   3. RESUMEN — tarjetas de acceso rápido
   ========================================================================== */
.pt-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.pt-quick {
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
  text-align: left;
}
.pt-quick .icon-badge { flex: none; }
.pt-quick__body { display: grid; gap: 7px; min-width: 0; }
.pt-quick__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pt-quick__row .card__title { margin: 0; font-size: 1.08rem; }
.pt-quick__go {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: var(--r-pill);
  color: var(--ink-mute); border: 1px solid var(--line);
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease), transform var(--t) var(--ease);
}
.pt-quick:hover .pt-quick__go { color: var(--brand); border-color: var(--line-brand); transform: translateX(3px); }
.pt-callout a { color: var(--brand); font-weight: 700; white-space: nowrap; }

/* ==========================================================================
   4. FACTURAS
   ========================================================================== */
.pt-stats-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.pt-money { display: grid; gap: 10px; align-content: start; }
.pt-money__value { font-family: var(--font-display); }
.pt-money__value.is-danger { color: var(--danger); }
.pt-money .badge { justify-self: start; }

.pt-tablewrap { padding: 6px; }
.pt-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pt-invoices__num { font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.pt-invoices__amount { font-family: var(--font-display); white-space: nowrap; }
.pt-invoices__concept { color: var(--ink-soft); min-width: 180px; }
.pt-states { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.pt-col-pdf { text-align: right; white-space: nowrap; }
.pt-pdf-none { color: var(--ink-mute); }
.btn--sm { padding: .5em .85em; font-size: var(--fs-xs); }
.pt-synced {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ink-mute); font-size: var(--fs-xs);
}
.pt-synced .dts-ico { width: 15px; height: 15px; color: var(--ink-mute); }

/* ==========================================================================
   5. AUDITORÍAS
   ========================================================================== */
.pt-aud { display: grid; gap: clamp(18px, 2.6vw, 26px); }
.pt-aud__bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--r);
  background: var(--bg-elev); border: 1px solid var(--line);
}
.pt-aud__bar-label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-xs); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-mute);
}
.pt-aud__bar-label .dts-ico { width: 16px; height: 16px; color: var(--brand); }
.pt-aud__select { max-width: 230px; }
/* En desktop, el .seg sustituye al <select>; en móvil al revés (ver media query). */
.pt-aud__seg { flex-wrap: wrap; }

.pt-aud__panel { display: grid; gap: clamp(16px, 2.4vw, 24px); animation: pt-fade var(--t) var(--ease-out); }
.pt-aud__panel[hidden] { display: none; }

.pt-aud__panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.pt-aud__period { font-family: var(--font-display); font-size: var(--fs-h2); line-height: 1.05; }
.pt-aud__gen .dts-ico { width: 13px; height: 13px; }

.pt-aud__resumen { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.pt-aud__resumen p { color: var(--ink); font-size: var(--fs-lead); line-height: 1.55; }

/* KPIs */
.pt-kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.pt-kpi { gap: 8px; }
.pt-kpi__vs { color: var(--ink-mute); font-weight: 500; font-size: var(--fs-xs); margin-left: 2px; }

/* Bloques */
.pt-block { display: grid; gap: 16px; }
.pt-block__title { font-family: var(--font-body); font-weight: 700; font-size: var(--fs-h3); }
.pt-block__empty { color: var(--ink-mute); font-size: var(--fs-sm); }
.pt-checklist { gap: 11px; }
.pt-checklist li { font-size: var(--fs-body); }

/* Barras horizontales */
.pt-bars { display: grid; gap: 14px; }
.pt-bars__item {
  display: grid; grid-template-columns: minmax(110px, 0.9fr) minmax(0, 2.4fr) auto;
  gap: 14px; align-items: center;
}
.pt-bars__label { font-size: var(--fs-sm); color: var(--ink-soft); }
.pt-bars__track {
  position: relative; height: 12px; border-radius: var(--r-pill);
  background: var(--bg-deep); border: 1px solid var(--line); overflow: hidden;
}
.pt-bars__fill {
  display: block; height: 100%; width: 0;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--brand-2), var(--brand));
  box-shadow: var(--glow-sm);
  transition: width var(--t-slow) var(--ease-out);
}
.pt-bars.is-in .pt-bars__fill { width: var(--pt-bar); }
.pt-bars__value { font-family: var(--font-display); font-size: var(--fs-sm); color: var(--ink); text-align: right; min-width: 56px; }

@keyframes pt-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ==========================================================================
   6. ACCESOS
   ========================================================================== */
.pt-accesos__group { display: grid; gap: 14px; }
.pt-accesos__cat {
  font-family: var(--font-body); font-weight: 700; font-size: 1rem;
  letter-spacing: .04em; text-transform: uppercase; color: var(--ink-mute);
}
.pt-accesos__grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.pt-acceso { display: grid; gap: 14px; align-content: start; }
.pt-acceso__head { display: flex; align-items: flex-start; gap: 13px; }
.pt-acceso__id { display: grid; gap: 7px; min-width: 0; }
.pt-acceso__name { font-family: var(--font-body); font-weight: 700; font-size: 1.04rem; }
.pt-acceso__user { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pt-acceso__user-val {
  font-family: var(--font-display); font-size: .82rem; color: var(--ink-soft);
  background: var(--bg-deep); border: 1px solid var(--line);
  padding: 4px 9px; border-radius: var(--r-sm);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.pt-copy {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 5px 9px; border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 600; color: var(--ink-mute);
  border: 1px solid var(--line); background: var(--bg-deep);
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
  cursor: pointer;
}
.pt-copy .dts-ico { width: 14px; height: 14px; }
.pt-copy:hover { color: var(--brand); border-color: var(--line-brand); }
.pt-copy.is-copied { color: var(--brand); border-color: var(--line-brand); }
.pt-acceso__note { color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.55; }
.pt-acceso__open { justify-self: start; }

/* ==========================================================================
   7. ADMIN BAR + ESTADOS VACÍOS
   ========================================================================== */
.pt-adminbar { flex-wrap: wrap; }
.pt-adminbar__form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; min-width: 0; }
.pt-adminbar__form label { font-size: var(--fs-sm); color: var(--ink-soft); }
.pt-adminbar__sel { max-width: 360px; }

.pt-empty {
  display: grid; justify-items: center; text-align: center; gap: 14px;
  padding: clamp(40px, 7vw, 80px) 20px;
  background: var(--bg-elev); border: 1px dashed var(--line-strong); border-radius: var(--r-lg);
}
.pt-empty .icon-badge { width: 64px; height: 64px; }
.pt-empty__title { font-family: var(--font-display); font-size: var(--fs-h3); }
.pt-empty__text { color: var(--ink-soft); font-size: var(--fs-sm); max-width: 46ch; line-height: 1.6; }

.screen-reader-text {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

/* ==========================================================================
   8. RESPONSIVE — la sidebar pasa a pestañas horizontales (<900px)
   ========================================================================== */

/* En desktop, el <select> de auditorías queda oculto (manda el .seg). */
@media (min-width: 720px) {
  .pt-aud__bar:has(.pt-aud__seg) .pt-aud__select { display: none; }
}

@media (max-width: 900px) {
  .pt-shell { grid-template-columns: 1fr; gap: 18px; padding-top: 18px; }

  .pt-side {
    position: static; top: auto;
    flex-direction: row; align-items: center; gap: 12px;
    padding: 12px; overflow: hidden;
  }
  .pt-side__brand { display: none; }
  .pt-side__user { flex: none; padding: 8px 10px; }
  .pt-side__hello { display: none; }
  .pt-side__company { max-width: 130px; }

  /* Nav horizontal scrollable */
  .pt-nav {
    grid-auto-flow: column; grid-template-columns: none;
    gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    flex: 1; padding-bottom: 2px; scrollbar-width: none;
  }
  .pt-nav::-webkit-scrollbar { display: none; }
  .pt-nav__item {
    white-space: nowrap; padding: 9px 13px; flex: none;
    border: 1px solid var(--line); border-radius: var(--r-pill);
    background: var(--bg-deep);
  }
  .pt-nav__item.is-active { background: rgba(46, 232, 105, .1); border-color: var(--line-brand); }
  .pt-nav__item.is-active::before { display: none; }
  .pt-nav__label { font-size: var(--fs-xs); }

  .pt-nav__logout {
    margin-top: 0; padding: 9px 13px; border-top: 0;
    border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--bg-deep);
  }
}

@media (max-width: 560px) {
  .pt-side { flex-wrap: wrap; }
  .pt-side__user { width: 100%; }
  .pt-quick { grid-template-columns: auto 1fr; }
  .pt-quick__go { display: none; }
  .pt-bars__item { grid-template-columns: 1fr auto; grid-template-areas: "label value" "track track"; gap: 6px 12px; }
  .pt-bars__label { grid-area: label; }
  .pt-bars__value { grid-area: value; }
  .pt-bars__track { grid-area: track; }
  .pt-aud__panel-head { gap: 8px; }
}

/* ==========================================================================
   9. Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .pt-aud__panel { animation: none; }
  .pt-bars__fill { transition: none; }
  .pt-quick:hover .pt-quick__go { transform: none; }
}
