:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #e2e6ea;
  --text: #1c2530;
  --text-muted: #6b7686;
  --primary: #0f5fa8;
  --primary-dark: #0b4a84;
  --green: #1a8754;
  --green-bg: #e8f7ef;
  --red: #c0392b;
  --red-bg: #fbeae8;
  --amber: #b7791f;
  --amber-bg: #fdf3e0;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

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

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #12233b;
  color: #fff;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.brand-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  text-align: left;
  background: transparent;
  border: none;
  color: #c5d2e0;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-btn.active {
  background: var(--primary);
  color: #fff;
}

.main {
  flex: 1;
  padding: 28px 36px;
  min-width: 0;
}

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

.topbar h1 {
  font-size: 20px;
  margin: 0;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #f0f2f4; }

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 0;
}

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

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.card .card-label {
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.card .card-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 6px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-form { padding: 22px 24px; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}

.panel-header h2 {
  font-size: 15px;
  margin: 0;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filters select,
.filters input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  background: #fff;
}

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 10px 16px;
  border-bottom: 1px solid #eef1f4;
  white-space: nowrap;
}

.table tbody tr:hover { background: #fafbfc; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}

.badge-alta { background: var(--green-bg); color: var(--green); }
.badge-baja { background: var(--red-bg); color: var(--red); }
.badge-mod { background: var(--amber-bg); color: var(--amber); }

.empty-row td {
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
}

.pdf-upload {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
  background: #fafbfd;
}

.pdf-upload-label {
  display: block;
  cursor: pointer;
  margin-bottom: 8px;
}

.pdf-upload-label strong {
  display: block;
  font-size: 13.5px;
  margin-bottom: 2px;
}

.pdf-upload-label span {
  color: var(--text-muted);
  font-size: 12.5px;
}

.pdf-status {
  font-size: 12.5px;
  margin-top: 6px;
}

.pdf-status.ok { color: var(--green); }
.pdf-status.warn { color: var(--amber); }
.pdf-status.err { color: var(--red); }

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

.field { display: flex; flex-direction: column; gap: 5px; }
.field-wide { grid-column: 1 / -1; }

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.form-mensaje { font-size: 13px; }
.form-mensaje.ok { color: var(--green); }
.form-mensaje.err { color: var(--red); }

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 33, 0.45);
  align-items: center;
  justify-content: center;
  z-index: 50;
}

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

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px 24px;
  width: 360px;
  max-width: 90vw;
}

.modal h3 { margin: 0 0 16px; font-size: 16px; }

.modal .field { margin-bottom: 12px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; }
  .nav { flex-direction: row; }
  .main { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 340px;
  max-width: 100%;
  text-align: center;
}

.login-mark {
  display: inline-block;
  margin-bottom: 14px;
}

.login-card h1 {
  font-size: 17px;
  margin: 0 0 22px;
}

.login-card .field {
  text-align: left;
  margin-bottom: 14px;
}

.login-btn {
  width: 100%;
  margin-top: 4px;
  padding: 10px 16px;
}

.login-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  min-height: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.modal-wide {
  width: 720px;
  max-width: 92vw;
  max-height: 86vh;
  overflow-y: auto;
  text-align: left;
}

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

.modal-header h3 {
  margin: 0;
}

.nombre-clickable {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  font-size: inherit;
  font-family: inherit;
}

.nombre-clickable:hover {
  text-decoration: underline;
}

.detalle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.detalle-item .detalle-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
}

.detalle-item .detalle-valor {
  font-size: 14px;
  margin-top: 3px;
}

.detalle-subtitulo {
  font-size: 14px;
  margin: 0 0 10px;
}
