:root {
  --header-h: 58px;
  --sidebar-w: 236px;
  --navy: #1e4f8c;
  --blue: #2f6fe4;
  --purple: #7d6bb5;
  --green: #2f9e44;
  --teal: #14a39a;
  --red: #e25555;
  --amber: #f0b429;
  --line: #e5e8ee;
  --text: #2c333a;
  --muted: #6b7280;
  --sidebar: #f3f4f6;
  --header: #eef0f3;
  --page: #f7f8fa;
  --ink: #243040;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--page);
  font-size: 14px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #8eb4f5;
  outline-offset: 1px;
}

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  background: var(--header);
  border-bottom: 1px solid #e1e4ea;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 14px;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: flex; align-items: center; gap: 8px; color: #1d6fbf; }
.brand-mark strong { font-size: 24px; letter-spacing: -0.4px; font-weight: 700; }
.icon-ghost {
  width: 36px; height: 36px; border: 0; background: transparent; color: #5c6770;
  border-radius: 8px; display: grid; place-items: center;
}
.icon-ghost:hover { background: rgba(0, 0, 0, 0.05); }
.top-actions { display: flex; align-items: center; gap: 2px; }
.menu-wrap { position: relative; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  min-width: 280px; box-shadow: 0 12px 32px rgba(20, 30, 50, 0.14);
  padding: 6px; z-index: 40;
}
.dropdown button, .dropdown .drop-item {
  display: block; width: 100%; text-align: left; background: transparent;
  border: 0; padding: 10px 12px; border-radius: 6px; color: var(--ink);
}
.dropdown button:hover { background: #f3f6fb; }
.dropdown .who { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.dropdown .who b { display: block; }
.dropdown .who span { color: var(--muted); font-size: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #e7a23a; color: #fff;
  display: grid; place-items: center; font-weight: 700; border: 0; margin-left: 6px;
}
.user-btn { display: flex; align-items: center; gap: 4px; background: transparent; border: 0; padding: 0; }
.caret { color: #667; font-size: 10px; }

.layout { padding-top: var(--header-h); }
.sidebar {
  position: fixed; top: var(--header-h); bottom: 0; left: 0; width: var(--sidebar-w);
  background: var(--sidebar); border-right: 1px solid #e6e8ed; overflow: auto;
  z-index: 20; transition: transform 0.18s ease;
}
.nav-closed .sidebar { transform: translateX(-100%); }
.empresa-box { padding: 14px 14px 8px; }
.empresa-box label { display: block; color: #8b949e; font-size: 12px; margin-bottom: 4px; }
.empresa-box select, .field input, .field select, .field textarea, .search-row input, .filter-card input, .filter-card select {
  width: 100%; border: 1px solid #d5dbe3; background: #fff; border-radius: 4px; padding: 7px 10px;
}
.empresa-box select { padding-right: 8px; }
.nav-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: transparent; border: 0; color: #4b5563; text-align: left;
  padding: 9px 16px; font-size: 14px;
}
.nav-btn svg { flex: 0 0 auto; }
.nav-btn:hover { background: #e9ebef; }
.nav-btn.active { background: #e7e9ed; color: #1f2933; font-weight: 650; }

.main {
  margin-left: var(--sidebar-w); min-height: calc(100vh - var(--header-h));
  background: #fff; padding: 16px 22px 48px; transition: margin-left 0.18s ease;
}
.nav-closed .main { margin-left: 0; }
.crumb { color: #9aa3ad; font-size: 13px; }
.crumb button { background: none; border: 0; color: #9aa3ad; padding: 0; }
.crumb button:hover { color: var(--blue); }
h1 { font-size: 26px; font-weight: 600; margin: 6px 0 12px; color: #3a4250; letter-spacing: -0.2px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  background: transparent; border: 1px solid transparent; border-bottom: 0;
  padding: 10px 14px; color: #6a7380; font-weight: 650; border-radius: 6px 6px 0 0; margin-bottom: -1px;
}
.tab.active { background: #fff; border-color: var(--line); color: #243040; }

.toolbar { display: flex; justify-content: flex-end; gap: 8px; margin: 4px 0 14px; flex-wrap: wrap; }
.btn {
  border: 0; border-radius: 4px; padding: 8px 12px; font-weight: 700; color: #fff;
  display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; white-space: nowrap;
}
.btn:hover { filter: brightness(0.96); }
.btn.blue { background: var(--blue); }
.btn.green { background: var(--green); }
.btn.purple { background: var(--purple); }
.btn.amber { background: var(--amber); color: #3d2e04; }
.btn.red { background: var(--red); }
.btn.gray { background: #6b7280; }
.btn.teal { background: var(--teal); }
.btn.navy { background: #163e6f; }
.btn.navy-2 { background: var(--navy); }
.btn.green-2 { background: #3aaa78; }
.btn.sky { background: #3d9be9; }
.btn.sm { padding: 6px 10px; }

.filter-card { border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; }
.filter-line { display: flex; flex-wrap: wrap; gap: 16px 22px; align-items: flex-end; }
.filter-line label { display: flex; flex-direction: column; gap: 6px; color: #4b5563; font-weight: 650; font-size: 13px; min-width: 180px; }
.filter-line label input { font-weight: 500; }
.pills { display: flex; gap: 10px; margin: 14px 0; }
.pill {
  flex: 1; border: 0; color: #fff; border-radius: 4px; min-height: 40px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; letter-spacing: 0.2px;
}
.pill .count {
  background: #fff; border-radius: 99px; min-width: 22px; height: 22px; padding: 0 6px;
  display: inline-grid; place-items: center; font-size: 12px;
}
.pill.active { outline: 2px solid #10243f; outline-offset: 1px; }
.pill.navy { background: #163e6f; } .pill.navy .count { color: #163e6f; }
.pill.amber { background: #e6b325; color: #fff; } .pill.amber .count { color: #a07910; }
.pill.red { background: #e25555; } .pill.red .count { color: #c43c3c; }
.pill.green { background: #2f9e44; } .pill.green .count { color: #217a33; }
.pill.teal { background: #1aae9f; } .pill.teal .count { color: #0e7d72; }
.pill.navy-2 { background: #1e4f8c; } .pill.navy-2 .count { color: #1e4f8c; }
.pill.green-2 { background: #3aaa78; } .pill.green-2 .count { color: #217a4e; }
.pill.sky { background: #3d9be9; } .pill.sky .count { color: #1d6eae; }

.search-row { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin: 6px 0 10px; color: #4b5563; }
.search-row input { width: 230px; }

.table-wrap { overflow: auto; border-top: 1px solid #dfe5ee; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th {
  background: var(--navy); color: #fff; font-weight: 700; font-size: 13px; text-align: left;
  padding: 8px 10px; white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
th button { background: none; border: 0; color: inherit; font-weight: 700; padding: 0; display: inline-flex; align-items: center; gap: 4px; }
td { padding: 9px 10px; border-bottom: 1px solid #e7ebf0; font-size: 12.5px; vertical-align: middle; white-space: nowrap; }
tr:nth-child(even) td { background: #f4f6f8; }
tr:hover td { background: #eaf2fb; }
td.worker { font-weight: 650; max-width: 240px; line-height: 1.3; white-space: normal; }
td.clip { max-width: 220px; white-space: normal; }
.estado { font-weight: 800; letter-spacing: 0.2px; }
.estado.RETRASADO, .entrega.Pendiente { color: #dc3d3d; }
.estado.FINALIZADO, .entrega.Entregado { color: #1d9a4a; }
.estado.PENDIENTE { color: #c89212; }
.estado.CANCELADO { color: #6b7280; }
.estado.PROGRAMADO { color: var(--navy); }
.actions { display: flex; gap: 4px; justify-content: center; }
.icon-btn {
  width: 28px; height: 28px; border: 0; border-radius: 4px; color: #fff;
  display: inline-grid; place-items: center; padding: 0;
}
.icon-btn.red { background: #e35d5d; }
.icon-btn.green { background: #2f9e44; }
.icon-btn.blue { background: #2b7de9; }
.icon-btn.cyan { background: #17a2b8; }
.icon-btn.gray { background: #8b949e; }
.icon-btn svg { width: 14px; height: 14px; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; color: #6b7280; font-size: 13px; flex-wrap: wrap; }
.pages { display: flex; gap: 4px; align-items: center; }
.pages button {
  min-width: 32px; height: 32px; border: 1px solid #d7dde6; background: #fff; border-radius: 4px; color: #375;
}
.pages button.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.pages button:disabled { color: #b0b7c3; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 14px; }
.stat {
  border: 1px solid var(--line); border-radius: 4px; min-height: 78px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: #8b949e; gap: 4px;
}
.stat b { color: #243040; font-size: 22px; font-weight: 700; }
.stat.bad b { color: var(--red); }

.sup-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px 12px; align-items: center; margin-bottom: 8px; }
.sup-head h2 { margin: 0; text-align: center; font-size: 20px; letter-spacing: 0.2px; color: #2a3140; grid-column: 2; grid-row: 1; }
.sup-actions { display: flex; justify-content: flex-end; gap: 8px; grid-column: 3; grid-row: 1; }
.pdf-row { grid-column: 2; grid-row: 2; display: flex; justify-content: center; }
.drawer footer { padding: 12px 16px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
.identity {
  display: grid; grid-template-columns: auto 1fr auto auto auto auto; gap: 8px 18px;
  align-items: baseline; padding: 10px 0 14px; border-bottom: 1px solid #eceff3; margin-bottom: 16px;
}
.identity .k { font-weight: 750; color: #3c4654; }
.identity .v { font-weight: 650; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px 18px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-weight: 750; color: #3c4654; font-size: 13.5px; }
.field textarea { min-height: 84px; resize: vertical; }
.locked { background: #eef1f5 !important; }
.hr { height: 1px; background: #eceff3; border: 0; margin: 16px 0; }

.exam-row { border-bottom: 1px solid #eceff3; padding: 11px 2px; }
.exam-row label { color: #2457a6; font-weight: 700; display: flex; gap: 10px; align-items: center; cursor: pointer; }
.exam-row input { width: 16px; height: 16px; accent-color: #2457a6; }
.exam-body { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; padding: 12px 0 6px 26px; }
.exam-body label { color: var(--muted); font-weight: 650; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }

h3.sec { font-size: 15px; margin: 18px 0 8px; }
.recs { margin: 6px 0 8px; padding-left: 22px; }
.recs li { margin: 5px 0; line-height: 1.35; }
.note { color: #98a2ad; font-style: italic; margin: 4px 0 8px; }
.apt-grid { display: grid; grid-template-columns: 180px 1fr 1fr; gap: 16px; align-items: end; }
.apt-read { padding-bottom: 8px; }
.apt-read b { display: block; font-size: 15px; margin-top: 4px; }
.radios { display: flex; gap: 16px; align-items: center; }
.radios label { display: inline-flex; gap: 6px; align-items: center; font-weight: 650; }
.footer-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.summary {
  border: 1px solid #d9e4f5; background: #f5f9ff; border-radius: 8px; padding: 12px 14px; margin: 12px 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px;
}
.summary b { font-weight: 750; }

.placeholder { max-width: 520px; margin: 48px auto; text-align: center; color: #4b5563; }
.placeholder h2 { margin-bottom: 8px; }
.placeholder p { color: var(--muted); }

.overlay {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px;
}
.modal { background: #fff; border-radius: 10px; width: min(640px, 100%); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22); }
.modal.headless { width: min(460px, 100%); }
.modal header, .drawer header {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.modal header h3, .drawer header h3 { margin: 0; font-size: 16px; }
.modal .body, .drawer .body { padding: 16px; }
.modal .body p { margin: 0 0 10px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 0 16px 16px; }
.stack { display: flex; flex-direction: column; gap: 10px; max-height: 360px; overflow: auto; }
.checkline { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid #f1f3f6; }
.preview { background: #f6f8fb; border-radius: 8px; padding: 10px 12px; color: #374151; font-size: 13px; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.28); z-index: 55; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(420px, 100vw);
  background: #fff; z-index: 60; box-shadow: -10px 0 30px rgba(0, 0, 0, 0.16);
  display: flex; flex-direction: column; animation: slide 0.18s ease;
}
@keyframes slide { from { transform: translateX(16px); opacity: 0.6; } }
.drawer .body { overflow: auto; flex: 1; }
.drawer header p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.finding { border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.finding.alerta { border-left-color: #e0a106; background: #fffaf0; }
.finding.ok { border-left-color: #2f9e44; background: #f4fbf6; }
.finding.info { border-left-color: #2f6fe4; background: #f5f8ff; }
.finding b { display: block; margin-bottom: 4px; }
.finding p { margin: 0; color: #3c4654; line-height: 1.4; }
.loading { display: flex; align-items: center; gap: 10px; color: #4b5563; padding: 12px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--purple); animation: blink 1s infinite ease-in-out; }
.dot:nth-child(2) { animation-delay: 0.15s; }
.dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.toast {
  position: fixed; right: 18px; bottom: 18px; background: #1f2933; color: #fff;
  padding: 12px 14px; border-radius: 8px; z-index: 80; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

@media (max-width: 1100px) {
  .identity, .form-grid-3, .exam-body, .apt-grid, .stats, .summary { grid-template-columns: 1fr 1fr; }
  .pills { flex-wrap: wrap; }
  .pill { flex: 1 1 30%; }
}
@media (max-width: 780px) {
  .sidebar { z-index: 25; }
  .main { margin-left: 0; }
  .nav-closed .sidebar { transform: translateX(-100%); }
  .app:not(.nav-closed) .sidebar { box-shadow: 8px 0 24px rgba(0, 0, 0, 0.08); }
  .sup-head { grid-template-columns: 1fr; }
  .sup-actions, .pdf-row { grid-column: auto; grid-row: auto; justify-content: flex-start; }
  .identity, .form-grid-3, .form-grid-2, .exam-body, .apt-grid, .stats, .summary { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
