body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f5f7fb;
  color: #1f2937;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: #1d4ed8;
  color: #fff;
  padding: 24px;
}

.sidebar h2 {
  margin-top: 0;
  font-size: 22px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar a {
  color: #fff;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
}

.sidebar a:hover {
  background: rgba(255,255,255,.18);
}

.content {
  flex: 1;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
  color: #4b5563;
}

.card {
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,.06);
}

.card-kpi {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-kpi span {
  font-size: 28px;
  font-weight: bold;
}

.grid {
  display: grid;
  gap: 16px;
}

.cards-4 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.two-col {
  grid-template-columns: 1fr 1fr;
}

.mt {
  margin-top: 18px;
}

.header-row,
.filters-row,
.search-row,
.actions-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.header-row {
  justify-content: space-between;
}

.search-row input,
.filters-row input,
.filters-row select {
  flex: 1;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.form-card {
  max-width: 900px;
}

input, select, textarea, button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  box-sizing: border-box;
  background: #fff;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

button, .btn {
  background: #1d4ed8;
  color: #fff;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  padding: 10px 14px;
  border-radius: 10px;
}

button:hover, .btn:hover {
  background: #1e40af;
}

.btn-secondary {
  background: #6b7280;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-danger {
  background: #dc2626;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-small {
  padding: 8px 10px;
  font-size: 13px;
}

.flash {
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.flash.success { background: #dcfce7; }
.flash.warning { background: #fef3c7; }
.flash.danger { background: #fee2e2; }

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 360px;
}

.hint {
  color: #6b7280;
  font-size: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: middle;
}

.actions-cell {
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
}

.badge-gray { background: #6b7280; }
.badge-blue { background: #2563eb; }
.badge-yellow { background: #d97706; }
.badge-cyan { background: #0891b2; }
.badge-orange { background: #ea580c; }
.badge-green { background: #16a34a; }
.badge-red { background: #dc2626; }
.badge-dark { background: #374151; }

.semaforo {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);
}

.semaforo-verde { background: #22c55e; }
.semaforo-amarillo { background: #facc15; }
.semaforo-rojo { background: #ef4444; }
.semaforo-gris { background: #9ca3af; }

.success-soft {
  background: #ecfdf5;
}

.warning-soft {
  background: #fffbeb;
}

.danger-soft {
  background: #fef2f2;
}

.info-soft {
  background: #eff6ff;
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: auto;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .header-row,
  .filters-row,
  .search-row,
  .actions-row {
    flex-direction: column;
    align-items: stretch;
  }

  .actions-cell {
    white-space: normal;
  }
}

.form-grid-clientes-horizontal {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-items: start;
}

.form-grid-clientes-horizontal textarea {
  grid-column: span 3;
  min-height: 44px;
}

.form-grid-clientes-horizontal button {
  grid-column: span 1;
  align-self: stretch;
}

@media (max-width: 1100px) {
  .form-grid-clientes-horizontal {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-grid-clientes-horizontal textarea {
    grid-column: span 2;
  }

  .form-grid-clientes-horizontal button {
    grid-column: span 2;
  }
}

@media (max-width: 700px) {
  .form-grid-clientes-horizontal {
    grid-template-columns: 1fr;
  }

  .form-grid-clientes-horizontal textarea,
  .form-grid-clientes-horizontal button {
    grid-column: span 1;
  }
}

.form-section {
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.form-section h3 {
  margin-bottom: 12px;
  font-size: 16px;
  color: #1d4ed8;
}

/* GRID HORIZONTAL */
.form-grid-horizontal {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

/* RESPONSIVE */
@media (max-width: 1100px) {
  .form-grid-horizontal {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  .form-grid-horizontal {
    grid-template-columns: 1fr;
  }
}

.form-section {
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.form-section h3 {
  margin-bottom: 12px;
  font-size: 16px;
  color: #1d4ed8;
}

.form-grid-horizontal {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.adjunto-box {
  padding: 10px 12px;
  background: #eff6ff;
  border-radius: 10px;
}

@media (max-width: 1100px) {
  .form-grid-horizontal {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  .form-grid-horizontal {
    grid-template-columns: 1fr;
  }
}

.inline-form {
  display: inline-block;
  margin: 0;
}

.notas-lista {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nota-item {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
}

.nota-cabecera {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #374151;
}

.nota-item p {
  margin-top: 0;
  margin-bottom: 10px;
  white-space: pre-wrap;
}

@media (max-width: 700px) {
  .nota-cabecera {
    flex-direction: column;
  }
}

.role-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  font-size: 12px;
}

.alert-card {
  border: 2px solid #fecaca;
}

.cards-4 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}