/* ==========================================================================
   DESIGN.md — Financiera Digitbank
   Arquetipo: Apple clean/spacious con superficies de cristal líquido
   Tipografía: Inter (400, 500, 600) · Tabular nums en cifras financieras
   ========================================================================== */

:root {
  --canvas: #0B0D12;
  --canvas-light: #F5F5F7;
  --surface: rgb(255 255 255 / 0.72);
  --surface-glass: rgb(255 255 255 / 0.08);
  --surface-raised: #FFFFFF;
  --hairline: rgb(0 0 0 / 0.08);
  --hairline-glass: rgb(255 255 255 / 0.18);

  --ink: #1D1D1F;
  --ink-muted: #6E6E73;
  --ink-on-dark: #F5F5F7;

  --accent: #C9A24B;
  --accent-soft: rgb(201 162 75 / 0.15);
  --accent-ink: #1D1608;

  --ok: #248A3D;
  --ok-soft: rgb(36 138 61 / 0.12);
  --warn: #B25E09;
  --warn-soft: rgb(178 94 9 / 0.12);
  --danger: #D70015;
  --danger-soft: rgb(215 0 21 / 0.12);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;
  --blur: 24px;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas-light);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
}

.num, td.num, th.num, .kpi-val {
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

[inert], [inert] * {
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}

/* ==========================================================================
   1. PANTALLA INICIAL — CRISTAL LÍQUIDO Y MONEDA 3D GIRANDO (PRD §4)
   ========================================================================== */
#vista-landing {
  position: relative;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink-on-dark);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 36px 20px 32px;
  overflow: hidden;
  isolation: isolate;
}

.liquid-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 22% 20%, rgb(201 162 75 / 0.18), transparent 46%),
    radial-gradient(circle at 78% 72%, rgb(255 255 255 / 0.08), transparent 52%),
    radial-gradient(circle at 50% 50%, rgb(28 34 48 / 0.9), #0B0D12 75%);
  filter: blur(20px);
}

.landing-top {
  text-align: center;
  padding: 12px 26px;
  border-radius: var(--r-pill);
  background: var(--surface-glass);
  backdrop-filter: blur(var(--blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.4);
  border: 1px solid var(--hairline-glass);
}

.brand-wordmark {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  color: var(--ink-on-dark);
}

.brand-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: rgb(245 245 247 / 0.66);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Escena 3D de la moneda de Digitbank girando a velocidad suave */
.coin-stage {
  perspective: 1100px;
  margin: 28px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.coin-3d {
  width: 240px;
  height: 240px;
  position: relative;
  transform-style: preserve-3d;
  animation: giroMoneda 12s linear infinite;
  filter: drop-shadow(0 22px 48px rgb(201 162 75 / 0.34));
}

@media (prefers-reduced-motion: reduce) {
  .coin-3d {
    animation-duration: 36s;
  }
}

@keyframes giroMoneda {
  0%   { transform: rotateY(0deg) rotateX(5deg); }
  50%  { transform: rotateY(180deg) rotateX(-5deg); }
  100% { transform: rotateY(360deg) rotateX(5deg); }
}

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.coin-face.front {
  transform: translateZ(3px);
}

.coin-face.back {
  transform: rotateY(180deg) translateZ(3px);
}

.coin-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.coin-mini-img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.landing-actions {
  width: 100%;
  max-width: 440px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--surface-glass);
  backdrop-filter: blur(var(--blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.4);
  border: 1px solid var(--hairline-glass);
}

.landing-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: center;
  font-size: 12.5px;
  color: rgb(245 245 247 / 0.62);
}

.link-btn {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 6px;
}

/* ==========================================================================
   2. BOTONES Y CONTROLES (MÍNIMO 44PX TÁCTIL)
   ========================================================================== */
.btn {
  appearance: none;
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 46px;
  padding: 11px 20px;
  border-radius: var(--r-pill);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s ease, background-color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.985);
}

.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.btn-glass {
  background: rgb(255 255 255 / 0.12);
  color: var(--ink-on-dark);
  border-color: var(--hairline-glass);
  backdrop-filter: blur(16px);
}

.btn-dark {
  background: var(--ink);
  color: var(--ink-on-dark);
}

.btn-outline {
  background: var(--surface-raised);
  color: var(--ink);
  border-color: var(--hairline);
}

.btn-sm {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 13px;
}

/* ==========================================================================
   3. DIÁLOGOS NATIVOS (<dialog closedby="any">)
   ========================================================================== */
dialog {
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 0;
  width: min(94vw, 620px);
  max-height: 90dvh;
  background: var(--surface-raised);
  color: var(--ink);
  box-shadow: 0 24px 64px rgb(0 0 0 / 0.22);
}

dialog::backdrop {
  background: rgb(11 13 18 / 0.62);
  backdrop-filter: blur(8px);
}

.dialog-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--surface-raised);
  z-index: 2;
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.dialog-body {
  padding: 22px 24px;
  overflow-y: auto;
}

/* ==========================================================================
   4. FORMULARIOS CON VALIDACIÓN MODERNA (:user-invalid / field-sizing)
   ========================================================================== */
.field {
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}

.hint {
  display: block;
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 5px;
}

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--surface-raised);
  color: var(--ink);
  font: inherit;
}

textarea {
  field-sizing: content;
  min-height: 76px;
}

input:user-invalid, select:user-invalid {
  border-color: var(--danger);
  background: var(--danger-soft);
}

input:user-valid {
  border-color: var(--ok);
}

.error-msg {
  display: none;
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
}

input:user-invalid + .error-msg {
  display: block;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 680px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ==========================================================================
   5. SHELL DE PANELES (CLIENTE / ADMIN / SUPER ADMIN)
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  backdrop-filter: blur(var(--blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.4);
  border-bottom: 1px solid var(--hairline);
}

.app-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  font-size: 14px;
}

.coin-mini {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #F4E0A4, #C9A24B 65%, #7E5E1B);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0;
}

.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.nav-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.nav-pills button {
  appearance: none;
  border: 1px solid var(--hairline);
  background: var(--surface-raised);
  color: var(--ink-muted);
  padding: 9px 16px;
  border-radius: var(--r-pill);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  min-height: 40px;
}

.nav-pills button.active {
  background: var(--ink);
  color: var(--ink-on-dark);
  border-color: var(--ink);
}

/* Superficies y tarjetas con borde hairline */
.card {
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 16px 18px;
}

.kpi.accent {
  background: var(--canvas);
  color: var(--ink-on-dark);
  border-color: var(--canvas);
}

.kpi.accent .kpi-label {
  color: rgb(245 245 247 / 0.68);
}

.kpi-label {
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.kpi-val {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Tablas limpias */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface-raised);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th, td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  white-space: nowrap;
}

th {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  background: #FAFAFC;
}

tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  background: var(--canvas-light);
  color: var(--ink-muted);
}

.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.gold { background: var(--accent-soft); color: var(--accent-ink); }

.banner-msg {
  padding: 12px 16px;
  border-radius: var(--r-sm);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid var(--hairline);
}

.banner-msg.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.banner-msg.err { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
