:root {
  --bg: #faf8fb;
  --panel: #ffffff;
  --border: #e5dcee;
  --text: #2b2233;
  --text-muted: #8a8194;
  --primary: #6e4d7a;        /* morado principal Senda */
  --primary-dark: #4c3960;   /* morado oscuro Senda */
  --primary-light: #E9DCF6;  /* morado claro Senda */
  --gray: #9C9C9B;           /* gris Senda */
  --accent-women: #6e4d7a;
  --accent-men: #9C9C9B;
  --danger: #b3455c;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(76,57,96,.08);
}

* { box-sizing: border-box; }

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

h1, h2, h3, h4 { font-family: "Poppins", "Segoe UI", Arial, sans-serif; }

.hidden { display: none !important; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  background: linear-gradient(120deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
}
.topbar-title h1 { font-size: 20px; margin: 0; font-weight: 700; color: #fff; }
.topbar-title .subtitle { font-size: 12.5px; color: #e9dcf6; }

.topbar-brand { display: flex; align-items: center; gap: 18px; }
.senda-logo { height: 46px; width: auto; display: block; }
.topbar-divider { width: 1px; align-self: stretch; background: rgba(255,255,255,.25); }

.login-logo { display: block; height: 52px; width: auto; margin: 0 auto 18px; }

.company-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

select, input[type=text], input[type=number], input[type=date] {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
select:focus, input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(110,77,122,.15);
}
select#companySelect { min-width: 220px; }

.btn {
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: transform .1s ease, background .15s ease;
}
.btn:hover { background: var(--primary-light); transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { padding: 7px 10px; }
.btn-danger { color: var(--danger); }
.btn-small { font-size: 12px; padding: 5px 10px; }

.save-status { font-size: 12.5px; color: #e9dcf6; min-width: 80px; font-weight: 500; }
.save-status.saving { color: #ffe08a; }
.save-status.saved { color: #b7f5c8; }
.save-status.error { color: #ffb3c1; }

/* ---------- Barra de progreso ---------- */
.progress-track {
  height: 6px;
  background: var(--primary-light);
  position: sticky;
  top: 66px;
  z-index: 49;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  transition: width .35s ease;
}
.progress-label {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 0 0;
  background: var(--bg);
}

/* ---------- Layout ---------- */
.layout { display: flex; min-height: calc(100vh - 57px); }

.sidenav {
  width: 260px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  position: sticky;
  top: 92px;
  align-self: flex-start;
  height: calc(100vh - 92px);
  overflow-y: auto;
}
.sidenav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--text);
  text-decoration: none;
  border-radius: 10px;
  margin-bottom: 2px;
  transition: background .15s ease, color .15s ease;
}
.sidenav a .nav-icon { font-size: 16px; }
.sidenav a:hover { background: var(--primary-light); }
.sidenav a.active { background: var(--primary); color: #fff; font-weight: 600; }

.content { flex: 1; padding: 24px 32px 80px; max-width: 1200px; }
.admin-content { margin: 0 auto; padding: 24px 32px 80px; }

/* ---------- Panel interno: tabla de empresas ---------- */
.link-banner {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 13px;
}
.link-box { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.link-box input { flex: 1; font-family: monospace; font-size: 12px; }

table.admin-table { border-collapse: collapse; width: 100%; font-size: 13px; }
table.admin-table th, table.admin-table td {
  border-bottom: 1px solid var(--border);
  padding: 12px 8px;
  text-align: left;
}
table.admin-table th { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.progress-cell { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.progress-mini-track { height: 8px; border-radius: 6px; background: var(--primary-light); overflow: hidden; }
.progress-mini-fill { height: 100%; background: var(--primary); border-radius: 6px; transition: width .3s ease; }
.progress-mini-label { font-size: 12px; font-weight: 600; color: var(--primary-dark); }
.progress-mini-detail { font-weight: 400; color: var(--text-muted); }
.progress-complete .progress-mini-fill { background: #4c9a6a; }
.progress-complete .progress-mini-label { color: #327a4d; }

.logo-cell { display: flex; align-items: center; gap: 10px; }
.logo-thumb {
  width: 56px; height: 56px; object-fit: contain;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 4px;
}
.logo-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text-muted); text-align: center; background: var(--bg);
}
.logo-cell-actions { display: flex; flex-direction: column; gap: 4px; }

.empty-state {
  margin-top: 60px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Sections ---------- */
.section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  scroll-margin-top: 100px;
}
.section h2 {
  margin: 0 0 4px;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary-dark);
}
.section-icon { font-size: 20px; }
.section .section-desc { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px 20px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--text-muted); }
.field input { width: 100%; }

.table-block { margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--border); }
.table-block:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.table-block h3 { font-size: 14.5px; margin: 0 0 12px; color: var(--text); }
.repeatable-title { font-size: 13px; margin: 0 0 8px; color: var(--text-muted); font-weight: 600; }

.table-flex { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; flex: 1 1 480px; }
.chart-wrap { flex: 0 0 200px; height: 170px; }

table.data-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13px;
}
table.data-table th, table.data-table td {
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
table.data-table th {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 12px;
}
table.data-table thead th:first-child { border-top-left-radius: 10px; }
table.data-table thead th:last-child { border-top-right-radius: 10px; }
table.data-table td.label-cell, table.data-table th.label-cell { text-align: left; min-width: 160px; }
table.data-table tr:hover td { background: #fbf8fd; }
table.data-table tr.total-row td { font-weight: 700; background: var(--primary-light); }
table.data-table tr.total-row:hover td { background: var(--primary-light); }
table.data-table input[type=number] { width: 68px; text-align: right; font-weight: 600; }
table.data-table input.label-input { width: 100%; min-width: 150px; text-align: left; }
table.data-table td.pct-cell { color: var(--text-muted); font-size: 12px; }
table.data-table .th-women { color: var(--accent-women); }
table.data-table .th-men { color: var(--gray); }

/* Mini barra de proporción mujeres/hombres por fila */
.bar-cell { width: 90px; min-width: 90px; }
.split-bar {
  display: flex;
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  background: #eee;
  min-width: 70px;
}
.split-bar-empty { background: #ececec; }
.split-women { background: var(--accent-women); transition: width .3s ease; }
.split-men { background: var(--gray); transition: width .3s ease; }

.row-actions-cell { width: 30px; }
.icon-btn {
  border: none; background: none; cursor: pointer; color: var(--text-muted); font-size: 14px;
}
.icon-btn:hover { color: var(--danger); }

.add-row-btn { margin-top: 10px; }

.repeatable-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  position: relative;
  background: #fdfbfe;
}
.repeatable-card .remove-btn { position: absolute; top: 8px; right: 10px; }
.repeatable-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 8px; }

.report-cta {
  text-align: center;
  padding: 26px;
  border-left-color: var(--primary);
  background: var(--primary-light);
}
.report-cta p { color: var(--primary-dark); font-size: 14px; font-weight: 500; margin: 0; }

@media (max-width: 900px) {
  .sidenav { display: none; }
  .content { padding: 20px; }
  .progress-track, .progress-label { top: auto; }
}
