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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f5f7;
  color: #333;
  min-height: 100vh;
}

/* ── Shared helpers ───────────────────────────────────────────────────────── */
.hidden { display: none !important; }

.btn {
  display: inline-block;
  padding: 9px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary  { background: #1a3c6e; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #245090; box-shadow: 0 4px 14px rgba(26,60,110,0.4); }
.btn-danger   { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled)  { background: #b91c1c; }
.btn-ghost    { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3); color: #fff; }
.btn-ghost:hover:not(:disabled)   { background: rgba(255,255,255,0.28); }
.btn-outline  { background: transparent; border: 1.5px solid #1a3c6e; color: #1a3c6e; }
.btn-outline:hover:not(:disabled) { background: #1a3c6e; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

.error-msg { color: #dc2626; font-size: 0.84rem; margin-top: 8px; }
.success-msg { color: #16a34a; font-size: 0.84rem; margin-top: 8px; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 28px 32px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin-bottom: 24px;
  border: 1px solid #e8edf5;
}
.card-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #1a3c6e;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 20px;
}

/* ── Form elements ───────────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 5px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #ccc;
  border-radius: 6px;
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.2s;
  outline: none;
  background: #fff;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: #1a3c6e; }
.field textarea { resize: vertical; min-height: 70px; }
.field-hint { font-size: 0.77rem; color: #888; margin-top: 4px; }

/* ══════════════════════════════════════════════════════════════════════════ */
/*  CLIENT PORTAL                                                             */
/* ══════════════════════════════════════════════════════════════════════════ */

/* ── Login overlay ───────────────────────────────────────────────────────── */
#login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#login-box {
  background: #fff;
  border-radius: 10px;
  padding: 40px 44px;
  width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  text-align: center;
  border-top: 4px solid #1a3c6e;
}
.login-icon { font-size: 2.4rem; margin-bottom: 10px; line-height: 1; }
#login-box h2 { font-size: 1.35rem; font-weight: 700; color: #1a3c6e; margin-bottom: 6px; }
#login-box .sub { font-size: 0.88rem; color: #666; margin-bottom: 28px; }
#login-box .login-hint { margin-top: 16px; font-size: 0.78rem; color: #aaa; }
#login-btn { width: 100%; }

/* ── Client header ───────────────────────────────────────────────────────── */
#client-header {
  background: linear-gradient(135deg, #1a3c6e 0%, #2256a8 100%);
  color: #fff;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
#client-header .firm-name { font-size: 1.2rem; font-weight: 700; }
#client-header .client-welcome { font-size: .95rem; opacity: .85; }

/* ── Main content ────────────────────────────────────────────────────────── */
#client-main {
  max-width: 960px;
  margin: 32px auto;
  padding: 0 20px;
}

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-wrapper {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 8px 0 0;
}
.progress-track {
  position: absolute;
  top: 22px;
  left: calc(100% / 22);
  right: calc(100% / 22);
  height: 4px;
  background: #ddd;
  z-index: 0;
}
.progress-track-fill { height: 100%; background: #27ae60; transition: width 0.5s ease; }

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
  z-index: 1;
}
.stage.interactive { cursor: pointer; }
.stage-node {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  border: 3px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s;
  background: #ccc;
  position: relative;
}
.stage.interactive:hover .stage-node {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.stage-node.green  { background: #27ae60; border-color: #1e8449; }
.stage-node.yellow { background: #f39c12; border-color: #d68910; animation: pulse-yellow 2.2s ease-out infinite; }
.stage-node.red    { background: #e74c3c; border-color: #c0392b; animation: pulse-red   2.2s ease-out infinite; }
.stage-node.gray   { background: #bdc3c7; border-color: #a0a6aa; }

@keyframes pulse-yellow {
  0%   { box-shadow: 0 0 0 0   rgba(243,156,18,0.55); }
  65%  { box-shadow: 0 0 0 11px rgba(243,156,18,0); }
  100% { box-shadow: 0 0 0 0   rgba(243,156,18,0); }
}
@keyframes pulse-red {
  0%   { box-shadow: 0 0 0 0   rgba(231,76,60,0.55); }
  65%  { box-shadow: 0 0 0 11px rgba(231,76,60,0); }
  100% { box-shadow: 0 0 0 0   rgba(231,76,60,0); }
}
.stage-node.green::after {
  content: "✓";
  position: absolute; top: -2px; right: -2px;
  width: 14px; height: 14px;
  background: #fff; color: #27ae60;
  border-radius: 50%; font-size: 9px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  line-height: 14px; text-align: center;
}
.stage-label {
  margin-top: 8px;
  font-size: 0.64rem;
  color: #555;
  text-align: center;
  max-width: 72px;
  line-height: 1.3;
}

/* ── Stage detail panel — dedicated, always-visible area for the current stage ── */
.stage-detail-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #e74c3c;
  margin-right: 7px;
  vertical-align: middle;
}
.stage-detail-body {
  font-size: 0.88rem;
  line-height: 1.55;
  color: #333;
}
.stage-detail-body h4 { font-size: 0.9rem; font-weight: 700; color: #1a3c6e; margin-bottom: 8px; }
.stage-detail-body a  { color: #1a3c6e; font-weight: 600; }
.stage-detail-body ul { padding-left: 18px; margin-top: 4px; }
.stage-detail-body ul li { margin-bottom: 4px; }

/* ── Progress bar — mobile vertical stepper ─────────────────────────────── */
@media (max-width: 640px) {
  .progress-wrapper {
    flex-direction: column;
    align-items: flex-start;
    padding-top: 0;
    gap: 0;
    max-width: 260px;
    margin: 0 auto;
  }
  .progress-track {
    top: 28px;
    bottom: 28px;
    left: 20px;
    right: auto;
    width: 4px;
    height: auto;
  }
  .progress-track-fill {
    width: 100% !important;
    height: var(--fill-pct, 0%);
    transition: height 0.5s ease;
  }
  .stage {
    flex-direction: row;
    align-items: center;
    flex: none;
    width: 100%;
    padding: 6px 0;
    gap: 16px;
    min-height: 56px;
  }
  .stage-label {
    text-align: left;
    max-width: none;
    margin-top: 0;
    font-size: 0.8rem;
  }
}

/* ── Sticky mobile action footer ────────────────────────────────────────────
   Surfaces the current stage's action item without requiring a scroll past
   the vertical stepper above. Supplements the inline #stage-detail-card
   (tapping it scrolls there) rather than replacing it. Mobile-only — on
   desktop the panel is already visible right under the progress bar. ── */
#stage-action-bar { display: none; }
@media (max-width: 640px) {
  body.has-stage-action { padding-bottom: 76px; }
  #stage-action-bar.show {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: #e74c3c;
    color: #fff;
    padding: 14px 18px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 14px rgba(0,0,0,0.2);
    z-index: 500;
    cursor: pointer;
  }
  #stage-action-bar .stage-action-label {
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.3;
  }
  #stage-action-bar button {
    flex-shrink: 0;
    background: #fff;
    color: #c0392b;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
  }
}

/* ── Legend ──────────────────────────────────────────────────────────────── */
.legend {
  display: flex; gap: 20px;
  margin-top: 22px; padding-top: 16px;
  border-top: 1px solid #eee; flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: #555; }
.legend-dot  { width: 12px; height: 12px; border-radius: 50%; }

/* ── Videos ──────────────────────────────────────────────────────────────── */
.video-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 620px) { .video-grid { grid-template-columns: 1fr; } }
.video-block h4 { font-size: 1rem; font-weight: 700; color: #1a3c6e; margin-bottom: 10px; }
.video-block p  { font-size: 0.85rem; color: #666; margin-bottom: 12px; line-height: 1.5; }
.video-block video { width: 100%; border-radius: 8px; background: #111; aspect-ratio: 16/9; }
.video-placeholder {
  width: 100%; aspect-ratio: 16/9;
  background: #1a1a2e; border-radius: 8px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: rgba(255,255,255,0.6); font-size: 0.82rem; font-style: italic;
}

/* ── Zoom info ───────────────────────────────────────────────────────────── */
.zoom-info p { font-size: 0.9rem; color: #555; margin-bottom: 8px; line-height: 1.6; }
.zoom-info a:not(.btn) {
  display: inline-block; margin-top: 4px;
  color: #1a3c6e; font-weight: 600; font-size: 0.9rem;
  text-decoration: none; border-bottom: 1px solid #1a3c6e;
}
.zoom-info a:not(.btn):hover { color: #245090; }
.zoom-details {
  margin-top: 12px; background: #f0f4fb;
  border-radius: 6px; padding: 12px 16px;
  font-size: 0.84rem; color: #444;
  display: grid; grid-template-columns: auto 1fr;
  gap: 4px 14px;
}
.zoom-details dt { font-weight: 600; color: #1a3c6e; }

/* ── Fireworks ───────────────────────────────────────────────────────────── */
#fireworks-overlay {
  display: none; position: fixed; inset: 0;
  pointer-events: none; z-index: 999;
}
.firework {
  position: absolute; border-radius: 50%;
  animation: burst 1s ease-out forwards;
}
@keyframes burst {
  0%   { transform: scale(0); opacity: 1; }
  100% { transform: scale(4); opacity: 0; }
}


/* ══════════════════════════════════════════════════════════════════════════ */
/*  ADMIN & FIRM ADMIN PORTALS                                               */
/* ══════════════════════════════════════════════════════════════════════════ */

#admin-app, #firm-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Admin header ────────────────────────────────────────────────────────── */
.admin-header {
  background: linear-gradient(135deg, #0d1d35 0%, #1e293b 100%);
  color: #fff;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 54px;
  flex-shrink: 0;
}
.admin-header .logo { font-size: 0.95rem; font-weight: 700; letter-spacing: 0.03em; margin-right: auto; }
.admin-header .logo span { color: #60a5fa; }

/* ── Admin nav ───────────────────────────────────────────────────────────── */
.admin-nav a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 4px 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.admin-nav a:hover, .admin-nav a.active { color: #fff; border-bottom-color: #60a5fa; }
.admin-nav { display: flex; gap: 20px; }

/* ── Admin body ──────────────────────────────────────────────────────────── */
.admin-body { flex: 1; max-width: 1100px; width: 100%; margin: 32px auto; padding: 0 24px; }

/* ── Admin login ─────────────────────────────────────────────────────────── */
#admin-login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: #f4f5f7;
}
.admin-login-box {
  background: #fff; border-radius: 10px;
  padding: 40px 44px; width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  border-top: 4px solid #60a5fa;
}
.admin-login-box h2 { font-size: 1.2rem; font-weight: 700; color: #1e293b; margin-bottom: 6px; }
.admin-login-box .sub { font-size: 0.85rem; color: #888; margin-bottom: 28px; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th {
  text-align: left; padding: 10px 14px;
  background: #f8fafc; border-bottom: 2px solid #e2e8f0;
  font-size: 0.75rem; font-weight: 700;
  color: #64748b; text-transform: uppercase; letter-spacing: 0.05em;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; }
.data-table tr:hover td { background: #f8fafc; }

/* ── Status badge ────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 9px;
  border-radius: 99px; font-size: 0.74rem; font-weight: 600;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-gray   { background: #f1f5f9; color: #475569; }

/* ── Page header row ─────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h2 { font-size: 1.2rem; font-weight: 700; color: #1e293b; }

/* ── Stat row (billing) ──────────────────────────────────────────────────── */
.stat-row { display: flex; gap: 20px; margin-bottom: 24px; }
.stat-card {
  flex: 1; background: #fff; border-radius: 10px;
  padding: 20px 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stat-card .label { font-size: 0.78rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .value { font-size: 2rem; font-weight: 700; color: #1e293b; margin-top: 6px; }

/* ── Section divider ─────────────────────────────────────────────────────── */
.section-divider {
  font-size: 0.74rem; font-weight: 700; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.07em;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 6px; margin: 28px 0 18px;
}

/* ── MFA QR block ────────────────────────────────────────────────────────── */
.qr-block {
  background: #f8fafc; border-radius: 8px;
  padding: 20px; text-align: center; margin: 16px 0;
}
.qr-block p { font-size: 0.84rem; color: #555; margin-bottom: 12px; }
.qr-block .uri-box {
  font-size: 0.68rem; word-break: break-all;
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 6px; padding: 10px; color: #334155;
  text-align: left; margin-bottom: 12px;
}

/* ── Video upload ────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed #cbd5e1; border-radius: 8px;
  padding: 32px; text-align: center;
  cursor: pointer; transition: border-color 0.2s, background 0.2s;
  background: #f8fafc;
}
.upload-zone:hover { border-color: #1a3c6e; background: #eff6ff; }
.upload-zone input[type=file] { display: none; }
.upload-zone p { font-size: 0.88rem; color: #64748b; margin-top: 8px; }
.upload-zone .icon { font-size: 2rem; }

/* ── Trustee zoom table ──────────────────────────────────────────────────── */
.kv-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.kv-table td { padding: 6px 8px; }
.kv-table input { width: 100%; padding: 6px 8px; border: 1.5px solid #cbd5e1; border-radius: 5px; font-size: 0.85rem; font-family: inherit; }
.kv-table input:focus { outline: none; border-color: #1a3c6e; }
