/* ── Variables ──────────────────────────────────────── */
:root {
  --navy:       #0f172a;
  --navy-light: #1e293b;
  --navy-mid:   #334155;
  --amber:      #f59e0b;
  --amber-dark: #d97706;
  --blue:       #3b82f6;
  --green:      #22c55e;
  --red:        #ef4444;
  --yellow:     #eab308;
  --gray-50:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-400:   #94a3b8;
  --gray-600:   #475569;
  --gray-800:   #1e293b;
  --text:       #0f172a;
  --text-muted: #64748b;
  --sidebar-w:  240px;
}

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; background: var(--gray-100); color: var(--text); display: flex; min-height: 100vh; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ── Sidebar ────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--navy-mid);
}
.brand-icon { font-size: 28px; color: var(--amber); }
.brand-name { font-size: 16px; font-weight: 700; color: #fff; line-height: 1; }
.brand-sub  { font-size: 10px; color: var(--gray-400); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  padding: 10px 16px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #94a3b8;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  font-size: 13.5px;
}
.nav-item:hover { background: var(--navy-light); color: #fff; }
.nav-item.active { background: var(--amber); color: var(--navy); font-weight: 600; }
.nav-icon { width: 18px; text-align: center; font-size: 14px; }
.nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--navy-mid);
}
.sidebar-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--gray-400); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray-400); }
.status-dot.ok  { background: var(--green); }
.status-dot.err { background: var(--red); }

/* ── Main Layout ────────────────────────────────────── */
.main-layout {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title { font-size: 18px; font-weight: 600; color: var(--navy); }
.content { padding: 24px; flex: 1; }

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  padding: 20px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--navy); }

/* ── KPI Cards ──────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--navy); line-height: 1; }
.kpi-sub   { font-size: 12px; color: var(--text-muted); }
.kpi-accent-amber { border-top: 3px solid var(--amber); }
.kpi-accent-blue  { border-top: 3px solid var(--blue); }
.kpi-accent-green { border-top: 3px solid var(--green); }
.kpi-accent-red   { border-top: 3px solid var(--red); }

/* ── Buttons ────────────────────────────────────────── */
.btn { padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; transition: opacity 0.15s, background 0.15s; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { opacity: 0.88; }
.btn-primary { background: var(--amber); color: var(--navy); }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-blue    { background: var(--blue); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ── Tables ─────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; }
.data-table th {
  background: var(--gray-100);
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--gray-200);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--text);
  font-size: 13px;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }
.td-actions { display: flex; gap: 6px; }

/* ── Badges / Status ────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-gray   { background: var(--gray-200); color: var(--gray-600); }
.badge-amber  { background: #fef3c7; color: #b45309; }
.badge-navy   { background: var(--navy); color: #fff; }

/* ── Forms ──────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--gray-600); }
.form-control {
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s;
  width: 100%;
}
.form-control:focus { outline: none; border-color: var(--amber); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

/* ── Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-lg { max-width: 820px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-200);
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--navy); }
.modal-close { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; color: var(--text-muted); transition: background 0.15s; }
.modal-close:hover { background: var(--gray-100); }
.modal-body  { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Toast ──────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  min-width: 240px;
  max-width: 360px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.2s ease;
}
.toast.success { border-left: 4px solid var(--green); }
.toast.error   { border-left: 4px solid var(--red); }
.toast.info    { border-left: 4px solid var(--blue); }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Workflow Timeline ──────────────────────────────── */
.workflow-timeline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 12px 0;
}
.wf-step {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--gray-100);
  color: var(--text-muted);
  border: 1px solid var(--gray-200);
}
.wf-step.done    { background: #dcfce7; color: #15803d; border-color: #86efac; }
.wf-step.current { background: var(--amber); color: var(--navy); border-color: var(--amber-dark); font-weight: 600; }
.wf-step.rejected{ background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.wf-arrow { color: var(--gray-400); font-size: 12px; }

/* ── Detail Sections ────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.detail-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 20px; }
.detail-item label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); display: block; }
.detail-item span  { font-size: 13px; color: var(--text); }

/* ── Search bar ─────────────────────────────────────── */
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: 6px; font-size: 13px; }
.search-input:focus { outline: none; border-color: var(--amber); }

/* ── Loading ────────────────────────────────────────── */
.loading-spinner { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px; color: var(--text-muted); gap: 12px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--gray-200); border-top-color: var(--amber); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 48px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 10px; }

/* ── Alert boxes ────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-success { background: #dcfce7; color: #15803d; border-left: 4px solid var(--green); }
.alert-error   { background: #fee2e2; color: #b91c1c; border-left: 4px solid var(--red); }
.alert-info    { background: #dbeafe; color: #1d4ed8; border-left: 4px solid var(--blue); }
.alert-warning { background: #fef9c3; color: #a16207; border-left: 4px solid var(--yellow); }

/* ── Validation result (API 598) ────────────────────── */
.validation-box { border-radius: 8px; padding: 16px; margin-top: 16px; }
.validation-box.pass { background: #dcfce7; border: 1px solid #86efac; }
.validation-box.fail { background: #fee2e2; border: 1px solid #fca5a5; }
.validation-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.validation-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; border-bottom: 1px solid rgba(0,0,0,0.06); }
.validation-obs { margin-top: 10px; font-size: 12px; line-height: 1.5; }

/* ── Tab navigation ─────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }
.tab { padding: 8px 18px; font-size: 13px; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; }
.tab.active { color: var(--amber-dark); border-bottom-color: var(--amber); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Misc ───────────────────────────────────────────── */
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--gray-200); }
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 12px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.d-flex { display: flex; }
.gap-2  { gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
hr.divider { border: none; border-top: 1px solid var(--gray-200); margin: 16px 0; }
.chart-container { position: relative; height: 220px; }

/* ── Login Overlay ──────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0; background: var(--navy);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.login-card {
  background: #fff; border-radius: 12px; padding: 40px;
  width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-brand .brand-icon { font-size: 32px; }
.login-brand .brand-name { font-size: 18px; font-weight: 800; color: var(--navy); }
.login-brand .brand-sub  { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.login-title { font-size: 20px; font-weight: 700; margin-bottom: 24px; color: var(--navy); }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin: 8px 0; }
.btn-block { width: 100%; margin-top: 8px; padding: 11px; font-size: 15px; }

/* ── Topbar user info ───────────────────────────────── */
.topbar-user { display: flex; align-items: center; gap: 10px; margin-left: 12px; }
.user-name { font-weight: 600; font-size: 13px; color: var(--navy); }
.user-role { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-role-administrador { background: #fef3c7; color: #92400e; }
.badge-role-supervisor    { background: #dbeafe; color: #1e40af; }
.badge-role-inspector     { background: #dcfce7; color: #166534; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-outline { border: 1px solid var(--gray-200); background: #fff; color: var(--text-muted); border-radius: 6px; }
.btn-outline:hover { background: var(--gray-100); }
