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

:root {
  --color-primary:       #1a4fd6;
  --color-primary-dark:  #1340b0;
  --color-primary-light: #e8f0fe;
  --color-bg:            #f0f2f7;
  --color-surface:       #ffffff;
  --color-text:          #0f1c2e;
  --color-muted:         #5a6a80;
  --color-border:        #dde3ef;
  --color-accent:        #00c2a0;
  --color-accent-light:  #e6faf7;
  --color-success:       #059669;
  --color-success-light: #d1fae5;
  --color-error:         #c53030;
  --color-error-light:   #fff5f5;
  --color-error-border:  #fed7d7;
  --radius:              12px;
  --radius-sm:           8px;
  --shadow:              0 2px 12px rgba(26,79,214,.07);
  --shadow-md:           0 4px 24px rgba(26,79,214,.12);
  --font:                'Segoe UI', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── HEADER ── */
.dash-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 2.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.dash-header__brand {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-primary);
  text-decoration: none;
  letter-spacing: -.5px;
  flex-shrink: 0;
}
.dash-header__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .1rem;
}
.dash-header__tagline {
  font-size: .77rem;
  color: var(--color-muted);
  font-weight: 500;
}
.dash-header__client {
  font-size: .77rem;
  color: var(--color-primary);
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

/* ── MAIN ── */
.dash-main {
  max-width: 780px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

/* ── INTRO ── */
.dash-intro { margin-bottom: 2rem; }
.dash-intro__title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -.3px;
  margin-bottom: .4rem;
}
.dash-intro__sub { font-size: .95rem; color: var(--color-muted); max-width: 640px; }

/* ── CARDS ── */
.dash-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.dash-card--payment {
  border-color: var(--color-primary);
  border-width: 2px;
}
.dash-card__header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.dash-card__num {
  width: 32px;
  height: 32px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .88rem;
  flex-shrink: 0;
  margin-top: 3px;
}
.dash-card__num--pay {
  background: var(--color-primary);
  color: #fff;
}
.dash-card__title {
  font-size: 1.08rem;
  font-weight: 700;
  margin-bottom: .2rem;
}
.dash-card__sub { font-size: .88rem; color: var(--color-muted); }

/* ── FORM GRID ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group--full { grid-column: 1 / -1; }

label {
  font-size: .86rem;
  font-weight: 600;
  color: var(--color-text);
  user-select: none;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,79,214,.1);
}
input.input--error,
textarea.input--error,
select.input--error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(197,48,48,.08);
}
textarea { resize: vertical; min-height: 82px; line-height: 1.55; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }

.select-wrapper { position: relative; }
.select-wrapper select { padding-right: 2.5rem; cursor: pointer; }
.select-wrapper::after {
  content: '';
  position: absolute;
  right: .95rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--color-muted);
  pointer-events: none;
}

.form-error {
  font-size: .8rem;
  color: var(--color-error);
  min-height: 1.1em;
  line-height: 1.3;
}

/* ── OPTION TOGGLES ── */
.options-row {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.option-toggle {
  display: flex;
  align-items: flex-start;
  gap: .9rem;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.option-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.option-toggle__track {
  width: 40px;
  height: 22px;
  background: var(--color-border);
  border-radius: 100px;
  flex-shrink: 0;
  margin-top: 3px;
  position: relative;
  transition: background .2s;
}
.option-toggle__track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.option-toggle input:checked ~ .option-toggle__track {
  background: var(--color-primary);
}
.option-toggle input:checked ~ .option-toggle__track::after {
  transform: translateX(18px);
}
.option-toggle input:focus-visible ~ .option-toggle__track {
  box-shadow: 0 0 0 3px rgba(26,79,214,.2);
}
.option-toggle__text strong {
  display: block;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: .15rem;
}
.option-toggle__text small {
  font-size: .82rem;
  color: var(--color-muted);
}

/* ── DROPZONE ── */
.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--color-bg);
}
.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
.dropzone:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}
.dropzone__icon {
  width: 40px;
  height: 40px;
  color: var(--color-muted);
  margin: 0 auto .9rem;
  display: block;
}
.dropzone__label { font-size: .95rem; color: var(--color-muted); }
.dropzone__link {
  background: none;
  border: none;
  color: var(--color-primary);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  text-decoration: underline;
}
.dropzone__hint {
  font-size: .8rem;
  color: var(--color-muted);
  margin-top: .4rem;
}

/* ── FILE LIST ── */
.file-list {
  list-style: none;
  margin-top: .9rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
.file-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem .9rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
}
.file-item__name {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-item__name svg { flex-shrink: 0; color: var(--color-muted); }
.file-item__size { color: var(--color-muted); font-size: .8rem; flex-shrink: 0; }
.file-item__remove {
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  padding: .2rem .35rem;
  border-radius: 4px;
  line-height: 1;
  font-size: .95rem;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.file-item__remove:hover {
  color: var(--color-error);
  background: var(--color-error-light);
}

/* ── PAYMENT SUMMARY ── */
.payment-summary {
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.payment-fee {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .9rem;
}
.payment-fee__label { font-weight: 600; font-size: .95rem; }
.payment-fee__amount {
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--color-primary);
  letter-spacing: -.5px;
}
.payment-deduction-note {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  font-size: .85rem;
  color: var(--color-success);
  background: var(--color-success-light);
  border-radius: var(--radius-sm);
  padding: .75rem .9rem;
  line-height: 1.5;
}
.note-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── PAYMENT METHOD ── */
.payment-method { margin-bottom: 1.5rem; }
.payment-method__label {
  font-size: .86rem;
  font-weight: 600;
  margin-bottom: .75rem;
}
.payment-method__options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.method-option { cursor: pointer; }
.method-option input { position: absolute; opacity: 0; width: 0; height: 0; }
.method-option__box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  padding: .85rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 600;
  color: var(--color-muted);
  transition: border-color .2s, color .2s, background .2s;
  cursor: pointer;
}
.method-option__box svg { width: 20px; height: 20px; flex-shrink: 0; }
.method-option input:checked ~ .method-option__box {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}
.method-option__box:hover { border-color: var(--color-primary); }

/* ── PAY BUTTON ── */
.btn-pay {
  width: 100%;
  padding: 1rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  transition: background .2s, transform .15s, box-shadow .2s;
  font-family: var(--font);
  letter-spacing: .1px;
  margin-bottom: 1rem;
}
.btn-pay:hover:not(:disabled) {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(26,79,214,.3);
}
.btn-pay:disabled { opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }
/* `.btn-pay{display:flex}` tiene la misma especificidad que la regla `[hidden]` del
   user-agent y gana por orden de cascada — sin esto, `btn.hidden = true` no oculta
   nada visualmente aunque la propiedad DOM `hidden` sí esté en `true`. */
.btn-pay[hidden] { display: none; }
.btn-pay__spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  display: none;
  flex-shrink: 0;
}
.btn-pay.loading .btn-pay__spinner { display: block; animation: spin .7s linear infinite; }
.btn-pay.loading .btn-pay__text { opacity: .75; }

@keyframes spin { to { transform: rotate(360deg); } }

.pay-legal {
  font-size: .78rem;
  color: var(--color-muted);
  text-align: center;
  line-height: 1.5;
}

/* ── API ERROR ── */
.api-error {
  background: var(--color-error-light);
  border: 1px solid var(--color-error-border);
  color: var(--color-error);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  font-size: .88rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* ── NO-CLIENT WARNING ── */
.no-client-warning {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  padding: .9rem 1.1rem;
  font-size: .88rem;
  color: #78350f;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* ── SUCCESS STATE ── */
.success-state {
  background: var(--color-surface);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
}
.success-icon {
  width: 56px;
  height: 56px;
  background: var(--color-accent);
  color: #fff;
  border-radius: 50%;
  font-size: 1.6rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}
.success-state h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: .5rem; }
.success-state > p { color: var(--color-muted); font-size: .95rem; margin-bottom: 1.5rem; max-width: 500px; margin-left: auto; margin-right: auto; }
.success-details {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.success-detail {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: .75rem 1.25rem;
  text-align: left;
  min-width: 160px;
}
.success-detail__label {
  display: block;
  font-size: .75rem;
  color: var(--color-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: .25rem;
}
.success-detail__value { font-size: .95rem; font-weight: 700; }
.success-detail__value--accent { color: var(--color-accent); }
.status-badge {
  background: #fef3c7;
  color: #92400e;
  padding: .2rem .65rem;
  border-radius: 100px;
  font-size: .8rem;
  font-weight: 700;
}
.success-note { font-size: .85rem; color: var(--color-muted); }

/* ── CASE META HEADER ── */
.case-meta {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 1.25rem 2rem;
}
.case-meta__item { flex: 1; min-width: 120px; }
.case-meta__item--right { text-align: right; flex: 0; min-width: unset; }
.case-meta__label {
  display: block;
  font-size: .74rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: .2rem;
}
.case-meta__value { font-size: .95rem; font-weight: 700; }
.status-badge--done { background: var(--color-success-light); color: var(--color-success); }

/* ── CASE PROGRESS ── */
.case-progress__steps {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin-bottom: 1rem;
}
.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  flex: 1;
  max-width: 140px;
  position: relative;
}
.progress-step__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--color-border);
  position: relative;
  z-index: 1;
  transition: border-color .3s, background .3s;
}
.progress-step--done .progress-step__dot  { background: var(--color-success); border-color: var(--color-success); }
.progress-step--active .progress-step__dot { background: var(--color-primary); border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(26,79,214,.15); }
.progress-step + .progress-step::before {
  content: '';
  position: absolute;
  left: -50%; top: 6px;
  width: 100%; height: 2px;
  background: var(--color-border);
  z-index: 0;
}
.progress-step--done + .progress-step::before { background: var(--color-success); }
.progress-step__label { font-size: .77rem; font-weight: 600; color: var(--color-muted); text-align: center; }
.progress-step--done .progress-step__label,
.progress-step--active .progress-step__label { color: var(--color-text); }

.progress-note { font-size: .87rem; color: var(--color-muted); margin-top: 1rem; text-align: center; }

/* ── COMPLETED PANEL ── */
.completed-panel__header { text-align: center; margin-bottom: 1.5rem; }
.completed-panel__icon {
  width: 48px; height: 48px;
  background: var(--color-success); color: #fff;
  border-radius: 50%; font-size: 1.3rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto .75rem;
}
.completed-panel__title { font-size: 1.15rem; font-weight: 800; margin-bottom: .35rem; }
.completed-panel__sub { font-size: .9rem; color: var(--color-muted); max-width: 440px; margin: 0 auto; }

.fee-breakdown {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.fee-row { display: flex; justify-content: space-between; align-items: baseline; font-size: .92rem; padding: .4rem 0; }
.fee-row__label { color: var(--color-muted); }
.fee-row__amount { font-weight: 700; }
.fee-row--total { border-top: 2px solid var(--color-border); margin-top: .35rem; padding-top: .75rem; }
.fee-row--total .fee-row__label { font-weight: 700; color: var(--color-text); font-size: .95rem; }
.fee-row--total .fee-row__amount { font-size: 1.5rem; font-weight: 900; color: var(--color-primary); letter-spacing: -.3px; }

.fee-pending { color: var(--color-muted); font-size: .92rem; text-align: center; padding: .5rem 0; }

.btn-pay--final { background: var(--color-success); }
.btn-pay--final:hover:not(:disabled) { background: #047857; box-shadow: 0 4px 14px rgba(5,150,105,.3); }

/* ── Stripe Elements (tarjeta) ── */
.card-payment-form { margin-bottom: 1rem; }
.card-element {
  padding: .9rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  margin-bottom: 1rem;
}
.card-element--focused { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(26,79,214,.12); }

.download-buttons { display: flex; flex-direction: column; gap: .75rem; margin-top: 1rem; }
.btn-download {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .95rem; font-weight: 700;
  cursor: pointer; text-decoration: none; font-family: var(--font);
  transition: background .2s, transform .15s;
  border: none;
}
.btn-download:hover { transform: translateY(-1px); }
.btn-download svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-download--primary { background: var(--color-primary); color: #fff; }
.btn-download--primary:hover { background: var(--color-primary-dark); }
.btn-download--secondary { background: var(--color-bg); color: var(--color-text); border: 1.5px solid var(--color-border); }
.btn-download--secondary:hover { background: var(--color-primary-light); border-color: var(--color-primary); }

/* ── RESPONSIVE ── */
@media (max-width: 620px) {
  .dash-main { padding: 1.5rem 1rem 3.5rem; }
  .dash-card { padding: 1.5rem 1.25rem; }
  .dash-header { padding: 0 1.25rem; }
  .dash-header__tagline { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .payment-method__options { grid-template-columns: 1fr; }
  .success-details { flex-direction: column; align-items: center; }
  .success-detail { min-width: unset; width: 100%; max-width: 280px; }
}
