/* ---------- Tipografía local (sin CDN de Google Fonts) ---------- */
@font-face {
  font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/Poppins-Regular.ttf') format('truetype');
}
@font-face {
  font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/Poppins-Medium.ttf') format('truetype');
}
@font-face {
  font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/Poppins-Bold.ttf') format('truetype');
}
@font-face {
  font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/Poppins-Bold.ttf') format('truetype');
}
@font-face {
  font-family: 'Poppins'; font-style: italic; font-weight: 400; font-display: swap;
  src: url('fonts/Poppins-Italic.ttf') format('truetype');
}

/* ---------- Iconos (Material Icons, Google Fonts, servidos en local) ---------- */
@font-face {
  font-family: 'Material Icons'; font-style: normal; font-weight: 400; font-display: block;
  src: url('fonts/MaterialIcons.ttf') format('truetype');
}
.material-icons {
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  font-size: inherit;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga', 'rlig';
  font-feature-settings: 'liga', 'rlig';
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  padding: 2rem;
  background: #f4f2f0;
  font-family: 'Poppins', sans-serif;
  color: #1a1a1a;
}

/* ---------- Auth (login / registro) ---------- */
.auth-wrap {
  min-height: calc(100vh - 4rem);
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: #ffffff;
  border: 0.5px solid #e5e2e0;
  border-radius: 14px;
  padding: 2.25rem 2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.auth-logo { display:flex; align-items:center; gap:10px; margin-bottom: 1.5rem; }
.auth-logo img { height: 72px; width: auto; object-fit: contain; }
.auth-logo span { font-size: 17px; font-weight: 500; }
.auth-card h1 { font-size: 20px; font-weight: 500; margin: 0 0 0.25rem; }
.auth-card p.sub { font-size: 13px; color: #6b6863; margin: 0 0 1.5rem; }

label { display:block; font-size: 12.5px; color:#6b6863; margin-bottom: 4px; margin-top: 14px; }
input[type=text], input[type=email], input[type=password] {
  width: 100%; padding: 10px 12px; border: 0.5px solid #d9d5d2; border-radius: 8px;
  font-family: 'Poppins', sans-serif; font-size: 13.5px; background: #fff;
}
input:focus { outline: none; border-color: #821436; }

.btn-primary {
  margin-top: 20px; width: 100%; background: #821436; color: #fff; border: none;
  border-radius: 9px; padding: 11px; font-family: 'Poppins', sans-serif; font-size: 14px;
  font-weight: 500; cursor: pointer;
}
.btn-primary:hover { background: #6c1029; }

.auth-footer { margin-top: 18px; font-size: 12.5px; color: #6b6863; text-align: center; }
.auth-footer a { color: #821436; text-decoration: none; font-weight: 500; }

.progress-panel {
  background: #fff; border: 1px solid #efece7; border-radius: 12px;
  padding: 28px; max-width: 560px; margin-top: 12px;
}
.progress-bar-track {
  width: 100%; height: 14px; background: #f1efeb; border-radius: 999px;
  overflow: hidden; margin-bottom: 14px;
}
.progress-bar-fill {
  height: 100%; background: linear-gradient(90deg, #821436, #b12252);
  border-radius: 999px; transition: width 0.4s ease;
}
.progress-counter { font-size: 14px; font-weight: 600; color: #2c2a27; margin-bottom: 4px; }
.progress-current { font-size: 13px; color: #6b6863; margin-bottom: 18px; min-height: 18px; }
.progress-hint { font-size: 12px; color: #a3a09b; line-height: 1.5; }

.flash { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.flash-error { background: #fdeceb; color: #a4231a; }
.flash-success { background: #e6f4ec; color: #1a7f4b; }
.flash-warning { background: #fdf1dd; color: #92600b; }
.flash-info { background: #eef2fb; color: #2b4a9b; }

.mail-test-form {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px; padding: 10px 14px; background: #f7f5f3; border-radius: 8px;
}
.btn-secondary {
  background: #fff; color: #821436; border: 1px solid #821436; border-radius: 8px;
  padding: 8px 14px; font-family: 'Poppins', sans-serif; font-size: 13px;
  font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn-secondary:hover { background: #fdeef1; }
.mail-test-form .hint { font-size: 12px; color: #6b6863; }

/* ---------- Dashboard shell ---------- */
.app { max-width: 1440px; width: 100%; margin: 0 auto; background: #ffffff; border-radius: 14px;
  border: 0.5px solid #e5e2e0; display: flex; min-height: calc(100vh - 4rem); overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

.sidebar { width: 240px; flex-shrink: 0; border-right: 0.5px solid #ececea; padding: 1.75rem 1.1rem;
  display: flex; flex-direction: column; gap: 6px; background: #fafafa; }
.logo-row { display:flex; flex-direction:column; align-items:flex-start; gap:2px; padding: 0 0.5rem 1.4rem; }
.logo-row img { width: 100%; max-width: 150px; height: auto; object-fit: contain; }
.logo-row span { font-size: 12px; font-weight: 500; color:#6b6863; white-space: nowrap; }

.navlink { display:flex; align-items:center; gap:12px; padding:10px 12px; border-radius:9px;
  text-decoration:none; color:#6b6863; font-size:14px; white-space:nowrap; }
.navlink.active { background: rgba(130,20,54,0.08); color:#821436; }
.navlink .material-icons { font-size:19px; flex-shrink:0; }

.user-row { margin-top:auto; display:flex; align-items:center; gap:8px; padding:14px 10px 0;
  border-top:0.5px solid #ececea; }
.avatar { width:32px; height:32px; border-radius:50%; background: rgba(130,20,54,0.08);
  display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:500;
  color:#821436; flex-shrink:0; }
.user-info { min-width:0; overflow:hidden; }
.user-info p { margin:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-info .user-name { font-size:12px; font-weight:500; }
.user-info .user-email { font-size:11px; color:#a3a09b; }
.logout-link { margin-left:auto; flex-shrink:0; color:#a3a09b; text-decoration:none; font-size:16px; }

.main { flex:1; padding: 2rem 2.5rem; min-width:0; overflow-y:auto; }
h1.page-title { margin: 0 0 1.5rem; font-size: 24px; font-weight: 500; }

.metrics { display:grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap:16px; margin-bottom:2rem; }
.metric-card { background:#faf9f8; border:0.5px solid #ececea; border-radius:10px; padding:1.25rem 1.3rem; min-width:0; }
.metric-head { display:flex; align-items:center; gap:8px; margin-bottom:10px; }
.metric-ico { width:28px; height:28px; border-radius:8px; display:flex; align-items:center; justify-content:center;
  background:rgba(107,104,99,0.1); color:#6b6863; font-size:16px; flex-shrink:0; }
.metric-ico.ok { background:rgba(26,127,75,0.1); color:#1a7f4b; }
.metric-ico.wait { background:rgba(43,74,155,0.1); color:#2b4a9b; }
.metric-ico.err { background:rgba(164,35,26,0.1); color:#a4231a; }
.metric-ico.accent { background:rgba(130,20,54,0.1); color:#821436; }
.metric-card p.label { margin:0; font-size:12.5px; color:#6b6863; line-height:1.2; }
.metric-card p.value { margin:0; font-size:28px; font-weight:600; line-height:1.1; }
.metric-card p.value.accent { color:#821436; }
.metric-card p.metric-sub { margin:6px 0 0; font-size:11px; color:#a3a09b; }

.upload-card { background: rgba(130,20,54,0.05); border:1px dashed rgba(130,20,54,0.35);
  border-radius:14px; padding:2.25rem; margin-bottom:2rem; text-align:center; }
.upload-card .material-icons.file-icon { font-size:32px; color:#821436; }
.upload-card p.title { margin:14px 0 4px; font-size:16px; font-weight:500; }
.upload-card p.sub { margin:0 0 18px; font-size:13px; color:#a3a09b; }
.upload-card input[type=file] { display:none; }
.upload-card label.file-label { display:inline-block; background:#fff; border:0.5px solid #d9d5d2;
  border-radius:9px; padding:9px 18px; font-size:13px; cursor:pointer; margin-bottom:12px; }
button#upload-btn { font-family:'Poppins',sans-serif; font-size:14px; background:#821436; color:#fff;
  border:0.5px solid #821436; border-radius:9px; padding:10px 20px; cursor:pointer; }
button#upload-btn:disabled { opacity:0.6; cursor:not-allowed; }
#file-chosen { font-size:12.5px; color:#6b6863; margin-top:8px; }
.upload-card.dragover { background: rgba(130,20,54,0.1); border-color:#821436; }
.upload-error { margin-top:10px; font-size:12.5px; color:#a4231a; background:#fdeceb; border-radius:8px;
  padding:8px 12px; display:inline-block; }

/* ---------- Lotes en proceso ---------- */
.active-batches { margin-bottom:2rem; }
.active-label { display:flex; align-items:center; gap:8px; margin:0 0 10px; font-size:14px; font-weight:500; color:#2b4a9b; }
.active-label .material-icons { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.active-item { display:flex; align-items:center; justify-content:space-between; gap:12px; text-decoration:none;
  background:#eef2fb; border:0.5px solid #d7e0f5; border-radius:10px; padding:12px 16px; margin-bottom:8px; }
.active-item:hover { background:#e4ebf9; }
.active-item-info { display:flex; flex-direction:column; gap:2px; min-width:0; }
.active-item-name { font-size:13.5px; font-weight:500; color:#1a1a1a; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.active-item-meta { font-size:11.5px; color:#6b6863; }
.active-item-cta { display:inline-flex; align-items:center; gap:4px; font-size:12.5px; font-weight:500; color:#2b4a9b; white-space:nowrap; flex-shrink:0; }

/* ---------- Controles del historial ---------- */
.history-header { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:10px; }
.history-header .history-label { margin:0; }
.history-controls { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.history-search { display:flex; align-items:center; gap:6px; background:#faf9f8; border:0.5px solid #d9d5d2;
  border-radius:8px; padding:6px 10px; }
.history-search .material-icons { font-size:15px; color:#a3a09b; }
.history-search input { border:none; background:transparent; font-family:'Poppins',sans-serif; font-size:13px;
  color:#1a1a1a; outline:none; width:170px; padding:0; }
#history-filter { font-family:'Poppins',sans-serif; font-size:13px; color:#1a1a1a; background:#faf9f8;
  border:0.5px solid #d9d5d2; border-radius:8px; padding:7px 10px; cursor:pointer; }
th.sortable { cursor:pointer; user-select:none; }
th.sortable:hover { color:#821436; }
.sort-ico { font-size:13px; vertical-align:-1px; }
.history-more-wrap { text-align:center; margin-top:14px; }

.mail-dry-run-banner { background:#fdf1dd; color:#92600b; font-size:12.5px; padding:8px 12px;
  border-radius:8px; margin-bottom:16px; }

.history-label { margin:0 0 10px; font-size:14px; font-weight:500; color:#6b6863; }
.table-scroll { width:100%; overflow-x:auto; }
table { width:100%; border-collapse:collapse; font-size:14px; }
th { text-align:left; padding:10px 6px; color:#a3a09b; font-weight:400; border-bottom:0.5px solid #ececea; white-space:nowrap; }
th.num { text-align:right; }
td { padding:12px 6px; border-bottom:0.5px solid #ececea; }
td.muted { color:#6b6863; }
td.num { text-align:right; }
tr.clickable { cursor:pointer; }
tr.clickable:hover { background:#faf9f8; }
.badge { font-size:11px; padding:2px 8px; border-radius:99px; white-space:nowrap; }
.badge.success { background:#e6f4ec; color:#1a7f4b; }
.badge.warning { background:#fdf1dd; color:#92600b; }
.badge.error { background:#fdeceb; color:#a4231a; }
.badge.pending { background:#eef2fb; color:#2b4a9b; }

.back-link { display:inline-flex; align-items:center; gap:6px; color:#6b6863; text-decoration:none;
  font-size:13px; margin-bottom:16px; transition: color 0.15s ease; }
.back-link:hover { color:#821436; }
.back-arrow { font-size:16px; line-height:1; transition: transform 0.15s ease; }
.back-link:hover .back-arrow { transform: translateX(-3px); }
.empty-state { text-align:center; padding: 2rem; color:#a3a09b; font-size:13.5px; }
.empty-first { border:1px dashed #e0dcd9; border-radius:12px; padding:2.5rem 1.5rem; }
.empty-first .material-icons { font-size:34px; color:#c9c4bf; }
.empty-first .empty-title { margin:12px 0 4px; font-size:15px; font-weight:500; color:#6b6863; }
.empty-first .empty-sub { margin:0; font-size:13px; color:#a3a09b; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  body { padding: 0.75rem; }
  .app { flex-direction: column; min-height: unset; max-width: 100%; }
  .sidebar { width:100%; flex-direction:row; align-items:center; flex-wrap:wrap;
    border-right:none; border-bottom:0.5px solid #ececea; padding:0.65rem 0.85rem; gap:4px 6px; }
  .logo-row { padding:0; margin-right:auto; flex-direction:row; align-items:center; gap:6px; }
  .logo-row img { max-width: 90px; }
  .logo-row span { display:none; }
  .navlink { padding:6px 8px; }
  .user-row { margin-top:0; border-top:none; padding:0; margin-left:8px; }
  .user-info { display:none; }
  .main { padding:1rem; }
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 480px) {
  h1.page-title { font-size:16px; }
  .metrics { grid-template-columns: 1fr 1fr; gap:8px; }
  .metric-card { padding:0.75rem; }
  .metric-card p.value { font-size:18px; }
  .navlink .nav-text { display:none; }
  .navlink { padding:6px; }
  .upload-card { padding:1.1rem 0.85rem; }

  table, thead, tbody, tr, td { display:block; width:100%; }
  thead { display:none; }
  tbody tr { border:0.5px solid #ececea; border-radius:8px; padding:8px 10px; margin-bottom:10px; }
  tbody tr td { border-bottom:none; padding:4px 0; display:flex; justify-content:space-between;
    align-items:center; gap:8px; white-space:normal; }
  tbody tr td::before { content: attr(data-label); font-size:11px; color:#a3a09b; flex-shrink:0; }
  td.num { text-align:right; }
}
