:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #e1e5ea;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #1f3b57;
  --accent-2: #e06c2c;
  --sidebar-bg: #16232f;
  --sidebar-text: #cdd6df;
}

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

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

.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  flex-shrink: 0;
}
.sidebar .brand { font-weight: 700; font-size: 20px; padding: 0 20px 20px; color: white; letter-spacing: 1px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 10px 20px;
  font-size: 14px;
}
.sidebar nav a.sub { padding-left: 34px; font-size: 13px; }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,0.08); color: white; }
.nav-group-label { padding: 12px 20px 2px; font-size: 11px; text-transform: uppercase; color: #7b8794; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: space-between; font-size: 13px; }
.sidebar-footer a { color: var(--sidebar-text); text-decoration: underline; }

.content { flex: 1; padding: 28px 36px; max-width: 1200px; }

h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 12px 0 6px; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.kpi-card.kpi-alert { border-color: var(--accent-2); background: #fff6ef; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--accent); }
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-sub { font-size: 12px; color: var(--accent-2); margin-top: 4px; }

.table-scroll { overflow-x: auto; max-width: 100%; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; padding: 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table.compact td, .table.compact th { padding: 4px 8px; font-size: 13px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; background: #eee; color: #444; }
.badge-done, .badge-ready { background: #dff5e1; color: #1e7b34; }
.badge-pending, .badge-analyzing, .badge-generating, .badge-indexing { background: #fff3cd; color: #92720c; }
.badge-blocked { background: #fde2e1; color: #b3261e; }
.badge-error { background: #fde2e1; color: #b3261e; }
.badge-pendiente-revision { background: #fff3cd; color: #92720c; }
.badge-aprobado, .badge-editado-aprobado { background: #dff5e1; color: #1e7b34; }

.muted { color: var(--muted); }
.muted.small { font-size: 11px; }

.btn, .btn-secondary {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
.btn { background: var(--accent); color: white; }
.btn-secondary { background: #eef1f4; color: var(--text); }

.form-card, .login-card { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.form-card fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.form-card legend { font-weight: 600; padding: 0 6px; }
.form-card label, .login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
input, select, textarea {
  font-size: 14px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
}
.trace-grid { display: flex; gap: 10px; align-items: flex-end; }
.trace-grid label { flex-direction: row; align-items: center; gap: 6px; }
.inline-legend { font-size: 13px; color: var(--muted); width: 100%; margin-bottom: 4px; }

.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.login-screen { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--sidebar-bg); }
.login-card { background: white; padding: 32px; border-radius: 12px; width: 320px; }
.error { color: #b3261e; font-size: 13px; }

.alert-box { background: #fff3cd; border: 1px solid #f0d999; border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; font-size: 14px; white-space: pre-wrap; }
.alert-box.ethics-alert { background: #fde2e1; border-color: #f3b4b0; color: #7a1a15; }

.plain-list { margin: 0; padding-left: 18px; font-size: 14px; }

.timeline { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.timeline-item { border-left: 3px solid var(--accent); padding-left: 12px; }
.timeline-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; font-size: 13px; }

.synthesis-box { background: #f8fafc; border-radius: 8px; padding: 12px; margin-bottom: 12px; font-size: 14px; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs .tab { padding: 8px 14px; text-decoration: none; color: var(--muted); font-size: 14px; border-bottom: 2px solid transparent; }
.tabs .tab.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }

.upload-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.upload-choice { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

.upload-progress { margin-top: 14px; padding: 12px 14px; background: #f8fafc; border-radius: 8px; border: 1px solid var(--border); }
.upload-progress-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; }
.upload-progress-track { height: 8px; background: #e1e5ea; border-radius: 4px; overflow: hidden; }
.upload-progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.2s ease; }
.curate-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; padding: 10px; background: #f8fafc; border-radius: 8px; min-width: 260px; }
.curate-form label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }

.action-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; max-width: 220px; }
.action-row form { margin: 0; }
.action-details { position: relative; }
.action-details > summary { list-style: none; cursor: pointer; }
.action-details > summary::-webkit-details-marker { display: none; }
.action-details[open] .curate-form { position: absolute; z-index: 5; right: 0; box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.btn-icon-danger {
  border: none; background: #fde2e1; color: #b3261e; border-radius: 8px;
  width: 32px; height: 32px; font-size: 15px; cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.btn-icon-danger:hover { background: #fbc9c7; }
.inline-check { flex-direction: row !important; align-items: center; gap: 6px; font-size: 12px; }

.transcript-box { white-space: pre-wrap; font-size: 13px; background: #f8fafc; padding: 12px; border-radius: 8px; max-height: 400px; overflow-y: auto; }

textarea { width: 100%; }
