/* Sistema de Tasaciones — estilos del panel de administración */
:root {
  --azul: #1a3a5c;
  --azul-claro: #2c5f8a;
  --azul-bg: #e8edf2;
  --acento: #e74c3c;
  --verde: #27ae60;
  --gris: #6c757d;
  --borde: #dee2e6;
  --radio: 6px;
  --sombra: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: #f4f6f9;
  color: #1a1a1a;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Barra superior ─────────────────────────────────── */
.topbar {
  background: var(--azul);
  color: white;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.topbar-brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-brand .version { font-size: 11px; opacity: 0.6; font-weight: 400; }
.topbar-nav { display: flex; gap: 6px; }
.topbar-nav a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radio);
  font-size: 13px;
  transition: background 0.15s;
}
.topbar-nav a:hover, .topbar-nav a.active {
  background: rgba(255,255,255,0.15);
  color: white;
}

/* ── Contenedor principal ───────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.container-wide { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radio);
  border: 1px solid var(--borde);
  box-shadow: var(--sombra);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  background: var(--azul-bg);
  border-bottom: 1px solid var(--borde);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2, .card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--azul);
  margin: 0;
}
.card-body { padding: 20px; }

/* ── Estadísticas dashboard ─────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  border-radius: var(--radio);
  padding: 16px 20px;
  border: 1px solid var(--borde);
  box-shadow: var(--sombra);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card .stat-label { font-size: 12px; color: var(--gris); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; color: var(--azul); }
.stat-card .stat-sub { font-size: 12px; color: var(--gris); }
.stat-card.verde .stat-value { color: var(--verde); }
.stat-card.rojo .stat-value { color: var(--acento); }

/* ── Tabla de tasaciones ────────────────────────────── */
.table-responsive { overflow-x: auto; }
table.main-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.main-table thead th {
  background: var(--azul);
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
table.main-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--borde);
  vertical-align: middle;
}
table.main-table tbody tr:hover td { background: #f8f9fc; }
table.main-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges de estado ───────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-borrador { background: #fff3cd; color: #856404; }
.badge-revision { background: #cff4fc; color: #055160; }
.badge-finalizado { background: #d1e7dd; color: #0a3622; }
.badge-vivienda { background: #e8edf2; color: var(--azul); }
.badge-apartamento { background: #e8f4e8; color: #155724; }
.badge-local_comercial { background: #fef3e8; color: #7c4b00; }
.badge-terreno { background: #f3e8ff; color: #4b007c; }

/* ── Botones ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radio);
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--azul); color: white; }
.btn-primary:hover { background: var(--azul-claro); }
.btn-success { background: var(--verde); color: white; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger { background: var(--acento); color: white; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-secondary { background: #6c757d; color: white; }
.btn-secondary:hover { background: #5a6268; }
.btn-outline {
  background: white;
  color: var(--azul);
  border: 1px solid var(--borde);
}
.btn-outline:hover { background: var(--azul-bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Formulario ─────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
.form-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-group label .req { color: var(--acento); }
.form-control {
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: white;
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--azul-claro);
  box-shadow: 0 0 0 3px rgba(44, 95, 138, 0.15);
}
.form-control.error { border-color: var(--acento); }
.form-hint { font-size: 11px; color: var(--gris); }
textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { cursor: pointer; }

/* ── Tabs ────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--borde);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--gris);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.tab-btn.active {
  color: var(--azul);
  border-bottom-color: var(--azul);
  font-weight: 600;
}
.tab-btn:hover:not(.active) { color: var(--azul-claro); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Tabla de comparables / factores ────────────────── */
.factor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  overflow-x: auto;
  display: block;
}
.factor-table th {
  background: var(--azul);
  color: white;
  padding: 7px 8px;
  text-align: center;
  white-space: nowrap;
  font-size: 11px;
}
.factor-table td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--borde);
  vertical-align: middle;
}
.factor-table input[type="number"] {
  width: 70px;
  padding: 3px 6px;
  border: 1px solid var(--borde);
  border-radius: 4px;
  text-align: center;
  font-size: 12px;
}
.factor-table input[type="number"]:focus {
  border-color: var(--azul-claro);
  outline: none;
}
.factor-table .calc-field {
  background: var(--azul-bg);
  font-weight: 600;
  color: var(--azul);
  text-align: center;
}

/* ── Alertas ─────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radio);
  font-size: 13px;
  margin-bottom: 14px;
  border-left: 4px solid;
}
.alert-error { background: #fdf2f2; border-color: var(--acento); color: #c0392b; }
.alert-success { background: #f0fff4; border-color: var(--verde); color: #155724; }
.alert-info { background: #e8f4fd; border-color: var(--azul-claro); color: #0c5460; }
.alert ul { margin: 6px 0 0 16px; }

/* ── Spinner ─────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 3px solid rgba(26,58,92,0.2);
  border-top-color: var(--azul);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Panel de resumen de cálculos ───────────────────── */
.calc-panel {
  background: var(--azul-bg);
  border: 1px solid #c5d0dc;
  border-radius: var(--radio);
  padding: 16px 20px;
  margin-top: 16px;
}
.calc-panel h4 { font-size: 13px; color: var(--azul); margin-bottom: 10px; font-weight: 700; text-transform: uppercase; }
.calc-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px dashed #c5d0dc;
}
.calc-row:last-child { border-bottom: none; font-weight: 700; color: var(--azul); font-size: 15px; padding-top: 8px; }
.calc-row .lbl { color: #555; }
.calc-row .val { font-weight: 600; }

/* ── Zona de fotos ───────────────────────────────────── */
.foto-drop {
  border: 2px dashed var(--borde);
  border-radius: var(--radio);
  padding: 30px;
  text-align: center;
  color: var(--gris);
  cursor: pointer;
  transition: all 0.15s;
}
.foto-drop:hover, .foto-drop.dragging {
  border-color: var(--azul-claro);
  background: var(--azul-bg);
  color: var(--azul);
}
.fotos-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.foto-thumb {
  position: relative;
  border-radius: var(--radio);
  overflow: hidden;
  border: 1px solid var(--borde);
}
.foto-thumb img { width: 100%; height: 100px; object-fit: cover; display: block; }
.foto-thumb .foto-del {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(231,76,60,0.85);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ── Documentos adjuntos ─────────────────────────────── */
.doc-grupo {
  margin-bottom: 20px;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  overflow: hidden;
}
.doc-grupo-titulo {
  background: var(--azul-bg);
  color: var(--azul);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--borde);
}
.doc-drop {
  border: 2px dashed var(--borde);
  margin: 12px;
  border-radius: var(--radio);
  padding: 18px;
  text-align: center;
  color: var(--gris);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.doc-drop:hover {
  border-color: var(--azul-claro);
  background: var(--azul-bg);
  color: var(--azul);
}
.doc-drop.drag-over {
  border-color: var(--azul);
  border-style: solid;
  background: var(--azul-bg);
  color: var(--azul);
  transform: scale(1.01);
  box-shadow: 0 4px 16px rgba(26,58,92,.15);
}
.doc-drop-icon { display: block; font-size: 22px; margin-bottom: 4px; }
.doc-lista { padding: 0 12px 12px; }
.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #f8f9fa;
  border-radius: var(--radio);
  margin-top: 6px;
  font-size: 13px;
}
.doc-item .doc-icon { font-size: 20px; flex-shrink: 0; }
.doc-item .doc-nombre { flex: 1; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-item .doc-del {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.doc-item .doc-del:hover { background: #fde8e8; }

/* ── Panel inicio rápido ─────────────────────────────── */
.iq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.iq-card {
  border: 2px dashed var(--borde);
  border-radius: 10px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s;
  background: #fafbff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.iq-card:hover { border-color: var(--azul-claro); background: var(--azul-bg); }
.iq-card.done { border-style: solid; border-color: var(--verde); background: #f0fff4; }
.iq-card.loading { border-color: var(--azul-claro); background: var(--azul-bg); opacity: 0.8; }
.iq-card.drag-over { border-color: var(--azul); border-style: solid; background: var(--azul-bg); transform: scale(1.02); box-shadow: 0 4px 16px rgba(26,58,92,.18); }
.iq-icon { font-size: 36px; line-height: 1; }
.iq-title { font-weight: 700; font-size: 14px; color: var(--azul); }
.iq-desc { font-size: 12px; color: var(--gris); line-height: 1.4; }
.iq-status { font-size: 12px; font-weight: 600; min-height: 18px; }
.iq-status.ok { color: var(--verde); }
.iq-status.err { color: var(--acento); }
.iq-status.loading { color: var(--azul-claro); }
.iq-campos {
  margin-top: 8px;
  text-align: left;
  width: 100%;
  font-size: 12px;
  background: white;
  border: 1px solid var(--borde);
  border-radius: 6px;
  padding: 8px 10px;
  display: none;
}
.iq-campos.visible { display: block; }
.iq-campo-row { display: flex; gap: 6px; padding: 2px 0; }
.iq-campo-row .lbl { color: #888; min-width: 80px; }
.iq-campo-row .val { color: var(--azul); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .container { padding: 12px; }
}
