@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');

:root {
  font-family: 'DM Sans', Arial, sans-serif;
  color: #111111;
  background: #f8f8f6;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --black: #0d0d0d;
  --black-soft: #1a1a1a;
  --yellow: #ffcb11;
  --yellow-hover: #f2be00;
  --yellow-soft: #fff8db;
  --yellow-ink: #8a6600;
  --muted: #6b6f76;
  --line: #e7e7e2;
  --surface: #ffffff;
  --green: #16794a;
  --orange: #9a5b00;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f8f8f6; color: #111111; }

/* Sidebar Negro Industrial + Acentos Amarillo Maquinaria (#FFCB11) */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 246px;
  background: var(--black);
  color: #f3f3f1;
  padding: 24px 16px 20px;
  display: flex;
  flex-direction: column;
  z-index: 3;
  border-right: 1px solid #1f1f1f;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: #ffffff;
  text-decoration: none;
  font: 800 17px Manrope, sans-serif;
  letter-spacing: 0.3px;
  padding: 0 8px 26px;
}
.brand-official {
  background: transparent;
  border: 0;
  padding: 4px 6px 24px;
  margin: 0;
  gap: 9px;
  box-shadow: none;
}
.brand-isotipo {
  height: 38px;
  width: auto;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}
.brand-wordmark {
  height: 30px;
  width: auto;
  max-width: 158px;
  display: block;
  object-fit: contain;
}
.nav-label {
  font-size: 10px;
  letter-spacing: 1.3px;
  font-weight: 800;
  color: rgba(255, 203, 17, 0.82);
  padding: 0 12px 8px;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 1.2px;
  font-weight: 800;
  color: #997300;
}
.nav {
  border: 0;
  background: none;
  color: #b7b7b2;
  padding: 11px 12px;
  border-radius: 8px;
  text-align: left;
  font: 600 13px 'DM Sans';
  cursor: pointer;
  margin: 2px 0;
  display: flex;
  align-items: center;
  transition: background 0.14s ease, color 0.14s ease;
  position: relative;
}
.nav span {
  display: inline-block;
  width: 26px;
  color: #84847f;
  font-size: 15px;
  flex-shrink: 0;
}
.nav:hover {
  background: #1b1b1b;
  color: #ffffff;
}
.nav.active {
  background: #1d1d1a;
  color: #ffffff;
  box-shadow: inset 3px 0 0 var(--yellow);
}
.nav.active span { color: var(--yellow); }

.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid #222222;
  padding: 16px 6px 0;
  color: #d4d4cf;
  font-size: 11px;
}
.sidebar-bottom small {
  display: block;
  color: #858580;
  padding: 6px 0 0 16px;
}
.online-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 203, 17, 0.22);
  margin: 0 7px 1px 1px;
}

/* Área principal blanca y limpia */
.main {
  margin-left: 246px;
  max-width: 1700px;
  padding: 0 38px 48px;
  background: #f8f8f6;
}
.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.topbar .eyebrow {
  font-size: 9.5px;
  color: #997300;
  margin-bottom: 3px;
}
.topbar h1 {
  font: 800 22px Manrope;
  margin: 0;
  color: #111111;
  letter-spacing: -0.02em;
}
.top-actions { display: flex; align-items: center; gap: 12px; }
.role-select { font-size: 10px; color: var(--muted); }
.role-select select {
  display: block;
  border: 0;
  background: transparent;
  color: #111111;
  font: 600 12px 'DM Sans';
  outline: 0;
  max-width: 210px;
}
.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--yellow);
  border-radius: 50%;
  color: #000000;
  font-size: 11px;
  font-weight: 800;
}
.mobile-menu { display: none; }

/* Barra de conectividad oculta por diseño */
.notice {
  display: none !important;
}
.notice > span {
  font-size: 15px;
  color: #111111;
  font-weight: 700;
}
.notice b, .notice span { display: block; }
.notice b { color: #111111; margin-bottom: 2px; font-size: 12px; }
.notice div span { line-height: 1.45; }
.notice-code {
  font-weight: 700;
  color: #111111;
  background: var(--yellow-soft);
  padding: 1px 6px;
  border-radius: 5px;
}
.notice-link {
  font-weight: 700;
  color: #111111;
  text-decoration: underline;
  text-decoration-color: var(--yellow);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.view { display: none; }
.view.shown { display: block; }

/* Banner principal compacto Negro + Acento Amarillo Maquinaria */
.welcome {
  min-height: 118px;
  padding: 22px 28px;
  background: linear-gradient(112deg, #0b0b0b 0%, #1b1b18 100%);
  border-left: 5px solid var(--yellow);
  border-radius: 12px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08);
}
.welcome:after {
  content: '';
  position: absolute;
  width: 280px;
  height: 280px;
  border: 1px solid rgba(255, 203, 17, 0.14);
  border-radius: 50%;
  right: 12%;
  top: -175px;
  box-shadow: 0 0 0 32px rgba(255, 203, 17, 0.05), 0 0 0 66px rgba(255, 203, 17, 0.03);
}
.welcome > * { position: relative; z-index: 1; }
.welcome .eyebrow { color: var(--yellow); }
.welcome h2 { font: 800 24px Manrope; margin: 5px 0 4px; color: #ffffff; letter-spacing: -0.02em; }
.welcome p:not(.eyebrow) { color: #c7c7c2; margin: 0; font-size: 13px; }

/* Botones industriales de alto contraste */
.btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font: 700 12px 'DM Sans';
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--yellow);
  color: #000000;
  box-shadow: 0 4px 12px rgba(255, 203, 17, 0.30);
}
.btn-primary:hover {
  background: var(--yellow-hover);
  box-shadow: 0 6px 16px rgba(255, 203, 17, 0.38);
}
.welcome .btn-primary {
  background: var(--yellow);
  color: #000000;
  box-shadow: none;
}
.btn-outline {
  border: 1px solid #d6d6d0;
  background: #ffffff;
  color: #181818;
}
.btn-outline:hover {
  border-color: #111111;
  background: #fbfbfa;
}
.btn-small { padding: 8px 11px; }

/* Tarjetas KPI blancas limpias */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 16px 0;
}
.stat {
  background: #ffffff;
  border: 1px solid var(--line);
  border-top: 3px solid var(--yellow);
  border-radius: 10px;
  padding: 15px 18px;
  min-width: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
}
.stat span {
  display: inline-block;
  background: var(--yellow-soft);
  color: #7a5900;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.75px;
}
.stat strong {
  display: block;
  font: 800 26px Manrope;
  color: #111111;
  margin: 10px 0 3px;
}
.stat small { color: #7e828a; font-size: 10.5px; }

/* Paneles y tablas */
.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 2.05fr) minmax(240px, 1fr);
  gap: 15px;
}
.panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.panel-head {
  padding: 15px 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-head h3 {
  font: 800 14px Manrope;
  margin: 0;
  color: #111111;
  border-left: 3px solid var(--yellow);
  padding-left: 9px;
}
.panel-head p { font-size: 11px; color: #84888f; margin: 3px 0 0; }
.text-btn {
  color: #111111;
  border: 0;
  background: none;
  font: 700 11.5px 'DM Sans';
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  text-decoration: underline;
  text-decoration-color: var(--yellow);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.text-btn:hover { background: var(--yellow-soft); }

.table-wrap { overflow: auto; width: 100%; }
table { border-collapse: collapse; width: 100%; white-space: nowrap; text-align: left; }
th {
  background: #fafaf8;
  color: #777b82;
  font-size: 9.5px;
  letter-spacing: 0.5px;
  font-weight: 700;
  padding: 10px 10px;
  border-top: 1px solid #efefea;
  border-bottom: 1px solid #efefea;
}
td {
  padding: 10px 10px;
  border-bottom: 1px solid #f1f1ec;
  font-size: 11.5px;
  color: #36393f;
}
tbody tr:last-child td { border-bottom: 0; }
.strong { font-weight: 700; color: #111111; }
.sub { display: block; color: #888c94; font-size: 10px; margin-top: 3px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 9.5px;
  font-weight: 700;
  background: #f2f2ee;
  color: #4f535a;
}
.badge.open { background: #141414; color: var(--yellow); }
.badge.closed { background: var(--yellow-soft); color: #7a5900; border: 1px solid #f5df8a; }
.badge.valid { background: #e8f6ee; color: #156e43; }

.inline-action {
  border: 0;
  background: transparent;
  color: #111111;
  font: 700 10.5px 'DM Sans';
  cursor: pointer;
  padding: 5px 6px;
  border-radius: 5px;
  text-decoration: underline;
  text-decoration-color: var(--yellow);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}
.inline-action:hover { background: var(--yellow-soft); }

/* Atención */
.attention { padding-bottom: 10px; }
.attention-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--yellow);
  color: #000000;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
}
.attention-list { padding: 0 18px; }
.attention-item {
  display: flex;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid #f1f1ec;
}
.attention-item > span {
  width: 7px;
  height: 7px;
  background: var(--yellow);
  border: 1px solid #111111;
  border-radius: 50%;
  margin-top: 4px;
  flex: 0 0 auto;
}
.attention-item b { font-size: 11.5px; color: #181818; display: block; }
.attention-item small { font-size: 10px; color: #7e828a; display: block; margin-top: 3px; }

/* Encabezados de sección y filtros */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 6px 0 16px;
}
.section-head h2 { font: 800 21px Manrope; margin: 0; color: #111111; }
.section-head p { font-size: 12px; color: #767a82; margin: 5px 0 0; }
.filters { display: flex; gap: 9px; margin: 0 0 14px; align-items: center; }
.filters input, .filters select {
  height: 38px;
  border: 1px solid #dcdcd5;
  border-radius: 8px;
  background: #ffffff;
  padding: 0 11px;
  color: #181818;
  font: 12px 'DM Sans';
  outline: none;
}
.filters input:focus, .filters select:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 203, 17, 0.24);
}
.filters input:first-child:not([type=month]) { flex: 1; min-width: 180px; }
.filters select { min-width: 155px; }
.filters input[type=month] { min-width: 160px; }

.report-stats { margin-top: 14px; }
.report-stats .stat { padding: 15px 17px; }
.report-stats .stat strong { font-size: 22px; }

/* Catálogo de maquinaria */
.machine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.machine-card { background: #ffffff; border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.machine-card-head { display: flex; justify-content: space-between; align-items: center; }
.machine-code {
  background: #141414;
  color: var(--yellow);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}
.machine-card h3 { font: 700 14px Manrope; line-height: 1.5; margin: 14px 0 8px; color: #111111; }
.machine-card p { color: #787c84; font-size: 11px; line-height: 1.65; margin: 0; }
.empty { padding: 26px; text-align: center; color: #878b92; font-size: 11.5px; }
.machine-card .badge { background: #e8f6ee; color: #156e43; }
.muted { color: #848890; }

/* Modales */
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { font: 800 20px Manrope; margin: 4px 0; color: #111111; }
.modal-head .eyebrow { color: #8a6600; }
.icon-btn {
  border: 0;
  background: #f2f2ee;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 19px;
  color: #333333;
  cursor: pointer;
}
.icon-btn:hover { background: var(--yellow); color: #000000; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid label, #close-form > label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #2b2e33;
}
.form-grid label small { display: inline; color: #868a92; font-weight: 400; }
.form-grid input, .form-grid select, .form-grid textarea, #close-form input:not([type=hidden]) {
  width: 100%;
  border: 1px solid #d8d8d0;
  border-radius: 7px;
  padding: 10px 11px;
  color: #111111;
  background: #ffffff;
  font: 12px 'DM Sans';
  outline: none;
}
.form-grid input:focus, .form-grid textarea:focus, .form-grid select:focus, #close-form input:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 203, 17, 0.28);
}
.span-two { grid-column: span 2; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid #ecece7;
  margin-top: 18px;
  padding-top: 14px;
}
.modal-foot > span { font-size: 10.5px; color: #80848c; line-height: 1.5; }
.modal-foot .btn { flex: 0 0 auto; }

dialog {
  border: 0;
  border-top: 4px solid var(--yellow);
  border-radius: 12px;
  padding: 22px 24px;
  width: min(720px, calc(100% - 24px));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  color: #111111;
}
dialog::backdrop { background: rgba(10, 10, 10, 0.62); backdrop-filter: blur(3px); }
#machine-dialog { width: min(600px, calc(100% - 24px)); }
#close-dialog { width: min(440px, calc(100% - 24px)); }
#close-form > label { margin-top: 17px; }

#toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #111111;
  color: #ffffff;
  border-left: 4px solid var(--yellow);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: 0.2s;
  z-index: 8;
  max-width: 360px;
}
#toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .main { padding: 0 24px 40px; }
  .sidebar { width: 218px; }
  .main { margin-left: 218px; }
  .stats { gap: 10px; }
  .stat { padding: 14px; }
  .grid-two { grid-template-columns: 1fr; }
  .attention { min-height: 120px; }
}
@media (max-width: 720px) {
  .sidebar { width: 250px; transform: translateX(-100%); transition: transform 0.2s; box-shadow: none; }
  .sidebar.menu-open { transform: translateX(0); box-shadow: 0 0 0 100vw rgba(0, 0, 0, 0.55); }
  .main { margin-left: 0; padding: 0 15px 35px; }
  .topbar { height: 68px; gap: 9px; }
  .mobile-menu { display: block; border: 0; background: #141414; border-radius: 7px; width: 34px; height: 34px; color: var(--yellow); font-weight: 800; }
  .topbar h1 { font-size: 18px; }
  .top-actions { gap: 8px; }
  .role-select { font-size: 9px; }
  .role-select select { font-size: 10px; max-width: 145px; }
  .avatar { display: none; }
  .notice { margin: 12px 0; }
  .welcome { padding: 20px 18px; min-height: 120px; align-items: flex-start; justify-content: center; flex-direction: column; gap: 12px; }
  .welcome h2 { font-size: 20px; }
  .welcome p:not(.eyebrow) { font-size: 11.5px; line-height: 1.5; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 13px; }
  .stat strong { font-size: 21px; }
  .stat span { font-size: 8.5px; }
  .section-head { gap: 10px; align-items: flex-start; }
  .section-head h2 { font-size: 18px; }
  .section-head p { line-height: 1.5; }
  .section-head .btn { white-space: nowrap; padding: 10px; }
  .filters { flex-wrap: wrap; }
  .filters input:first-child:not([type=month]) { flex-basis: 100%; }
  .filters select, .filters input[type=month] { flex: 1; min-width: 120px; }
  .panel-head { padding: 14px; }
  .grid-two { gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .modal-foot { align-items: flex-end; }
  .modal-foot > span { max-width: 56%; }
  dialog { padding: 18px 16px; max-height: 90vh; overflow: auto; }
  .report-stats .stat strong { font-size: 19px; }
}
@media print {
  .sidebar, .topbar, .notice, .filters, .btn, .section-head button { display: none !important; }
  .main { margin: 0; padding: 0; background: #ffffff; }
  .view { display: none !important; }
  #view-reports { display: block !important; }
  .panel, .stat { break-inside: avoid; }
  .report-stats { grid-template-columns: repeat(4, 1fr); }
}

.security-note { font-size: 11px; color: #7c8088; line-height: 1.6; margin: 13px 2px; }
.staff-stats .stat strong { font-size: 23px; }
.credentials-box { background: #fafaf7; border: 1px solid var(--line); border-radius: 9px; padding: 15px 17px; }
.credentials-box p { font-size: 12px; color: #5b5f66; margin: 0 0 14px; }
.credentials-box > div { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid #ecece7; gap: 12px; }
.credentials-box > div span { font-size: 9px; letter-spacing: 0.7px; color: #7e828a; font-weight: 700; }
.credentials-box > div strong { font-size: 13px; color: #111111; overflow-wrap: anywhere; }
.credentials-box > small { display: block; color: #8a6600; font-size: 10px; line-height: 1.5; margin-top: 10px; }
.contract-date.hidden { display: none; }
.staff-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.danger-action { color: #b42318; text-decoration-color: #fca5a5; }
.staff-actions button { white-space: nowrap; }
.edit-contract-date.hidden { display: none; }
.apk-readiness { color: #9a5b00; }
.apk-readiness.ready { color: #156e43; }

/* Ficha mensual estilo Excel */
.machine-detail-btn { margin-top: 14px; }
.machine-detail-filters { display: flex; gap: 10px; align-items: center; }
.machine-detail-filters select { min-width: 190px; }
.excel-like-panel { overflow: hidden; }
.excel-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 20px;
  background: #121212;
  border-bottom: 3px solid var(--yellow);
  color: #ffffff;
}
.excel-heading b, .excel-heading small { display: block; }
.excel-heading small { margin-top: 5px; color: #c7c7c2; font-size: 11px; }
.excel-heading strong { color: var(--yellow); }
.excel-meta { display: flex; flex-wrap: wrap; gap: 22px; padding: 13px 20px; background: #ffffff; border-bottom: 1px solid var(--line); font-size: 11px; color: #4d5158; }
.excel-meta em { font-style: normal; color: #111111; font-weight: 600; }
.excel-table-wrap { overflow: auto; }
.excel-table { min-width: 1500px; font-size: 10px; }
.excel-table th { white-space: nowrap; background: #f8f8f5; color: #3a3d42; text-align: center; vertical-align: middle; }
.excel-table td { vertical-align: top; }
.excel-table td, .excel-table th { border-right: 1px solid #e7e7e2; border-bottom: 1px solid #e7e7e2; padding: 8px 7px; }
.excel-table tfoot th { background: var(--yellow-soft); color: #111111; }
.description-cell { min-width: 260px; white-space: normal; line-height: 1.45; }
.excel-table tbody tr:nth-child(even) { background: #fcfcfb; }
@media print {
  .sidebar, .topbar, .section-head .btn, .machine-detail-filters, .stats { display: none !important; }
  .main { margin: 0; padding: 0; }
  .view { display: none !important; }
  .view#view-machine-detail { display: block !important; }
  .excel-like-panel { box-shadow: none; border: 1px solid #777; }
  .excel-table { font-size: 8px; min-width: 0; }
  .excel-table td, .excel-table th { padding: 4px; }
  .description-cell { min-width: 0; }
}

/* Grupos de personal y maquinaria */
.staff-main-group th {
  background: #141414;
  color: var(--yellow);
  text-align: left;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  padding: 13px 14px;
  border-top: 10px solid #f8f8f6;
}
.staff-main-group th span, .staff-sub-group th span { float: right; font-size: 11px; letter-spacing: 0; font-weight: 600; color: #d5d5cf; }
.staff-sub-group th { background: #fafaf7; color: #45484f; text-align: left; padding: 10px 14px; font-size: 11px; text-transform: none; }
.staff-sub-group th span { color: #7a7e86; }
.staff-empty-group td { color: #8c9098; font-size: 11px; text-align: center; padding: 13px; }
.staff-main-group:first-child th { border-top: 0; }

.machine-group { margin: 0 0 20px; }
.machine-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 17px;
  background: #141414;
  border: 1px solid #1f1f1f;
  border-bottom: 2px solid var(--yellow);
  border-radius: 10px 10px 0 0;
  color: #ffffff;
}
.machine-group-title h3 { margin: 0; font-size: 14px; }
.machine-group-title span { font-size: 11px; color: var(--yellow); }
.machine-grid-inner { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; padding: 14px; background: #fafaf7; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; }
.machine-group:first-child .machine-group-title { margin-top: 0; }

.machine-group-dropdown {
  grid-column: 1/-1;
  margin: 0 0 11px;
  background: #ffffff;
  border: 1px solid #d7d7cf;
  border-left: 6px solid var(--yellow);
  border-radius: 11px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}
.machine-group-dropdown:hover {
  border-color: #181818;
  border-left-color: var(--yellow);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}
.machine-group-dropdown[open] {
  border-color: #141414;
  border-left: 6px solid var(--yellow);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.09);
}
.machine-group-dropdown summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  list-style: none;
  padding: 13px 16px 13px 18px;
  background: linear-gradient(90deg, #fffdf4 0%, #ffffff 34%, #ffffff 100%);
  color: #111111;
  font-size: 13.5px;
  font-weight: 800;
  transition: background 0.14s ease;
}
.machine-group-dropdown summary:hover {
  background: linear-gradient(90deg, #fff6cf 0%, #ffffff 45%, #ffffff 100%);
}
.machine-group-dropdown[open] summary {
  background: #141414;
  color: #ffffff;
  border-bottom: 2px solid var(--yellow);
}
.machine-group-dropdown summary::-webkit-details-marker { display: none; }
.machine-group-dropdown summary::after {
  content: '⌄';
  font-size: 16px;
  line-height: 1;
  color: var(--yellow);
  background: #141414;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  transition: transform 0.2s, background 0.15s, color 0.15s;
}
.machine-group-dropdown[open] summary::after {
  background: var(--yellow);
  color: #000000;
}
.machine-group-dropdown:not([open]) summary::after { transform: rotate(-90deg); }
.machine-group-dropdown summary small {
  margin-left: auto;
  color: #141414;
  background: var(--yellow-soft);
  border: 1px solid #f0d778;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
}
.machine-group-dropdown[open] summary small {
  background: rgba(255, 203, 17, 0.18);
  border-color: rgba(255, 203, 17, 0.55);
  color: var(--yellow);
}
.machine-group-dropdown .machine-grid-inner { display: grid; grid-template-columns: 1fr; gap: 0; padding: 10px; background: #ffffff; border: 0; border-radius: 0; }

/* Bitácora horaria agrupada por perfil */
.bitacora-groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 18px 18px;
}
.bitacora-profile-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--yellow);
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
}
.bitacora-profile-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  background: #ffffff;
  transition: background 0.14s ease;
}
.bitacora-profile-card summary:hover { background: #fffdf5; }
.bitacora-profile-card[open] summary {
  background: #fafaf6;
  border-bottom: 1px solid var(--line);
}
.bitacora-profile-card summary::-webkit-details-marker { display: none; }
.bitacora-profile-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.bitacora-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--yellow);
  color: #000000;
  font-weight: 800;
  font-size: 11px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.bitacora-profile-left strong {
  display: block;
  font-size: 13px;
  color: #111111;
}
.bitacora-profile-left small {
  display: block;
  font-size: 10.5px;
  color: #767a82;
  margin-top: 2px;
}
.bitacora-profile-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.bitacora-chevron {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--yellow-soft);
  color: #111111;
  display: inline-grid;
  place-items: center;
  font-size: 14px;
  transition: transform 0.2s ease, background 0.15s ease;
}
.bitacora-profile-card:not([open]) .bitacora-chevron { transform: rotate(-90deg); }
.bitacora-profile-card[open] .bitacora-chevron { background: var(--yellow); }

.machine-row { display: grid; grid-template-columns: 180px 140px minmax(0, 1fr) auto 240px; align-items: center; gap: 18px; width: 100%; padding: 14px 16px; border: 0; border-bottom: 1px solid #efefea; border-radius: 0; background: #ffffff; }
.machine-row:last-child { border-bottom: 0; }
.machine-row-main h3 { margin: 0 0 6px; }
.machine-row-main p { margin: 0; color: #6e727a; font-size: 11px; }
.machine-row-main .sub { margin-top: 5px; }
.machine-row-actions { white-space: nowrap; display: flex; flex-wrap: wrap; gap: 8px; }
.machine-row-actions .btn { white-space: nowrap; }
.machine-row-reference { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.machine-row-reference small { font-size: 10px; }
.machine-row-photo { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.machine-row-photo img, .machine-photo-empty { width: 160px; height: 92px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fafaf7; }
.machine-photo-empty { display: flex; align-items: center; justify-content: center; color: #8c9098; font-size: 10px; }
.machine-row-photo .inline-action { font-size: 10px; padding: 0; background: none; border: 0; color: #111111; cursor: pointer; }

.machine-status-maintenance { background: var(--yellow-soft); color: #8a5b00; }
.machine-status-out_of_service { background: #fee2e2; color: #a32626; }

.machine-edit-reference-box { display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fafaf7; padding: 10px; }
.machine-edit-reference-box img { width: 150px; height: 86px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #ffffff; }
.machine-edit-reference-box > div { display: flex; flex-direction: column; gap: 5px; }
.machine-edit-reference-box span { font-size: 11px; color: #181818; font-weight: 700; }
.machine-edit-reference-box small { font-size: 10px; color: #7e828a; font-weight: 400; line-height: 1.45; }
.machine-edit-reference-box .inline-action { align-self: flex-start; padding: 3px 0; }
.machine-edit-reference-field { gap: 7px !important; }
@media (max-width: 560px) {
  .machine-edit-reference-box { align-items: flex-start; flex-direction: column; }
  .machine-edit-reference-box img { width: 100%; height: 120px; }
}

.machine-edit-catalog-box { border: 1px solid var(--line); border-radius: 8px; background: #fafaf7; padding: 10px; }
.machine-catalog-search { display: flex; gap: 8px; }
.machine-catalog-search input { flex: 1; }
.machine-catalog-preview { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.machine-catalog-preview img { width: 180px; height: 105px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #ffffff; }
.machine-catalog-preview b, .machine-catalog-preview small { display: block; }
.machine-catalog-preview b { font-size: 11px; color: #181818; }
.machine-catalog-preview small { font-size: 10px; color: #7e828a; margin: 5px 0 0; }
.machine-catalog-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.machine-catalog-result { display: flex; gap: 8px; align-items: center; padding: 8px; background: #ffffff; border: 1px solid var(--line); border-radius: 7px; min-width: 0; }
.machine-catalog-result img { width: 82px; height: 62px; object-fit: cover; border-radius: 5px; background: #f3f3ef; flex: 0 0 auto; }
.machine-catalog-result b, .machine-catalog-result small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.machine-catalog-result b { font-size: 10px; color: #181818; }
.machine-catalog-result small { font-size: 9px; color: #848890; margin: 3px 0; }
.machine-catalog-result .btn { padding: 5px 7px; font-size: 9px; }
@media (max-width: 560px) {
  .machine-catalog-search { flex-direction: column; }
  .machine-catalog-preview { align-items: flex-start; flex-direction: column; }
  .machine-catalog-preview img { width: 100%; height: 130px; }
  .machine-catalog-results { grid-template-columns: 1fr; }
}

.modal-wide { width: min(880px, 95vw); max-height: 90vh; overflow-y: auto; }
.part-detail-body { display: flex; flex-direction: column; gap: 14px; margin: 10px 0 14px; }
.part-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 10px; }
.part-detail-box { background: #fafaf7; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.part-detail-box span { display: block; font-size: 10px; font-weight: 700; color: #757982; text-transform: uppercase; letter-spacing: 0.04em; }
.part-detail-box strong { display: block; font-size: 13px; color: #111111; margin-top: 3px; }
.part-detail-section { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #ffffff; }
.part-detail-section h4 { margin: 0 0 8px; font-size: 12px; color: #181818; text-transform: uppercase; letter-spacing: 0.04em; }
.evidence-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.evidence-card { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fafaf7; }
.evidence-card img { width: 100%; height: 165px; object-fit: cover; display: block; background: #111111; cursor: zoom-in; }
.evidence-card-meta { padding: 8px 10px; font-size: 11px; color: #36393f; }
.evidence-card-meta b { display: block; color: #111111; margin-bottom: 2px; }
.evidence-card-meta small { display: block; color: #757982; font-size: 10px; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #fffdf2; }

/* Aplicativos en línea + versión compacta en Resumen */
.nav-pill {
  margin-left: auto;
  background: #242420;
  color: #d6d6cf;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.nav-pill.online { background: var(--yellow); color: #000000; }
.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
  margin-right: 5px;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.25);
}
.devices-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  padding: 0 18px 16px;
}
.device-row {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 13px;
  background: #fafaf8;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.device-row-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.device-row-main strong { display: block; font-size: 0.88rem; color: #111111; }
.device-row-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.78rem; color: #5b5f66; flex-wrap: wrap; }
.devices-compact-panel .panel-head { padding: 12px 18px 10px; }
.devices-list-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 18px 13px;
}
.devices-list-compact .device-row {
  flex: 1 1 250px;
  max-width: 340px;
  padding: 9px 12px;
  gap: 4px;
  background: #ffffff;
  border-left: 3px solid #181818;
}
.devices-list-compact .device-row-main .sub { display: none; }
.empty-inline {
  padding: 12px 14px;
  color: #747880;
  font-size: 0.85rem;
  background: #fafaf7;
  border-radius: 8px;
  border: 1px dashed #d6d6ce;
  width: 100%;
}

/* Clean compact single-row layout for Maquinaria cards */
.machine-row { display: grid !important; grid-template-columns: 144px minmax(0, 1fr) !important; gap: 18px !important; align-items: center !important; padding: 14px 18px !important; }
.machine-row-photo { align-items: center !important; width: 144px; }
.machine-row-photo img, .machine-photo-empty { width: 144px !important; height: 88px !important; border-radius: 8px !important; }
.machine-row-content { display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 10px; min-width: 0; }
.machine-row-top { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1; }
.machine-row-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.machine-row-info .machine-card-head { display: flex; align-items: center; gap: 8px; margin: 0; justify-content: flex-start; flex-wrap: wrap; }
.machine-row-info h3 { margin: 0; font-size: 1.03rem; line-height: 1.25; color: #111111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.machine-meta-line { margin: 0; font-size: 0.84rem; color: #6e727a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.machine-row-reference { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: #fafaf7; flex-shrink: 0; }
.machine-row-reference img { display: block; width: 96px; height: 56px; object-fit: contain; border-radius: 5px; }
.machine-row-actions { display: flex !important; flex-wrap: wrap !important; align-items: center !important; gap: 8px !important; flex-shrink: 0; padding: 0; border: 0; }
.machine-row-actions .btn { height: 34px !important; min-height: 34px !important; padding: 0 12px !important; margin: 0 !important; font-size: 0.82rem !important; display: inline-flex !important; align-items: center !important; justify-content: center !important; white-space: nowrap !important; line-height: 1 !important; }
.machine-row-actions .machine-detail-btn { margin-left: 0 !important; margin-top: 0 !important; }
@media (max-width: 1180px) { .machine-row-content { flex-direction: column; align-items: stretch; gap: 12px; } .machine-row-actions { flex-wrap: wrap !important; } }
@media (max-width: 780px) { .machine-row { grid-template-columns: 1fr !important; } .machine-row-photo { width: 100% !important; } .machine-row-info h3, .machine-meta-line { white-space: normal; } }

/* Menú de perfil limpio */
.profile-wrap { position: relative; }
.profile-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid #dcdcd5;
  border-radius: 999px;
  padding: 4px 8px 4px 14px;
  cursor: pointer;
  text-align: right;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.profile-trigger:hover { border-color: #111111; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06); }
.profile-meta { display: flex; flex-direction: column; line-height: 1.2; }
.profile-meta span { font-size: 0.7rem; color: #787c84; font-weight: 600; }
.profile-meta strong { font-size: 0.84rem; color: #111111; max-width: 195px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 240px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-top: 3px solid var(--yellow);
  border-radius: 11px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.14);
  padding: 8px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.profile-dropdown[hidden] { display: none !important; }
.profile-dropdown-head { padding: 8px 10px 10px; border-bottom: 1px solid #efefea; margin-bottom: 4px; display: flex; flex-direction: column; gap: 2px; }
.profile-dropdown-head strong { font-size: 0.9rem; color: #111111; }
.profile-dropdown-head span { font-size: 0.76rem; color: #8a6600; font-weight: 700; }
.profile-dropdown button { width: 100%; text-align: left; background: transparent; border: 0; border-radius: 8px; padding: 9px 10px; font-size: 0.86rem; font-weight: 600; color: #1f2228; cursor: pointer; }
.profile-dropdown button:hover { background: var(--yellow-soft); color: #000000; }
.profile-dropdown button.danger-item { color: #b91c1c; }
.profile-dropdown button.danger-item:hover { background: #fef2f2; color: #b91c1c; }

/* Developer mode switcher bar (Negro + Amarillo) */
.dev-mode-bar {
  background: #111111;
  border: 1px solid var(--yellow);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 10px;
  margin: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.dev-mode-bar[hidden] { display: none !important; }
.dev-bar-left { display: flex; align-items: center; gap: 10px; font-size: 0.84rem; font-weight: 600; flex-wrap: wrap; }
.dev-pill { background: var(--yellow); color: #000000; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em; }
.dev-bar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dev-select-wrap { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 700; }
.dev-select-wrap select { height: 32px; border-radius: 7px; border: 1px solid #383833; background: #ffffff; color: #111111; padding: 0 10px; font-size: 0.82rem; font-weight: 600; max-width: 260px; }
.dev-btn-light { background: #22221e !important; color: #ffffff !important; border: 1px solid #3c3c36 !important; height: 32px !important; padding: 0 11px !important; font-size: 0.8rem !important; }
.dev-btn-light:hover { background: var(--yellow) !important; color: #000000 !important; border-color: var(--yellow) !important; }

/* Clean embedded APK mode */
body.apk-embedded .notice { display: none !important; }
body.apk-embedded .top-actions { display: none !important; }
body.apk-embedded .topbar { min-height: 48px !important; padding: 4px 0 10px !important; border-bottom: 1px solid var(--line); }
body.apk-embedded .sidebar a[href="/operador.html"], body.apk-embedded #open-connectivity-modal { display: none !important; }
body.apk-embedded .welcome { min-height: 104px !important; padding: 16px 18px !important; margin-top: 10px !important; }
body.apk-embedded .welcome h2 { font-size: 1.22rem !important; margin: 4px 0 !important; }
body.apk-embedded .welcome p:not(.eyebrow) { font-size: 0.82rem !important; }

/* Strict vertical-only scrolling on mobile / APK WebView */
html, body { max-width: 100%; overflow-x: hidden; background: #f8f8f6; }
.main, .view, .panel { min-width: 0; max-width: 100%; }
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 780px) {
  .sidebar { box-shadow: none !important; z-index: 300 !important; }
  .sidebar.menu-open { box-shadow: 0 0 0 100vw rgba(0, 0, 0, 0.58) !important; }
  .main { padding: 10px 14px 30px !important; width: 100% !important; max-width: 100vw !important; overflow-x: hidden !important; }
  .topbar { height: auto !important; min-height: 54px !important; padding: 6px 0 10px !important; flex-wrap: nowrap !important; align-items: center !important; justify-content: flex-start !important; gap: 10px !important; }
  .topbar > div:nth-child(2) { flex: 1; min-width: 0; }
  .topbar .eyebrow { display: none !important; }
  .topbar h1 { font-size: 1.15rem !important; margin: 0 !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-actions { width: auto !important; flex-wrap: nowrap !important; justify-content: flex-end !important; gap: 8px !important; flex-shrink: 0; }
  .profile-trigger { padding: 3px 6px 3px 10px !important; gap: 8px !important; }
  .profile-meta span { font-size: 0.66rem !important; }
  .profile-meta strong { max-width: 120px !important; font-size: 0.78rem !important; }
  .notice { flex-wrap: wrap !important; word-break: break-word !important; margin: 10px 0 12px !important; }
  .panel-head { flex-wrap: wrap !important; gap: 8px !important; align-items: flex-start !important; padding: 14px !important; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; margin: 12px 0 !important; }
  .stat { padding: 13px 14px !important; }
  .grid-two, .devices-list { grid-template-columns: 1fr !important; gap: 12px !important; }
  .devices-list-compact .device-row { max-width: none !important; }
  .section-head { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; }
  .filters { flex-direction: column !important; align-items: stretch !important; gap: 8px !important; }
  .filters input, .filters select, .filters button { width: 100% !important; min-width: 0 !important; }
  .machine-row { padding: 14px !important; gap: 12px !important; }
  .machine-row-content, .machine-row-top { flex-direction: column !important; align-items: stretch !important; }
  .machine-row-actions { flex-wrap: wrap !important; gap: 8px !important; }
  .machine-row-actions .btn { flex: 1 1 calc(50% - 8px) !important; white-space: normal !important; height: auto !important; min-height: 38px !important; padding: 8px 10px !important; text-align: center !important; }
  dialog { width: calc(100vw - 16px) !important; max-width: calc(100vw - 16px) !important; padding: 16px !important; border-radius: 12px !important; }
  .modal-foot { flex-direction: column !important; align-items: stretch !important; gap: 10px !important; }
  .modal-foot > span { max-width: 100% !important; }
  .modal-foot .btn { width: 100% !important; }
}

/* Unified single download dropdown button */
.download-menu-wrap { position: relative; display: inline-block; }
.download-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 240px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-top: 3px solid var(--yellow);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
  padding: 6px;
  z-index: 220;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.download-menu[hidden] { display: none !important; }
.download-menu button { width: 100%; text-align: left; background: transparent; border: 0; border-radius: 7px; padding: 9px 12px; font-size: 0.86rem; font-weight: 700; color: #181818; cursor: pointer; white-space: nowrap; }
.download-menu button:hover { background: var(--yellow-soft); color: #000000; }

/* Profile caret & sidebar logout */
.profile-caret { font-size: 0.75rem; color: #6b6f76; margin-right: 4px; }
.sidebar-logout-btn {
  width: 100%;
  color: #e5e5e0 !important;
  background: #1b1b18 !important;
  border: 1px solid #2b2b26 !important;
  border-radius: 8px;
  margin-bottom: 6px !important;
}
.sidebar-logout-btn:hover {
  background: rgba(239, 68, 68, 0.18) !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  color: #fecaca !important;
}
body.apk-embedded .sidebar-logout-btn { display: none !important; }
