/* ─── Variables ────────────────────────────────────────────── */
:root {
  --primary:       #1e3a5f;
  --primary-dk:    #162d4a;
  --accent:        #2563eb;
  --success:       #16a34a;
  --error:         #dc2626;
  --bg:            #f1f5f9;
  --card:          #ffffff;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --muted:         #64748b;
  --radius:        10px;
  --shadow:        0 2px 14px rgba(0,0,0,0.07);
}

/* ─── Reset básico ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Header ───────────────────────────────────────────────── */
.app-header {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.header-sub {
  font-size: 12.5px;
  opacity: 0.65;
  white-space: nowrap;
}

/* ─── Main layout ──────────────────────────────────────────── */
.app-main {
  max-width: 860px;
  margin: 32px auto 80px;
  padding: 0 20px;
}

/* ─── Steps bar ────────────────────────────────────────────── */
.steps-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  gap: 0;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 80px;
}

.step-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s, color 0.25s;
}

.step.active .step-dot  { background: var(--primary); color: #fff; }
.step.done   .step-dot  { background: var(--success);  color: #fff; }

.step-lbl {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.step.active .step-lbl  { color: var(--primary); font-weight: 700; }

.step-line {
  flex: 1;
  max-width: 72px;
  height: 2px;
  background: var(--border);
  margin-bottom: 22px;
}

/* ─── Card / Panel ─────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  border: 1px solid var(--border);
}

.card h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}

.subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
}

/* ─── Campo inválido (null post-validación) ─────────────────── */
.cell-invalid {
  background: #fff1f2;
  color: #b91c1c;
  font-weight: 600;
}

.badge-ok   { display: inline-block; background: #dcfce7; color: #166534;
              padding: 1px 7px; border-radius: 4px; font-size: 13px; font-weight: 600; }
.badge-warn { display: inline-block; background: #fff7ed; color: #9a3412;
              padding: 1px 7px; border-radius: 4px; font-size: 13px; font-weight: 600; }

/* ─── Drop zone ────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  outline: none;
}

.drop-zone:hover,
.drop-zone:focus,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: #eff6ff;
}

.drop-icon { color: var(--muted); margin-bottom: 14px; transition: color 0.2s; }
.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon { color: var(--accent); }

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

.drop-copy strong { font-size: 16px; }
.drop-copy span   { font-size: 14px; color: var(--muted); }
.drop-hint        { margin-top: 10px; font-size: 12px; color: var(--muted); }

.file-hidden {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ─── File badge ───────────────────────────────────────────── */
.file-badge {
  margin-top: 14px;
  padding: 10px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 14px;
  color: #166534;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.18s, transform 0.12s, box-shadow 0.18s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dk);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(30,58,95,0.28);
}

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; margin-top: 18px; }

/* ─── Form fieldsets ───────────────────────────────────────── */
.fset {
  border: none;
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.fset:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.fset legend {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 16px;
}

.grid { display: grid; gap: 14px; }
.g2   { grid-template-columns: 1fr 1fr; }
.g-span2 { grid-column: 1 / -1; }

.fg {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

input[type="text"],
input[type="number"] {
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  width: 100%;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
input.ok {
  background: #f0fdf4;
  border-color: #86efac;
}
input.warn {
  background: #fff7ed;
  border-color: #fdba74;
}

/* ─── Form actions ─────────────────────────────────────────── */
.form-actions {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.form-actions.centered { justify-content: center; }

/* ─── Loading ──────────────────────────────────────────────── */
.loading-wrap {
  text-align: center;
  padding: 40px 0;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 22px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}
.loading-sub { font-size: 14px; color: var(--muted); }

/* ─── Result ────────────────────────────────────────────────── */
.result-wrap { text-align: center; padding: 16px 0 24px; }

.result-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}
.result-icon.success { background: #dcfce7; color: var(--success); }
.result-icon.error   { background: #fee2e2; color: var(--error); }

.result-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.result-title.success { color: var(--success); }
.result-title.error   { color: var(--error); }

.result-msg { font-size: 15px; color: var(--muted); max-width: 440px; margin: 0 auto; }

/* ─── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 18px rgba(0,0,0,0.16);
  z-index: 9999;
  max-width: 380px;
  animation: slideIn 0.28s ease;
}
.toast.t-error   { background: var(--error);   color: #fff; }
.toast.t-success { background: var(--success);  color: #fff; }

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

/* ─── File list ────────────────────────────────────────────── */
.file-list {
  list-style: none;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  font-size: 13px;
  color: #166534;
}

.file-item svg       { flex-shrink: 0; }
.file-item-name      { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-item-size      { color: #4d7c5e; font-size: 12px; white-space: nowrap; }

/* ─── Progress ─────────────────────────────────────────────── */
.progress-wrap {
  width: 100%;
  max-width: 360px;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin: 16px auto 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ─── Table panel layout ────────────────────────────────────── */
.app-main.main-wide { max-width: 1400px; }

.table-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}
.table-header h2 { margin-bottom: 4px; }

.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.chk-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.btn-sm { padding: 7px 16px; font-size: 13px; }

/* ─── Review table ──────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

#reviewTable {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 13px;
}

#reviewTable th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 9px 10px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

#reviewTable td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  min-width: 110px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#reviewTable .col-check,
#reviewTable th.col-check  { min-width: 36px; width: 36px; text-align: center; }
#reviewTable .col-status,
#reviewTable th.col-status { min-width: 80px; width: 80px; }

#reviewTable tbody tr:last-child td { border-bottom: none; }
#reviewTable tbody tr:hover          { background: #f8fafc; }

[data-col][contenteditable]:focus {
  outline: none;
  background: #eff6ff;
  box-shadow: inset 0 0 0 2px var(--accent);
  white-space: normal;
  overflow: visible;
  max-width: none;
}

.tbl-select {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  width: 100%;
  min-width: 80px;
}

.badge-error {
  display: inline-block;
  background: #fee2e2;
  color: #b91c1c;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
}

.cell-error {
  color: var(--error);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.cell-error .btn-retry {
  flex-shrink: 0;
  padding: 3px 10px;
  font-size: 12px;
  border-color: var(--error);
  color: var(--error);
}
.cell-error .btn-retry:hover { background: #fee2e2; }

/* ─── Result summary table ──────────────────────────────────── */
.result-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  font-size: 14px;
  text-align: left;
}

.result-table th {
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.result-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.result-table .row-ok  td { background: #f0fdf4; }
.result-table .row-err td { background: #fff1f2; }

/* ─── Warn toast ────────────────────────────────────────────── */
.toast.t-warn { background: #d97706; color: #fff; }

/* ─── Fila expansión (campos opcionales) ─────────────────────── */
.expand-cell {
  padding: 10px 16px !important;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
}

.expand-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: flex-end;
}

.expand-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 130px;
}

.expand-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.expand-input {
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 120px;
}

.expand-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.12);
  white-space: normal;
  overflow: visible;
  color: var(--text);
}

.expand-input.cell-invalid {
  background: #fff1f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.expand-select { min-width: 120px; }

/* ─── Botón "Ver más" ─────────────────────────────────────────── */
#reviewTable .col-expand,
#reviewTable th.col-expand { min-width: 68px; width: 68px; text-align: center; }

.btn-expand {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-expand:hover  { border-color: var(--accent); color: var(--accent); }
.btn-expand.expanded {
  border-color: var(--accent);
  color: var(--accent);
  background: #eff6ff;
}

/* ─── Auth overlay ──────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 9998;
  font-size: 15px;
  color: var(--muted);
}

.auth-overlay-error {
  color: var(--error);
  font-size: 14px;
  text-align: center;
  max-width: 360px;
}

/* ─── Header right (user info + actions) ────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.header-user {
  font-size: 13px;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.header-role {
  font-size: 11px;
  background: rgba(255,255,255,0.15);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.header-logo {
  height: 28px;
  width: auto;
  border-radius: 3px;
  object-fit: contain;
}

/* ─── Login page ─────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 28px rgba(0,0,0,0.1);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.login-icon {
  width: 72px;
  height: 72px;
  background: #eff6ff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  margin-bottom: 20px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}

.login-error {
  width: 100%;
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  text-align: left;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: box-shadow 0.18s, border-color 0.18s;
  margin-bottom: 20px;
}

.btn-google:hover:not(:disabled) {
  border-color: #aab4c4;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

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

.login-help {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* ─── Config page ────────────────────────────────────────────── */
.config-header {
  margin-bottom: 24px;
}

.config-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}

.config-section {
  margin-bottom: 24px;
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.color-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.color-row input[type="color"] {
  width: 42px;
  height: 42px;
  padding: 2px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.usage-bar {
  margin-top: 20px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.usage-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.dt-status {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

.dt-status.dt-ok   { background: #dcfce7; color: #166534; }
.dt-status.dt-warn { background: #fff7ed; color: #9a3412; }

/* ─── Add user form ──────────────────────────────────────────── */
.add-user-form {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.add-user-form .fg { min-width: 160px; }

/* ─── Users table ────────────────────────────────────────────── */
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.users-table th {
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: left;
}

.users-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.users-table tbody tr:last-child td { border-bottom: none; }
.users-table tbody tr:hover { background: #f8fafc; }

.badge-rol {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.badge-rol.admin       { background: #ede9fe; color: #5b21b6; }
.badge-rol.funcionario { background: #dbeafe; color: #1e40af; }

.btn-remove-user { color: var(--error); border-color: var(--error); }
.btn-remove-user:hover { background: #fee2e2; }

.muted-text { font-size: 14px; color: var(--muted); }

/* ─── Helpers ───────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
  .header-inner { flex-direction: column; align-items: flex-start; gap: 4px; }
  .header-sub   { display: none; }
  .card         { padding: 20px 16px; }
  .g2           { grid-template-columns: 1fr; }
  .g-span2      { grid-column: auto; }
  .form-actions { flex-direction: column; }
  .btn-block    { margin-top: 12px; }
}
