/* ════════════════════════════════════════════════════════════
   Pericia PRO — Hoja de estilos principal
   HPG S.L. — Paleta: azul marino + dorado + blanco
   ════════════════════════════════════════════════════════════ */

:root {
  --navy:        #0d1b2a;
  --navy-mid:    #1a3a5c;
  --navy-light:  #1e4976;
  --navy-card:   #152438;
  --gold:        #c9952a;
  --gold-light:  #e0b048;
  --gold-pale:   #f5e6c4;
  --white:       #ffffff;
  --gray-100:    #f4f7fb;
  --gray-200:    #e2e8f0;
  --gray-400:    #94a3b8;
  --gray-600:    #475569;
  --text-light:  #e2e8f0;
  --text-muted:  #94a3b8;
  --success:     #22c55e;
  --error:       #ef4444;
  --warning:     #f59e0b;
  --radius:      8px;
  --radius-lg:   14px;
  --shadow:      0 4px 24px rgba(0,0,0,0.35);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.2);
  --transition:  0.2s ease;
  --sidebar-w:   260px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--navy);
  color: var(--text-light);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: var(--gold-light); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Scrollbar personalizada ────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--navy); }
::-webkit-scrollbar-thumb { background: var(--navy-mid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ════════════════════════════════════════════════════════════
   LOGIN PAGE
   ════════════════════════════════════════════════════════════ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 20%, #1a3a5c 0%, var(--navy) 60%);
  padding: 20px;
}

.login-card {
  background: var(--navy-card);
  border: 1px solid rgba(201,149,42,0.25);
  border-radius: var(--radius-lg);
  padding: 48px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo img {
  height: 90px;
  margin: 0 auto 12px;
}

.login-logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.5px;
}

.login-logo p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-form .form-group {
  margin-bottom: 18px;
}

.login-form label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.login-form input {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  color: var(--white);
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.login-form input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,149,42,0.15);
}

.btn-login {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: var(--navy);
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-top: 8px;
  transition: opacity var(--transition), transform var(--transition);
}

.btn-login:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }
.btn-login:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.4);
  color: #fca5a5;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-top: 14px;
  display: none;
}

.login-footer {
  text-align: center;
  margin-top: 28px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.login-footer a { color: var(--gold-light); }

/* ════════════════════════════════════════════════════════════
   APP LAYOUT — Sidebar + Main
   ════════════════════════════════════════════════════════════ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--navy-card);
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo img {
  height: 44px;
  width: auto;
}

.sidebar-logo .logo-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
}

.sidebar-logo .logo-text span {
  display: block;
  font-size: 0.72rem;
  color: var(--gold);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-gabinete {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  background: rgba(201,149,42,0.06);
}

.sidebar-gabinete .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.sidebar-gabinete .gabinete-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gold-light);
}

/* ── Navegación ─────────────────────────────────────────────── */
.sidebar-nav {
  padding: 16px 10px;
  flex: 1;
}

.nav-section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 10px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-light);
}

.nav-item.active {
  background: rgba(201,149,42,0.15);
  color: var(--gold-light);
  font-weight: 600;
}

.nav-item.active .nav-icon { color: var(--gold); }

.nav-icon {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Estado de licencia en sidebar ─────────────────────────── */
.sidebar-license {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 0.78rem;
}

.license-status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}

.license-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.license-dot.warning { background: var(--warning); }
.license-dot.error { background: var(--error); }

.license-label { color: var(--text-muted); }
.license-value { color: var(--text-light); font-weight: 500; }

.btn-renew {
  display: block;
  text-align: center;
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(201,149,42,0.15);
  border: 1px solid rgba(201,149,42,0.3);
  border-radius: 6px;
  color: var(--gold-light);
  font-size: 0.78rem;
  font-weight: 500;
  transition: background var(--transition);
}
.btn-renew:hover { background: rgba(201,149,42,0.25); text-decoration: none; }

/* ── Main content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--navy-card);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--white);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.topbar-user .user-email {
  color: var(--text-light);
  font-weight: 500;
}

.btn-logout {
  padding: 6px 14px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 6px;
  color: #fca5a5;
  font-size: 0.8rem;
  transition: background var(--transition);
}
.btn-logout:hover { background: rgba(239,68,68,0.2); }

.page-content {
  padding: 30px 36px;
  flex: 1;
}

/* ════════════════════════════════════════════════════════════
   SECCIONES / VISTAS
   ════════════════════════════════════════════════════════════ */

.view { display: none; }
.view.active { display: block; }

.page-header {
  margin-bottom: 28px;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ════════════════════════════════════════════════════════════
   STEPPER (Flujo principal)
   ════════════════════════════════════════════════════════════ */

.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.step-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gray-400);
  background: var(--navy-card);
  transition: all var(--transition);
  flex-shrink: 0;
}

.step-circle.active {
  border-color: var(--gold);
  background: rgba(201,149,42,0.15);
  color: var(--gold-light);
}

.step-circle.done {
  border-color: var(--success);
  background: rgba(34,197,94,0.12);
  color: var(--success);
}

.step-label {
  margin-left: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.step-label.active { color: var(--gold-light); font-weight: 600; }
.step-label.done { color: var(--success); }

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--gray-600);
  min-width: 24px;
  max-width: 60px;
  margin: 0 8px;
}

.step-connector.done { background: var(--success); }

/* ════════════════════════════════════════════════════════════
   CARDS
   ════════════════════════════════════════════════════════════ */

.card {
  background: var(--navy-card);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  color: var(--gold);
  font-size: 1.1rem;
}

/* ════════════════════════════════════════════════════════════
   FORMULARIOS
   ════════════════════════════════════════════════════════════ */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols-1 { grid-template-columns: 1fr; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full { grid-column: 1 / -1; }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

label .required,
.card-title .required {
  color: var(--gold);
  margin-left: 3px;
  font-size: 0.78rem;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
input[type="password"],
select,
textarea {
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  color: var(--white);
  font-size: 0.92rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,149,42,0.12);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

select option { background: var(--navy-card); }

textarea { resize: vertical; min-height: 100px; }

/* Campo con botón de voz integrado */
.voice-field {
  position: relative;
}

.voice-field textarea,
.voice-field input {
  padding-right: 44px;
}

.btn-voice {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 5px;
  line-height: 0;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-field.textarea-field .btn-voice {
  top: 10px;
  transform: none;
}

.btn-voice svg { display: block; flex-shrink: 0; }
.btn-voice:hover { color: var(--gold); background: rgba(201,149,42,0.1); }
.btn-voice.recording {
  color: var(--error);
  background: rgba(239,68,68,0.1);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ════════════════════════════════════════════════════════════
   UPLOAD ZONE
   ════════════════════════════════════════════════════════════ */

.upload-zone {
  display: block;
  border: 2px dashed rgba(201,149,42,0.35);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: rgba(201,149,42,0.03);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--gold);
  background: rgba(201,149,42,0.07);
}

.upload-icon {
  font-size: 2.8rem;
  margin-bottom: 14px;
}

.upload-zone h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 6px;
}

.upload-zone p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.upload-zone .upload-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ════════════════════════════════════════════════════════════
   BOTONES
   ════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: var(--navy);
}
.btn-primary:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }

.btn-secondary {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-light);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.12); }

.btn-success {
  background: rgba(34,197,94,0.15);
  border: 1px solid rgba(34,197,94,0.35);
  color: #86efac;
}
.btn-success:hover:not(:disabled) { background: rgba(34,197,94,0.22); }

.btn-danger {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
}
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.2); }

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }

.btn-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ════════════════════════════════════════════════════════════
   BADGE / CHIPS
   ════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-draft {
  background: rgba(148,163,184,0.15);
  color: var(--gray-400);
}

.badge-exported {
  background: rgba(34,197,94,0.12);
  color: #86efac;
}

.badge-active {
  background: rgba(34,197,94,0.12);
  color: #86efac;
}

.badge-warning {
  background: rgba(245,158,11,0.15);
  color: #fcd34d;
}

/* ════════════════════════════════════════════════════════════
   TABLA DE HISTORIAL
   ════════════════════════════════════════════════════════════ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead tr {
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background var(--transition);
}

tbody tr:hover { background: rgba(255,255,255,0.03); }

tbody td {
  padding: 12px 16px;
  color: var(--text-light);
  vertical-align: middle;
}

.table-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

/* ════════════════════════════════════════════════════════════
   PREVIEW DEL INFORME
   ════════════════════════════════════════════════════════════ */

.report-preview-wrapper {
  background: var(--white);
  border-radius: var(--radius);
  padding: 0;
  min-height: 600px;
  overflow: hidden;
}

.report-preview-toolbar {
  background: var(--navy-mid);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.report-editor {
  width: 100%;
  min-height: 700px;
  padding: 40px 48px;
  background: var(--white);
  color: #1a1a1a;
  font-family: 'Times New Roman', serif;
  font-size: 11pt;
  line-height: 1.6;
  border: none;
  outline: none;
  resize: none;
}

/* ════════════════════════════════════════════════════════════
   ALERTAS / TOASTS
   ════════════════════════════════════════════════════════════ */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-info {
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.25);
  color: #93c5fd;
}

.alert-success {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.25);
  color: #86efac;
}

.alert-warning {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.25);
  color: #fcd34d;
}

.alert-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  color: #fca5a5;
}

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  background: var(--navy-card);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  animation: slideIn 0.25s ease;
  color: var(--text-light);
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }
.toast.warning { border-color: var(--warning); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ════════════════════════════════════════════════════════════
   LOADER
   ════════════════════════════════════════════════════════════ */

.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,27,42,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  flex-direction: column;
  gap: 16px;
  display: none;
}

.loader-overlay.active { display: flex; }

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(201,149,42,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loader-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ════════════════════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════════════════════ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  display: none;
}

.modal-backdrop.active { display: flex; }

.modal {
  background: var(--navy-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  padding: 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--white); }

/* ════════════════════════════════════════════════════════════
   SEARCH BAR
   ════════════════════════════════════════════════════════════ */

.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-bar input, .search-bar select {
  flex: 1;
  min-width: 160px;
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE (mínimo 768px)
   ════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 20px 18px; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); transition: transform 0.3s ease; }
  .sidebar.open { transform: translateX(0); --sidebar-w: 260px; }
  .main-content { margin-left: 0; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  .page-content { padding: 16px; }
  .card { padding: 18px; }
  .stepper { gap: 4px; }
  .step-connector { min-width: 12px; }
  .foto-categories { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════════════════════════
   FOTOS DE DAÑOS — ANÁLISIS IA
   ════════════════════════════════════════════════════════════ */

.foto-analysis-header {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03);
  transition: background var(--transition);
  user-select: none;
}
.foto-analysis-header:hover { background: rgba(255,255,255,0.06); }

.foto-categories {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.foto-cat-block {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255,255,255,0.02);
}

.foto-cat-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--white);
  margin-bottom: 4px;
}

.foto-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  border: 2px dashed rgba(255,255,255,0.15);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.foto-dropzone:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.foto-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.foto-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}
.foto-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.foto-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.foto-remove:hover { background: var(--error); }

/* ════════════════════════════════════════════════════════════
   PASO 1 — RECOPILAR DATOS
   ════════════════════════════════════════════════════════════ */

/* Checkbox "No hay encargo" */
.doc-no-encargo-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 14px;
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.doc-no-encargo-label:hover { background: rgba(255,255,255,0.04); }
.doc-no-encargo-label input { accent-color: var(--gold); width: 15px; height: 15px; flex-shrink: 0; }

/* Cabecera desplegable "Documentación adicional" */
.doc-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03);
  transition: background var(--transition);
  user-select: none;
}
.doc-section-header:hover { background: rgba(255,255,255,0.06); }

/* Fila de documento */
.doc-row {
  padding: 12px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.doc-row:last-child { border-bottom: none; }

.doc-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.doc-row-icon { font-size: 1.15rem; flex-shrink: 0; line-height: 1; }

.doc-row-info { flex: 1; min-width: 0; }

.doc-row-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--white);
  line-height: 1.3;
}

.doc-row-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.doc-row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-left: 34px; /* alineado con el título */
}

/* Toggle "Analizar con IA" */
.doc-analyze-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.1);
  transition: border-color var(--transition), color var(--transition);
  user-select: none;
}
.doc-analyze-toggle:hover {
  border-color: rgba(201,149,42,0.5);
  color: var(--gold-light);
}
.doc-analyze-toggle input {
  accent-color: var(--gold);
  margin: 0;
  width: 13px;
  height: 13px;
}
/* Estado activo (checkbox marcado) — se aplica con CSS puro */
.doc-analyze-toggle:has(input:checked) {
  border-color: rgba(201,149,42,0.35);
  color: var(--gold-light);
  background: rgba(201,149,42,0.07);
}

/* Badge de archivos adjuntos */
.doc-file-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  color: var(--gold);
  background: rgba(201,149,42,0.1);
  border: 1px solid rgba(201,149,42,0.25);
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
}

/* Nombre editable en la fila "Otros" */
.doc-editable-name {
  background: transparent;
  border: none;
  border-bottom: 1px dashed rgba(255,255,255,0.2);
  color: var(--white);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 2px 4px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition);
}
.doc-editable-name:focus { border-bottom-color: var(--gold); }

/* ════════════════════════════════════════════════════════════
   PASO 2 — Grupos de campos predefinidos
   ════════════════════════════════════════════════════════════ */

/* Grupo colapsable (<details>) */
.field-group {
  background: var(--navy-card);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}

/* Cabecera del grupo */
.field-group-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-light);
  list-style: none;
  user-select: none;
  transition: background var(--transition);
}
.field-group-hdr::-webkit-details-marker { display: none; }
.field-group-hdr::after {
  content: '▼';
  margin-left: auto;
  font-size: 0.68rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}
details[open] > .field-group-hdr::after { transform: rotate(180deg); }
details[open] > .field-group-hdr { color: var(--gold-light); border-bottom: 1px solid rgba(201,149,42,0.2); }
.field-group-hdr:hover { background: rgba(255,255,255,0.03); }

/* Contenido del grupo */
.field-group-body {
  padding: 14px 16px 10px;
}

/* Input rellenado por IA → borde dorado */
.field-group-body input.ai-filled,
.field-group-body textarea.ai-filled {
  border-color: rgba(201,149,42,0.6);
  background: rgba(201,149,42,0.04);
}

/* ── Gestiones realizadas ─────────────────────────────────── */
.gestiones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 4px 16px;
  padding: 12px 16px 14px;
}
.gestion-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 5px;
  transition: background var(--transition), color var(--transition);
}
.gestion-item:hover { background: rgba(201,149,42,0.06); color: var(--text-light); }
.gestion-item input[type="checkbox"] { accent-color: var(--gold); width: 14px; height: 14px; flex-shrink: 0; }
.gestion-item:has(input:checked) { color: var(--gold-light); }

/* ── Configuración de la IA (radio pills) ────────────────── */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.radio-option {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: all var(--transition);
}
.radio-option:hover { border-color: rgba(201,149,42,0.35); color: var(--text-light); }
.radio-option:has(input:checked) {
  border-color: var(--gold);
  background: rgba(201,149,42,0.1);
  color: var(--gold-light);
  font-weight: 600;
}
.radio-option input[type="radio"] { display: none; }
