:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --border: #e7e5e4;
  --primary: #16a34a;
  --primary-hover: #15803d;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.patch-bg {
  background: #3d5aa3;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 20px;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("/assets/img/parche-fondo.jpg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  opacity: 0.08;
  z-index: 0;
}

.card > * {
  position: relative;
  z-index: 1;
}

h1 { font-size: 1.5rem; margin: 0 0 8px; }
p.subtitle { color: var(--muted); margin: 0 0 24px; }

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 18px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

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

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > div {
  min-width: 0;
}

.form-row-grado {
  flex: 0 0 90px;
}

.form-row-ffaa {
  flex: 1;
}

.field-error {
  color: var(--danger);
  font-size: 0.825rem;
  margin: -12px 0 18px;
  min-height: 1em;
}

button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover { background: var(--primary-hover); }

@media (max-width: 480px) {
  #submit-btn {
    width: 100%;
  }
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  max-width: calc(100vw - 40px);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

.toast-success { background: #dcfce7; color: #166534; }

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

.topbar a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.topbar a:hover { color: var(--text); }

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

.btn-excel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.btn-excel:hover { color: var(--text); }

.topbar-separator {
  color: var(--border);
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.table-toolbar select {
  width: auto;
  margin-bottom: 0;
  padding: 6px 10px;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.page-link {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
}

.page-link:hover { background: #fafaf9; }

.page-link.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.page-link.disabled {
  pointer-events: none;
  color: var(--muted);
  opacity: 0.5;
}

.thumb {
  max-width: 42px;
  max-height: 42px;
  margin: 2px;
  border-radius: 6px;
  cursor: pointer;
  object-fit: cover;
  display: block;
}

.fotos-cell {
  text-align: center;
  vertical-align: middle;
}

.fotos-cell-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

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

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 16px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-box img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  object-fit: contain;
}

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

.btn-modal {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-modal-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-modal-primary:hover {
  background: var(--primary-hover);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

th { background: #fafaf9; font-weight: 600; }
tr:last-child td { border-bottom: none; }

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

.admin-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px;
}
