/* =====================================================================
   SYNORIS — SYNORIS Office, backoffice y autenticación
   ===================================================================== */

/* ══════════════════════════════════════════════ AUTENTICACIÓN ══ */
.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}
@media (min-width: 960px) {
  .auth { grid-template-columns: 1fr 1.05fr; }
}

.auth__aside {
  display: none;
  background: var(--navy);
  color: rgba(255, 255, 255, .72);
  padding: clamp(2.5rem, 5vw, 4.5rem);
  position: relative;
  overflow: hidden;
  flex-direction: column;
  justify-content: space-between;
}
@media (min-width: 960px) { .auth__aside { display: flex; } }

.auth__aside::before {
  content: '';
  position: absolute;
  top: -20%; right: -25%;
  width: 90%; height: 140%;
  background: linear-gradient(101deg, transparent 49.5%, rgba(205,183,141,.35) 49.8%, rgba(205,183,141,.35) 50.2%, transparent 50.5%);
  pointer-events: none;
}
.auth__aside > * { position: relative; z-index: 1; }
.auth__quote {
  font-family: var(--font-display);
  font-size: var(--step-2);
  line-height: 1.3;
  color: var(--white);
  max-width: 24rem;
}
.auth__meta {
  font-size: var(--step--1);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(255,255,255,.42);
}

.auth__main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2rem, 6vw, 4rem) clamp(1.25rem, 5vw, 3rem);
  background: var(--ivory);
}
.auth__form { width: 100%; max-width: 27rem; }
.auth__logo { display: inline-flex; align-items: center; gap: .55rem; margin-bottom: var(--sp-7); }
.auth__logo svg { width: 2.1rem; }
.auth__logo span {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: .34em;
  text-indent: .34em;
  color: var(--navy);
}
.auth__title { font-size: var(--step-2); margin-bottom: var(--sp-2); }
.auth__sub { color: var(--text-muted); margin-bottom: var(--sp-6); }
.auth__foot {
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  font-size: var(--step--1);
  color: var(--text-muted);
  text-align: center;
}
.auth__foot a { font-weight: 500; color: var(--navy); }
.auth__foot a:hover { color: var(--gold-600); }


/* ══════════════════════════════════════════════ SHELL DE PANEL ══ */
.shell {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: 1fr;
}
@media (min-width: 1024px) {
  .shell { grid-template-columns: 16.5rem 1fr; }
}

/* ------------------------------------------------------- barra lateral */
.side {
  background: var(--navy);
  color: rgba(255,255,255,.66);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  width: min(17rem, 82vw);
  z-index: 200;
  transform: translateX(-102%);
  transition: transform .35s var(--ease);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.side.is-open { transform: none; box-shadow: var(--shadow-lg); }
@media (min-width: 1024px) {
  .side { position: sticky; top: 0; height: 100dvh; width: auto; transform: none; }
}

.side__head {
  padding: var(--sp-6) var(--sp-5) var(--sp-5);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.side__logo { display: inline-flex; align-items: center; gap: .55rem; color: var(--white); }
.side__logo:hover { color: var(--white); }
.side__logo svg { width: 1.85rem; }
.side__logo span {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: .3em;
  text-indent: .3em;
}
.side__badge {
  display: block;
  margin-top: var(--sp-3);
  font-size: .64rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold);
}

.side__nav { padding: var(--sp-5) var(--sp-3); flex: 1; }
.side__group {
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(255,255,255,.32);
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
}
.side__link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: .68rem var(--sp-4);
  border-radius: var(--radius);
  color: rgba(255,255,255,.66);
  font-size: var(--step-0);
  transition: background .2s var(--ease), color .2s var(--ease);
  position: relative;
}
.side__link:hover { background: rgba(255,255,255,.06); color: var(--white); }
.side__link.is-active { background: rgba(205,183,141,.14); color: var(--white); }
.side__link.is-active::before {
  content: '';
  position: absolute;
  left: 0; top: 22%; bottom: 22%;
  width: 2px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}
.side__link svg { width: 1.05rem; height: 1.05rem; flex: none; opacity: .85; }
.side__count {
  margin-left: auto;
  background: var(--gold);
  color: var(--navy);
  font-size: .65rem;
  font-weight: 700;
  padding: .12em .5em;
  border-radius: 999px;
  min-width: 1.35rem;
  text-align: center;
}

.side__foot {
  padding: var(--sp-5);
  border-top: 1px solid rgba(255,255,255,.08);
}
.side__user { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.side__avatar {
  width: 2.2rem; height: 2.2rem;
  border-radius: 50%;
  background: rgba(205,183,141,.2);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: .95rem;
  flex: none;
}
.side__uname { color: var(--white); font-size: var(--step--1); font-weight: 500; line-height: 1.3; }
.side__umail { font-size: .7rem; color: rgba(255,255,255,.4); word-break: break-all; line-height: 1.3; }

.side-scrim {
  position: fixed;
  inset: 0;
  background: rgba(11,19,34,.45);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease);
}
.side-scrim.is-open { opacity: 1; pointer-events: auto; }
@media (min-width: 1024px) { .side-scrim { display: none; } }

/* ---------------------------------------------------------- contenido */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(247,245,241,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-4) clamp(1.15rem, 4vw, 2.5rem);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.topbar__title {
  font-family: var(--font-display);
  font-size: var(--step-1);
  color: var(--navy);
  margin: 0;
  line-height: 1.2;
}
.topbar__sub { font-size: var(--step--1); color: var(--text-muted); margin: 0; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }

.side-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 2.4rem; height: 2.4rem;
  align-items: center;
  cursor: pointer;
  flex: none;
}
.side-toggle span { display: block; width: 1.05rem; height: 1.5px; background: var(--navy); }
@media (min-width: 1024px) { .side-toggle { display: none; } }

.content { padding: clamp(1.5rem, 4vw, 2.75rem) clamp(1.15rem, 4vw, 2.5rem) var(--sp-8); flex: 1; }
.content__section { margin-bottom: clamp(2rem, 4vw, 3rem); }
.content__section:last-child { margin-bottom: 0; }

.page-head { margin-bottom: var(--sp-6); }
.page-head h2 { margin-bottom: var(--sp-2); }


/* ═════════════════════════════════════════════ TARJETAS DE DATOS ══ */
.kpis {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
}
.kpi--accent { border-color: var(--gold); background: linear-gradient(180deg, var(--gold-100), var(--white) 65%); }
.kpi--dark { background: var(--navy); border-color: var(--navy); }
.kpi--dark .kpi__label { color: rgba(255,255,255,.5); }
.kpi--dark .kpi__value { color: var(--white); }
.kpi--dark .kpi__hint  { color: rgba(255,255,255,.45); }

.kpi__label {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.kpi__value {
  font-family: var(--font-display);
  font-size: var(--step-2);
  line-height: 1.05;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.kpi__unit { font-family: var(--font-ui); font-size: .7em; color: var(--text-muted); margin-left: .25em; }
.kpi__hint { font-size: var(--step--1); color: var(--text-muted); margin-top: var(--sp-2); line-height: 1.45; }

/* Panel con cabecera */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.panel__head {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  background: var(--sand);
}
.panel__title {
  font-family: var(--font-ui);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--navy);
  margin: 0;
}
.panel__body { padding: var(--sp-5); }
.panel__body--flush { padding: 0; }
.panel .table-wrap { border: 0; border-radius: 0; }

/* Estado vacío */
.empty {
  padding: clamp(2.5rem, 6vw, 4rem) var(--sp-5);
  text-align: center;
  color: var(--text-muted);
}
.empty__mark {
  width: 2.6rem; height: 2.6rem;
  margin: 0 auto var(--sp-4);
  border: 1px solid var(--border);
  transform: rotate(45deg);
  display: grid;
  place-items: center;
}
.empty__mark span { transform: rotate(-45deg); color: var(--gold); font-size: 1.1rem; }
.empty h4 { font-size: var(--step-1); margin-bottom: var(--sp-2); }

/* Fila descriptiva clave / valor */
.dl { display: grid; gap: 0; }
.dl__row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--step-0);
}
.dl__row:last-child { border-bottom: 0; }
.dl__k { color: var(--text-muted); }
.dl__v { font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.dl__row--total { border-top: 1px solid var(--navy); border-bottom: 0; padding-top: var(--sp-4); }
.dl__row--total .dl__k, .dl__row--total .dl__v { font-weight: 600; color: var(--navy); font-size: var(--step-1); }

/* Barra de progreso (recuperación) */
.progress {
  height: 6px;
  background: var(--sand-200);
  border-radius: 999px;
  overflow: hidden;
  margin-top: var(--sp-3);
}
.progress__bar { height: 100%; background: var(--gold); border-radius: 999px; transition: width .8s var(--ease); }

/* Filtros */
.filters {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  align-items: flex-end;
}
.filters .field { margin-bottom: 0; min-width: 9rem; flex: 1 1 9rem; }
.filters .btn { flex: none; }

/* Paginación */
.pager {
  display: flex;
  gap: var(--sp-2);
  justify-content: center;
  align-items: center;
  padding: var(--sp-5);
  flex-wrap: wrap;
}
.pager a, .pager span {
  min-width: 2.2rem;
  padding: .4rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  font-size: var(--step--1);
  background: var(--surface);
}
.pager .is-current { background: var(--navy); color: var(--white); border-color: var(--navy); }
.pager .is-disabled { opacity: .4; pointer-events: none; }


/* ══════════════════════════════════════════ PANTALLA DE PAGO ══ */
.pay {
  display: grid;
  gap: clamp(1.5rem, 4vw, 2.5rem);
  grid-template-columns: 1fr;
  align-items: start;
}
@media (min-width: 900px) { .pay { grid-template-columns: 1fr 20rem; } }

.pay__qr {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  display: grid;
  place-items: center;
  min-height: 12rem;
}
.pay__qr canvas, .pay__qr img { border-radius: 4px; }

.pay__address {
  font-family: var(--font-mono);
  font-size: .82rem;
  background: var(--sand);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  word-break: break-all;
  line-height: 1.55;
  user-select: all;
}

.pay__status {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius);
  background: var(--sand);
  border: 1px solid var(--border);
  font-size: var(--step-0);
}
.pay__status--waiting  { background: var(--info-bg);     border-color: #cfdde8; color: var(--info); }
.pay__status--progress { background: var(--warning-bg);  border-color: #ecdcb9; color: var(--warning); }
.pay__status--done     { background: var(--positive-bg); border-color: #cfe3d7; color: var(--positive); }
.pay__status--error    { background: var(--negative-bg); border-color: #eed6d6; color: var(--negative); }

.spinner {
  width: 1.05rem; height: 1.05rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pay__steps { display: flex; flex-direction: column; gap: 0; }
.pay__step {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--step-0);
}
.pay__step:last-child { border-bottom: 0; }
.pay__step__n {
  width: 1.6rem; height: 1.6rem;
  border: 1px solid var(--gold);
  color: var(--gold-600);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .75rem;
  font-weight: 600;
  flex: none;
}

/* Aviso de red: el error más caro que puede cometer un usuario */
.net-warning {
  border: 1px solid var(--warning);
  background: var(--warning-bg);
  border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-5);
  font-size: var(--step--1);
  color: #6d5323;
  line-height: 1.6;
}
.net-warning strong { color: #4d3a15; }


/* ═════════════════════════════════════════ SELECCIÓN DE NIVEL ══ */
.pick {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}
.pick__item {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  cursor: pointer;
  transition: all .25s var(--ease);
  position: relative;
}
.pick__item:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: var(--shadow); }
.pick__item input { position: absolute; opacity: 0; }
.pick__item input:checked + .pick__body { color: inherit; }
.pick__item:has(input:checked) { border-color: var(--navy); box-shadow: 0 0 0 2px rgba(11,19,34,.08); }
.pick__code {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold-600);
  margin-bottom: var(--sp-2);
}
.pick__amount {
  font-family: var(--font-display);
  font-size: var(--step-2);
  color: var(--navy);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pick__meta { font-size: var(--step--1); color: var(--text-muted); margin-top: var(--sp-3); }


/* ═══════════════════════════════════════════════ CHAT DE TICKETS ══ */
.thread { display: flex; flex-direction: column; gap: var(--sp-4); }
.msg {
  max-width: 82%;
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius-lg);
  background: var(--sand);
  border: 1px solid var(--border);
  font-size: var(--step-0);
}
.msg--admin { align-self: flex-start; background: var(--white); border-left: 3px solid var(--gold); }
.msg--user  { align-self: flex-end; background: var(--navy); color: rgba(255,255,255,.85); border-color: var(--navy); }
.msg__meta { font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; opacity: .6; margin-bottom: var(--sp-2); }
.msg p:last-child { margin-bottom: 0; }
@media (max-width: 640px) { .msg { max-width: 94%; } }


/* ══════════════════════════════════════════════ CORTE SEMANAL ══ */
.cut-input {
  display: grid;
  grid-template-columns: 1fr 9rem;
  gap: var(--sp-4);
  align-items: center;
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border);
}
.cut-input:last-of-type { border-bottom: 0; }
.cut-input__name { font-weight: 500; color: var(--navy); }
.cut-input__meta { font-size: var(--step--1); color: var(--text-muted); }
.cut-input .input { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .cut-input { grid-template-columns: 1fr; gap: var(--sp-2); }
  .cut-input .input { text-align: left; }
}

/* Resumen previo al corte */
.preview-totals {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  padding: var(--sp-5);
  background: var(--sand);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.preview-totals .stat__value { font-size: var(--step-2); }

/* Aviso de acción irreversible */
.danger-zone {
  border: 1px solid var(--negative);
  background: var(--negative-bg);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
}
.danger-zone h4 { color: var(--negative); font-size: var(--step-0); margin-bottom: var(--sp-2); }
