:root {
  --black: #0F0F0F;
  --gray-900: #1A1A1A;
  --gray-800: #2E2E2E;
  --gray-600: #5C5C5C;
  --gray-400: #8C8C8C;
  --gray-300: #B5B5B5;
  --gray-200: #D6D6D6;
  --gray-100: #E8E8E8;
  --gray-50: #F4F4F2;
  --white: #FFFFFF;

  --accent: #1A4D8F;
  --accent-hover: #133A6D;
  --accent-light: #E8EFF8;
  --accent-08: rgba(26,77,143,0.08);

  --green: #1A7F37;
  --green-bg: #EBF5EE;
  --red: #C4262E;
  --red-bg: #FDF0F0;

  --radius: 4px;
  --radius-lg: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'DM Mono', 'SF Mono', 'Consolas', monospace;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.03);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* ── Login ──────────────────────────────────────────────────────────────── */

.login-wrapper {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--white);
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-logo-wrap {
  width: 48px;
  height: 48px;
  margin: 0 auto 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(26,77,143,0.25);
}

.login-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: brightness(10);
}

.login-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: 10px;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.login-sub {
  font-size: 15px;
  color: var(--gray-400);
  margin-bottom: 44px;
  line-height: 1.5;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 8px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 17px;
  font-family: var(--mono);
  letter-spacing: 0.1em;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--black);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-08);
}

.form-input::placeholder {
  color: var(--gray-300);
  letter-spacing: 0;
  font-family: var(--font);
  font-size: 15px;
}

.btn-primary {
  width: 100%;
  padding: 13px;
  margin-top: 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
  min-height: 48px;
  box-shadow: 0 1px 3px rgba(26,77,143,0.2);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 6px rgba(26,77,143,0.28);
}

.btn-primary:active {
  transform: translateY(0.5px);
  box-shadow: 0 1px 2px rgba(26,77,143,0.15);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.login-error {
  margin-top: 16px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid rgba(196,38,46,0.1);
  border-radius: var(--radius);
  display: none;
  text-align: left;
  line-height: 1.45;
}

.login-divider { display: none; }

.login-footer {
  margin-top: 48px;
  font-size: 12px;
  color: var(--gray-300);
  letter-spacing: 0.02em;
}

/* ── Dashboard topbar ───────────────────────────────────────────────────── */

.dash-topbar {
  background: var(--accent);
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  position: relative;
  z-index: 10;
}

.dash-topbar-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.dash-logo-sm {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.dash-logo-sm img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: brightness(10);
}

.dash-user-info { min-width: 0; }

.dash-greeting {
  font-size: 16px;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.dash-cedula {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  font-family: var(--mono);
  margin-top: 2px;
  letter-spacing: 0.03em;
}

.btn-logout {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.14);
  color: var(--white);
  border-color: rgba(255,255,255,0.3);
}

/* ── Dashboard content ──────────────────────────────────────────────────── */

.dash-wrapper {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray-400);
  margin: 36px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-100);
}

/* ── Congress cards ─────────────────────────────────────────────────────── */

.congress-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.congress-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--gray-200);
}

.cc-accent { display: none; }

.cc-body { padding: 28px; }

.cc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.cc-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--black);
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.cc-date {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 6px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.cc-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.badge-inscrito {
  background: var(--accent-light);
  color: var(--accent);
}

.badge-asistio {
  background: var(--green-bg);
  color: var(--green);
}

/* ── Stats ──────────────────────────────────────────────────────────────── */

.cc-stats {
  display: flex;
  margin-bottom: 24px;
  padding: 16px 0;
  border-top: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
}

.cc-stat {
  display: flex;
  flex-direction: column;
  padding-right: 28px;
}

.cc-stat + .cc-stat {
  padding-right: 0;
  padding-left: 28px;
  border-left: 1px solid var(--gray-100);
}

.cc-stat-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--black);
  font-family: var(--mono);
  line-height: 1;
  letter-spacing: -0.02em;
}

.cc-stat-label {
  font-size: 11px;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 6px;
  font-weight: 500;
}

/* ── Contact info ───────────────────────────────────────────────────────── */

.cc-contact {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

.cc-contact-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--gray-600);
  min-width: 0;
}

.cc-contact-item svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--gray-300);
}

.cc-contact-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Action buttons ─────────────────────────────────────────────────────── */

.cc-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 20px;
}

.btn-action {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-800);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-action:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-08);
}

.btn-ticket {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
  font-weight: 600;
}

.btn-ticket:hover {
  background: var(--gray-800);
  border-color: var(--gray-800);
  color: var(--white);
  background: #333;
}

.btn-qr {
  background: var(--accent);
  color: var(--white);
  border-color: var(--accent);
  box-shadow: 0 1px 3px rgba(26,77,143,0.18);
  font-weight: 600;
}

.btn-qr:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--white);
  box-shadow: 0 2px 6px rgba(26,77,143,0.25);
}

.btn-diploma:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-diploma:disabled:hover {
  border-color: var(--gray-200);
  color: var(--gray-800);
  background: var(--white);
}

/* ── Modal ──────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.open { display: flex; }

.modal-card {
  background: var(--white);
  border-radius: 10px 10px 0 0;
  padding: 24px 24px 32px;
  width: 100%;
  max-width: 480px;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  margin: 0 auto 24px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}

.modal-field { margin-bottom: 18px; }

.modal-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.modal-field input {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--black);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

.modal-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-08);
}

.modal-note {
  font-size: 12px;
  color: var(--gray-600);
  margin: -4px 0 20px;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 28px;
}

.btn-modal-save {
  flex: 1;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--white);
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  min-height: 48px;
  box-shadow: 0 1px 3px rgba(26,77,143,0.2);
}

.btn-modal-save:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 6px rgba(26,77,143,0.28);
}

.btn-modal-cancel {
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
}

.btn-modal-cancel:hover {
  border-color: var(--gray-400);
  background: var(--gray-50);
}

/* ── QR Modal ───────────────────────────────────────────────────────────── */

.qr-modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 0 20px;
}

.qr-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: 4px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.qr-subtitle {
  font-size: 13px;
  color: var(--gray-400);
  margin-bottom: 28px;
}

.qr-canvas {
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  max-width: 220px;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  box-shadow: var(--shadow-sm);
}

.qr-sid {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--gray-400);
  letter-spacing: 0.05em;
}

/* ── Diploma info ───────────────────────────────────────────────────────── */

.diploma-info {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-top: 24px;
  box-shadow: var(--shadow-sm);
}

.diploma-info-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.diploma-info-text {
  font-size: 14px;
  color: var(--gray-600);
  line-height: 1.65;
}

.diploma-info a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(26,77,143,0.25);
  transition: border-color 0.2s;
}

.diploma-info a:hover {
  border-bottom-color: var(--accent);
}

.diploma-more-text {
  font-size: 13px;
  color: var(--gray-600);
  margin-top: 14px;
  text-align: center;
}

.diploma-more-text a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(26,77,143,0.25);
  transition: border-color 0.2s;
  white-space: nowrap;
}

.diploma-more-text a:hover {
  border-bottom-color: var(--accent);
}

.diploma-password {
  font-family: var(--mono);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 500;
  user-select: all;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.03em;
}

/* ── Skeleton loading ───────────────────────────────────────────────────── */

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skel {
  background: linear-gradient(90deg, var(--gray-100) 25%, #F0F0EE 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: 3px;
}

.skel-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.skel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.skel-stats {
  display: flex;
  gap: 32px;
  margin-bottom: 24px;
  padding: 16px 0;
  border-top: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
}

.skel-actions {
  display: flex;
  gap: 8px;
  padding-top: 20px;
}

.skel-btn { width: 96px; height: 36px; }

/* ── UI States (empty, error) ──────────────────────────────────────────── */

.state-box {
  text-align: center;
  padding: 64px 24px;
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.state-box svg {
  color: var(--gray-200);
  margin-bottom: 20px;
}

.state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.state-text {
  font-size: 14px;
  color: var(--gray-400);
  line-height: 1.6;
  max-width: 320px;
  margin: 0 auto;
}

.state-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.state-action:hover {
  background: var(--accent);
  color: var(--white);
}

/* ── Login button loading ──────────────────────────────────────────────── */

.btn-loading-dots span {
  animation: dotPulse 1s ease-in-out infinite;
}

.btn-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.btn-loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

/* ── Partial state: date placeholder ───────────────────────────────────── */

.cc-date-pending {
  font-style: italic;
  color: var(--gray-300);
  font-family: var(--font);
  font-size: 13px;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 12px 24px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  z-index: 2000;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--gray-900); color: var(--white); }
.toast.err { background: var(--red); color: var(--white); }

/* ── Pull to refresh ────────────────────────────────────────────────────── */

.ptr-indicator {
  text-align: center;
  padding: 14px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  display: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ptr-indicator.visible { display: block; }

/* ── Last updated ───────────────────────────────────────────────────────── */

.dash-updated {
  text-align: center;
  font-size: 12px;
  color: var(--gray-300);
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
  font-family: var(--mono);
  letter-spacing: 0.03em;
}

/* ── Responsive: mobile ─────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .login-wrapper { padding: 16px; }
  .login-title { font-size: 24px; }
  .login-sub { margin-bottom: 36px; font-size: 14px; }

  .dash-topbar { padding: 14px 16px; }
  .dash-greeting { font-size: 15px; }
  .dash-cedula { font-size: 11px; }
  .dash-logo-sm, .dash-logo-sm img { width: 26px; height: 26px; }
  .btn-logout { padding: 6px 14px; font-size: 12px; }

  .dash-wrapper { padding: 0 16px 64px; }
  .section-label { margin: 28px 0 14px; }

  .cc-body { padding: 22px 18px; }
  .cc-name { font-size: 16px; }
  .cc-stat-value { font-size: 22px; }

  .cc-actions {
    flex-direction: column;
    gap: 6px;
  }

  .btn-action {
    width: 100%;
    justify-content: center;
    min-height: 46px;
  }

  .cc-contact {
    flex-direction: column;
    gap: 10px;
  }

  .modal-card { padding: 20px 18px 28px; }
  .diploma-info { padding: 18px; }

  .skel-card { padding: 22px 18px; }
  .skel-actions { flex-direction: column; }
  .skel-btn { width: 100%; }
}

/* ── Responsive: very small ─────────────────────────────────────────────── */

@media (max-width: 360px) {
  .login-wrapper { padding: 12px; }
  .login-title { font-size: 22px; }

  .dash-topbar { padding: 12px 12px; }
  .dash-greeting { font-size: 14px; }
  .dash-wrapper { padding: 0 12px 56px; }
  .cc-body { padding: 18px 14px; }
  .cc-name { font-size: 15px; }
  .cc-stat-value { font-size: 20px; }
}

/* ── Desktop: centered modal ────────────────────────────────────────────── */

@media (min-width: 481px) {
  .modal-overlay {
    align-items: center;
    padding: 16px;
  }

  .modal-card {
    border-radius: var(--radius-lg);
    animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-lg);
  }

  @keyframes modalIn {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
  }

  .modal-handle { display: none; }
}

/* ── Safe area (notch phones) ───────────────────────────────────────────── */

@supports (padding-top: env(safe-area-inset-top)) {
  .dash-topbar {
    padding-top: calc(18px + env(safe-area-inset-top));
  }

  .toast {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .modal-card {
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
  }
}
