:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #142033;
  --muted: #63728a;
  --line: #e1e5ee;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #2563eb;
  --warning: #d97706;
  --danger: #dc2626;
  --success: #15803d;
  --shadow: 0 14px 34px rgba(23, 32, 51, 0.10);
  --soft-shadow: 0 4px 14px rgba(23, 32, 51, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #dfeaf4 0, #f6f8fb 260px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: max(12px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 auto 12px;
  max-width: 760px;
}

.app-topbar h1,
.driver-card h2,
.panel h2,
.guide-card h3 {
  margin: 0;
}

.app-topbar h1 {
  font-size: 22px;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.panel,
.driver-card,
.summary-card,
.toolbar,
.guide-card,
.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.panel {
  width: min(100%, 520px);
  max-width: 520px;
  margin: 18px auto;
  padding: 18px;
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

label {
  color: #42526a;
  display: grid;
  font-size: 12px;
  font-weight: 800;
  gap: 6px;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  border: 1px solid #c9d5e5;
  border-radius: 7px;
  color: var(--ink);
  min-height: 48px;
  padding: 12px 12px;
  outline: none;
  background: #fff;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

button {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
  min-height: 46px;
  padding: 11px 14px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-btn {
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
  color: white;
}

.primary-btn:hover {
  background: var(--primary-dark);
}

.secondary-btn {
  background: #eff6ff;
  color: var(--primary-dark);
}

.ghost-btn,
.icon-btn {
  background: #eef3fa;
  color: #42526a;
}

.manual-box {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 12px;
}

.manual-box summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.connection-field {
  margin-top: 12px;
}

.hidden {
  display: none !important;
}

#appView {
  max-width: 980px;
  margin: 0 auto;
}

.driver-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  position: sticky;
  top: max(8px, env(safe-area-inset-top));
  z-index: 10;
}

.driver-actions {
  display: flex;
  gap: 8px;
}

.status-pill {
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 10px;
}

.status-pill.online {
  background: #dcfce7;
  color: var(--success);
}

.status-pill.offline {
  background: #fee2e2;
  color: var(--danger);
}

.summary-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, 1fr);
  margin: 12px 0;
}

.summary-card {
  appearance: none;
  border: 1px solid var(--line);
  padding: 13px;
  text-align: left;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
  width: 100%;
}

.summary-card:focus,
.summary-card:hover,
.summary-card.active {
  border-color: var(--accent);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.16);
  transform: translateY(-1px);
}

.summary-card.active {
  background: #eef5ff;
}

.summary-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-card strong {
  display: block;
  font-size: 28px;
  line-height: 1;
  margin-top: 8px;
}

.toolbar {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 180px;
  margin-bottom: 12px;
  padding: 12px;
}

.notice {
  border-left: 4px solid var(--warning);
  color: #6b4a00;
  margin-bottom: 12px;
  padding: 12px;
}

.guides-list {
  display: grid;
  gap: 12px;
}

.guide-card {
  padding: 14px;
}

.guide-head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.guide-number {
  appearance: none;
  background: transparent;
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
  min-height: auto;
  padding: 0;
  text-align: left;
}

.guide-number.collapsible {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.guide-number.collapsible::after {
  content: " Ver detalle";
  color: var(--muted);
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  margin-left: 6px;
  text-decoration: none;
  text-transform: uppercase;
}

.guide-number.collapsible[aria-expanded="true"]::after {
  content: " Ocultar";
}

.guide-card.is-delivered-collapsed {
  padding-bottom: 12px;
}

.guide-card.is-delivered-collapsed .guide-data,
.guide-card.is-delivered-collapsed .guide-milestones,
.guide-card.is-delivered-collapsed .guide-actions {
  display: none;
}

.guide-status {
  border-radius: 999px;
  color: white;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
  text-align: center;
}

.guide-status.pending {
  background: var(--warning);
}

.guide-status.transit {
  background: var(--accent);
}

.guide-status.done {
  background: var(--success);
}

.guide-status.other {
  background: #64748b;
}

.guide-data {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 14px 0;
}

.guide-data div {
  border-top: 1px solid #edf2f7;
  padding-top: 8px;
}

.guide-data dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.guide-data dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.guide-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1.2fr 1fr 1fr;
}

.guide-milestones {
  border-top: 1px solid #edf2f7;
  display: grid;
  gap: 8px;
  margin: 4px 0 14px;
  padding-top: 12px;
}

.milestone-head {
  align-items: baseline;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.milestone-head strong {
  font-size: 13px;
}

.milestone-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.milestone-list {
  display: grid;
  gap: 8px;
}

.milestone-item {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) 116px;
  padding: 10px;
}

.milestone-item.done {
  background: #effaf3;
  border-color: #bbf7d0;
}

.milestone-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.milestone-text strong,
.milestone-text span {
  overflow-wrap: anywhere;
}

.milestone-text span {
  color: var(--muted);
  font-size: 12px;
}

.milestone-action {
  min-height: 40px;
  padding: 8px 10px;
}

.empty-state {
  color: var(--muted);
  padding: 28px 12px;
  text-align: center;
}

.module-switch {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, 1fr);
  margin: 12px 0;
  padding: 6px;
  position: sticky;
  top: 82px;
  z-index: 9;
  backdrop-filter: blur(10px);
}

.module-btn {
  background: transparent;
  color: #52637a;
}

.module-btn.active {
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
  color: #fff;
}

.gate-hero {
  align-items: center;
  background: linear-gradient(135deg, #ffffff 0%, #edf8f5 55%, #eef5ff 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 16px;
}

.gate-hero h2,
.gate-panel h3,
.panel-head h3 {
  margin: 0;
}

.gate-tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  overflow-x: auto;
  padding: 2px 2px 10px;
  scroll-snap-type: x proximity;
}

.gate-tab-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: #52637a;
  flex: 0 0 158px;
  min-height: 50px;
  scroll-snap-align: start;
}

.gate-tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.22);
  color: #fff;
}

.gate-panel {
  margin-top: 0;
  max-width: none;
  padding: 16px;
}

.gate-panel h3 {
  font-size: 18px;
  margin-bottom: 12px;
}

.scan-row,
.gate-grid,
.compact-buttons {
  display: grid;
  gap: 10px;
}

.scan-row {
  grid-template-columns: minmax(0, 1fr) 74px 92px;
  margin-bottom: 12px;
}

.gate-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 10px 0;
}

.compact-buttons {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 6px 0 12px;
}

.gate-result {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #52637a;
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  min-height: 58px;
  padding: 12px;
}

.gate-result strong {
  color: var(--ink);
}

.gate-result span,
.gate-result small {
  overflow-wrap: anywhere;
}

textarea {
  border: 1px solid #c9d5e5;
  border-radius: 7px;
  color: var(--ink);
  font: inherit;
  min-height: 88px;
  outline: none;
  padding: 10px 12px;
  resize: vertical;
  width: 100%;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.check-list {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.check-list label {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: row;
  gap: 10px;
  min-height: 46px;
  padding: 10px 12px;
  text-transform: none;
}

.check-list input {
  min-height: auto;
  width: auto;
}

.full-btn {
  margin-top: 12px;
  width: 100%;
}

.gate-details {
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 10px 0;
  padding: 12px;
}

.native-select-hidden {
  display: none;
}

.search-select {
  position: relative;
}

.search-select-input {
  padding-right: 38px;
  background:
    linear-gradient(45deg, transparent 50%, #6b7b90 50%) right 18px center / 7px 7px no-repeat,
    #fff;
}

.search-select-list {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.18);
  left: 0;
  max-height: 248px;
  overflow: auto;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
}

.search-select-option {
  background: transparent;
  border-radius: 6px;
  color: var(--ink);
  display: block;
  min-height: 42px;
  padding: 10px;
  text-align: left;
  width: 100%;
}

.search-select-option:hover,
.search-select-option:focus {
  background: #eaf2ff;
  color: #174eb9;
}

.search-select-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 12px;
  text-align: center;
}

.gate-details summary {
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
}

.gate-details label {
  margin-top: 10px;
}

.panel-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 12px;
}

.history-item span,
.history-item small {
  color: var(--muted);
}

.qr-scan-overlay {
  align-items: center;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 9999;
}

.qr-scan-box {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  display: grid;
  gap: 12px;
  max-width: 460px;
  padding: 14px;
  width: 100%;
}

.qr-scan-box video {
  background: #0f172a;
  border-radius: 8px;
  min-height: 280px;
  object-fit: cover;
  width: 100%;
}

.qr-scan-box p {
  color: var(--muted);
  margin: 0;
  text-align: center;
}

@media (max-width: 680px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .app-topbar {
    align-items: flex-start;
    margin-bottom: 8px;
  }

  .panel {
    margin: 12px 0;
    max-width: 100%;
  }

  .driver-card,
  .guide-head {
    align-items: stretch;
    flex-direction: column;
  }

  .driver-actions,
  .guide-actions,
  .milestone-item,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .driver-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guide-data {
    grid-template-columns: 1fr;
  }

  .module-switch,
  .gate-grid,
  .compact-buttons,
  .scan-row {
    grid-template-columns: 1fr;
  }

  .module-switch {
    top: 112px;
  }

  .gate-tabs {
    margin-left: -10px;
    margin-right: -10px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .gate-tab-btn {
    flex-basis: 138px;
  }

  .gate-hero,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .gate-tab-btn {
    min-height: 48px;
  }

  .qr-scan-box video {
    min-height: 220px;
  }
}

/* Shell BPS Driver Task: sidebar y modulos del empleado. */
body.app-authenticated {
  background: var(--bg);
}

body.app-authenticated .app-shell {
  padding: 0;
}

body.app-authenticated .app-topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 260px;
  z-index: 30;
  width: auto;
  max-width: none;
  min-height: 70px;
  margin: 0;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 12px rgba(23, 32, 51, 0.05);
  backdrop-filter: blur(14px);
}

body.app-authenticated .app-topbar h1 {
  font-size: 19px;
}

.sidebar-toggle {
  width: 42px;
  min-height: 42px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.sidebar-toggle span {
  display: block;
  height: 2px;
  margin: 4px 0;
  border-radius: 2px;
  background: var(--ink);
}

body.app-authenticated #appView {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  margin: 0;
  padding: 86px 24px 32px 284px;
}

body.app-authenticated #appView > .driver-card,
body.app-authenticated #appView > #guidesView,
body.app-authenticated #appView > #gateView,
body.app-authenticated #appView > .employee-view {
  width: min(100%, 1180px);
  margin-right: auto;
  margin-left: auto;
}

body.app-authenticated .driver-card {
  position: static;
  margin-bottom: 14px;
  padding: 14px 18px;
  box-shadow: none;
}

.module-switch {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: flex;
  width: 260px;
  height: 100vh;
  margin: 0;
  padding: 18px 14px;
  border: 0;
  border-right: 1px solid #25324b;
  border-radius: 0;
  background: #172033;
  box-shadow: 8px 0 24px rgba(15, 23, 42, 0.12);
  color: #fff;
  flex-direction: column;
  overflow-y: auto;
  backdrop-filter: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 4px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .03em;
}

.sidebar-brand strong,
.sidebar-brand small,
.sidebar-user strong,
.sidebar-user small {
  display: block;
}

.sidebar-brand strong {
  font-size: 16px;
}

.sidebar-brand small,
.sidebar-user small {
  margin-top: 2px;
  color: #9aa8c1;
  font-size: 11px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-user > span:last-child {
  min-width: 0;
}

.sidebar-user strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 50%;
  color: #172033;
  background: #7dd3fc;
  font-size: 13px;
  font-weight: 900;
}

.sidebar-label {
  margin: 10px 10px 6px;
  color: #7f8da8;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.module-btn {
  display: grid;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  color: #cbd5e1;
  background: transparent;
  font-size: 13px;
  text-align: left;
}

.module-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.module-btn.active {
  border-color: rgba(96, 165, 250, 0.45);
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}

.module-btn small {
  min-width: 22px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 10px;
  text-align: center;
}

.nav-icon {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 15px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: auto;
  padding: 18px 8px 4px;
  color: #8997b1;
  font-size: 10px;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, .12);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  padding: 0;
  border-radius: 0;
  background: rgba(15, 23, 42, .54);
}

.module-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 128px;
  margin-bottom: 14px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.module-hero h2 {
  margin: 0;
  font-size: clamp(21px, 3vw, 28px);
}

.module-hero-maintenance {
  background: linear-gradient(120deg, #ffffff 50%, #eff6ff 100%);
}

.module-hero-quality {
  background: linear-gradient(120deg, #ffffff 50%, #f5f3ff 100%);
}

.module-hero-safety {
  background: linear-gradient(120deg, #ffffff 50%, #ecfeff 100%);
}

.employee-summary {
  margin-bottom: 14px;
}

.employee-summary .summary-card {
  cursor: default;
}

.employee-summary .summary-card:hover {
  border-color: var(--line);
  box-shadow: var(--soft-shadow);
  transform: none;
}

.record-list {
  display: grid;
  gap: 12px;
}

.record-card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.record-card-head,
.record-card-title,
.record-actions,
.task-row,
.record-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.record-card-head {
  align-items: flex-start;
  justify-content: space-between;
}

.record-card-title {
  align-items: flex-start;
}

.record-code {
  display: grid;
  min-width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: var(--primary-dark);
  background: #eff6ff;
  font-size: 11px;
  font-weight: 900;
}

.record-card h3,
.record-card h4 {
  margin: 0;
}

.record-card h3 {
  font-size: 17px;
}

.record-meta {
  flex-wrap: wrap;
  margin: 12px 0;
  color: var(--muted);
  font-size: 12px;
}

.record-meta span {
  padding-right: 10px;
  border-right: 1px solid var(--line);
}

.record-description {
  margin: 10px 0 0;
  color: #42526a;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.record-status {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  color: #475569;
  background: #eef2f7;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.record-status.pending,
.record-status.open {
  color: #92400e;
  background: #fef3c7;
}

.record-status.progress {
  color: #1d4ed8;
  background: #dbeafe;
}

.record-status.done,
.record-status.closed {
  color: #166534;
  background: #dcfce7;
}

.record-status.critical {
  color: #991b1b;
  background: #fee2e2;
}

.task-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.task-row {
  justify-content: space-between;
  min-height: 54px;
  padding: 9px 10px;
  border: 1px solid #e8edf4;
  border-radius: 8px;
  background: #f8fafc;
}

.task-row > div {
  min-width: 0;
}

.task-row strong,
.task-row small {
  display: block;
  overflow-wrap: anywhere;
}

.task-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.task-actions,
.record-actions {
  flex: 0 0 auto;
}

.task-actions button,
.record-actions button {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 11px;
}

.employee-form-panel {
  width: 100%;
  max-width: none;
  margin: 0 0 14px;
  padding: 18px;
}

.employee-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-span-2 {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.records-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.empty-records {
  padding: 38px 20px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, .7);
  text-align: center;
}

@media (max-width: 860px) {
  body.app-authenticated .app-topbar {
    left: 0;
    padding: 10px 12px;
  }

  body.app-authenticated .sidebar-toggle {
    display: block !important;
  }

  body.app-authenticated #appView {
    padding: 82px 12px 24px;
  }

  .module-switch {
    width: min(286px, 86vw);
    transform: translateX(-105%);
    transition: transform .2s ease;
  }

  .module-switch.sidebar-open {
    transform: translateX(0);
  }

  body.app-authenticated .driver-card {
    position: static;
  }

  .module-hero {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  body.app-authenticated .topbar-brand .eyebrow {
    display: none;
  }

  body.app-authenticated .topbar-brand h1 {
    font-size: 16px;
  }

  body.app-authenticated .status-pill {
    padding: 6px 8px;
    font-size: 10px;
  }

  body.app-authenticated .driver-card {
    align-items: center;
    flex-direction: row;
  }

  body.app-authenticated .driver-card h2 {
    font-size: 17px;
  }

  body.app-authenticated .driver-card .muted {
    font-size: 11px;
  }

  body.app-authenticated .driver-actions {
    display: flex;
  }

  body.app-authenticated .driver-actions button {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 11px;
  }

  .employee-form,
  .records-toolbar,
  .employee-summary {
    grid-template-columns: 1fr;
  }

  .form-span-2 {
    grid-column: auto;
  }

  .record-card-head,
  .task-row {
    align-items: stretch;
    flex-direction: column;
  }

  .task-actions,
  .record-actions {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-actions button,
  .record-actions button {
    width: 100%;
  }
}

/* Portal B2B 2026: capa visual compartida para Driver Task. */
body.app-authenticated {
  --bg: #f4f7fb;
  --ink: #172b4d;
  --muted: #65758b;
  --line: #dce4ef;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --soft-shadow: 0 2px 8px rgba(23, 43, 77, .04);
  color: var(--ink);
  background: var(--bg);
}

body.app-authenticated .app-topbar {
  left: 240px;
  min-height: 64px;
  padding: 8px 18px 8px 26px;
  border-color: var(--line);
  background: rgba(255, 255, 255, .98);
  box-shadow: none;
}

.topbar-context {
  min-width: 0;
  margin-right: auto;
  line-height: 1.1;
}

.topbar-context p,
.topbar-context strong {
  display: block;
  margin: 0;
}

.topbar-context p {
  margin-bottom: 4px;
  color: #6b7b91;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.topbar-context strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.utility-btn,
.clock-card {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid #d6e0ed;
  border-radius: 8px;
  color: #52637a;
  background: #fff;
  box-shadow: none;
  font-size: 10px;
  font-weight: 750;
}

.utility-btn:hover {
  border-color: #b9cced;
  color: var(--primary-dark);
  background: #f8fbff;
  transform: none;
}

.utility-btn > span:first-child,
.clock-card > span:first-child {
  color: var(--primary);
  font-size: 15px;
  line-height: 1;
}

.clock-card div,
.clock-card strong,
.clock-card small {
  display: block;
}

.clock-card strong {
  color: var(--ink);
  font-size: 11px;
  letter-spacing: .03em;
}

.clock-card small {
  margin-top: 2px;
  color: #7b899d;
  font-size: 8px;
}

body.app-authenticated .status-pill {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid #bfe8db;
  color: #138565;
  background: #edf9f5;
  box-shadow: none;
  font-size: 9px;
  font-weight: 800;
}

body.app-authenticated .status-pill::before {
  width: 7px;
  height: 7px;
}

body.app-authenticated #appView {
  padding: 86px 22px 36px 262px;
}

body.app-authenticated #appView > #guidesView,
body.app-authenticated #appView > #gateView,
body.app-authenticated #appView > .employee-view {
  width: min(100%, 1280px);
}

.module-switch {
  width: 240px;
  padding: 0 11px 12px;
  border-right: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  box-shadow: none;
}

.sidebar-brand {
  min-height: 88px;
  margin: 0 -11px 5px;
  padding: 20px 26px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand img {
  display: block;
  width: 142px;
  max-height: 44px;
  object-fit: contain;
  object-position: left center;
}

.sidebar-label {
  margin: 15px 9px 7px;
  color: #8492a6;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .1em;
}

.sidebar-nav {
  gap: 3px;
}

.module-btn {
  position: relative;
  min-height: 42px;
  padding: 6px 9px;
  grid-template-columns: 27px minmax(0, 1fr) auto;
  border-radius: 7px;
  color: #52637a;
  font-size: 11px;
  font-weight: 700;
}

.module-btn::before {
  content: "";
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: -1px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
}

.module-btn:hover {
  color: var(--primary-dark);
  background: #f5f8fd;
}

.module-btn.active {
  border-color: #bfd2ff;
  color: var(--primary-dark);
  background: #edf3ff;
  box-shadow: none;
}

.module-btn.active::before {
  background: var(--primary);
}

.nav-icon {
  width: 25px;
  height: 25px;
  border-radius: 6px;
  color: #6b7f9b;
  background: #f1f5f9;
  font-size: 13px;
}

.module-btn.active .nav-icon,
.module-btn:hover .nav-icon {
  color: var(--primary);
  background: #dce8ff;
}

.module-btn small {
  min-width: 18px;
  padding: 2px 5px;
  color: #6b7b91;
  background: #edf1f6;
  font-size: 9px;
}

.module-btn.active small {
  color: var(--primary-dark);
  background: #d8e5ff;
}

.sidebar-spacer {
  min-height: 16px;
  flex: 1 1 auto;
}

.sidebar-user {
  margin: 8px 0 6px;
  padding: 9px;
  border-color: #d8e2ef;
  color: var(--ink);
  background: #fff;
}

.sidebar-user strong {
  color: var(--ink);
  font-size: 11px;
}

.sidebar-user small {
  color: #6e7e94;
  font-size: 9px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
  color: #fff;
  background: var(--primary);
}

.sidebar-account-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.sidebar-account-actions .ghost-btn {
  min-height: 31px;
  padding: 6px;
  border-color: #d8e2ef;
  color: #63738a;
  background: #fff;
  font-size: 9px;
}

.sidebar-account-actions .ghost-btn:hover {
  border-color: #b9cced;
  color: var(--primary-dark);
  background: #f7faff;
}

.sidebar-footer {
  margin-top: 4px;
  padding: 10px 5px 2px;
  border-top: 1px solid #edf1f6;
  color: #7d8ba0;
  font-size: 8px;
}

.module-hero,
.gate-hero {
  min-height: 116px;
  margin-bottom: 14px;
  padding: 12px 2px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.module-hero-maintenance,
.module-hero-quality,
.module-hero-safety {
  background: transparent;
}

.module-hero .eyebrow,
.gate-hero .eyebrow {
  color: var(--primary);
  font-size: 9px;
  letter-spacing: .08em;
}

.module-hero h2,
.gate-hero h2 {
  margin-top: 6px;
  color: var(--ink);
  font-size: clamp(24px, 3vw, 30px);
  line-height: 1.08;
}

.module-hero .muted,
.gate-hero .muted {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.summary-grid,
.employee-summary {
  gap: 10px;
  margin-bottom: 14px;
}

.summary-card {
  min-height: 98px;
  padding: 13px 15px;
  border-color: var(--line);
  border-left: 2px solid var(--primary);
  border-radius: 7px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.summary-card:hover,
.employee-summary .summary-card:hover {
  border-color: #bfd1ed;
  border-left-color: var(--primary);
  box-shadow: 0 4px 12px rgba(23, 43, 77, .06);
  transform: none;
}

.summary-card span {
  color: #56677e;
  font-size: 9px;
  letter-spacing: .04em;
}

.summary-card strong {
  margin-top: 7px;
  color: var(--ink);
  font-size: 28px;
}

.toolbar,
.records-toolbar,
.panel,
.record-card,
.employee-form-panel,
.gate-panel {
  border-color: var(--line);
  border-radius: 7px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.toolbar,
.records-toolbar {
  padding: 12px 14px;
}

.record-card {
  box-shadow: var(--soft-shadow);
}

body.app-authenticated input,
body.app-authenticated select,
body.app-authenticated textarea {
  border-color: #cad7e7;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  box-shadow: none;
}

body.app-authenticated input:focus,
body.app-authenticated select:focus,
body.app-authenticated textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .11);
}

body.app-authenticated .primary-btn,
body.app-authenticated .secondary-btn,
body.app-authenticated .ghost-btn,
body.app-authenticated .icon-btn {
  border-radius: 6px;
  box-shadow: none;
}

.empty-records,
.empty-state {
  border-color: #ccd8e8;
  background: rgba(255, 255, 255, .72);
}

body.app-authenticated.theme-dark {
  --bg: #111827;
  --ink: #e5edf8;
  --muted: #9aabc2;
  --line: #334155;
  color: var(--ink);
  background: var(--bg);
}

body.app-authenticated.theme-dark .app-topbar,
body.app-authenticated.theme-dark .module-switch,
body.app-authenticated.theme-dark .utility-btn,
body.app-authenticated.theme-dark .clock-card,
body.app-authenticated.theme-dark .sidebar-user,
body.app-authenticated.theme-dark .sidebar-account-actions .ghost-btn,
body.app-authenticated.theme-dark .summary-card,
body.app-authenticated.theme-dark .toolbar,
body.app-authenticated.theme-dark .records-toolbar,
body.app-authenticated.theme-dark .panel,
body.app-authenticated.theme-dark .record-card,
body.app-authenticated.theme-dark .employee-form-panel,
body.app-authenticated.theme-dark .gate-panel {
  color: var(--ink);
  background: #182235;
  border-color: var(--line);
}

body.app-authenticated.theme-dark .sidebar-brand img {
  padding: 5px;
  border-radius: 6px;
  background: #fff;
}

body.app-authenticated.theme-dark input,
body.app-authenticated.theme-dark select,
body.app-authenticated.theme-dark textarea,
body.app-authenticated.theme-dark .task-row {
  color: var(--ink);
  border-color: #3b4a60;
  background: #111827;
}

body.app-authenticated.theme-dark .topbar-context strong,
body.app-authenticated.theme-dark .clock-card strong,
body.app-authenticated.theme-dark .sidebar-user strong,
body.app-authenticated.theme-dark .module-hero h2,
body.app-authenticated.theme-dark .gate-hero h2,
body.app-authenticated.theme-dark .summary-card strong {
  color: var(--ink);
}

body.app-authenticated.theme-dark .module-btn,
body.app-authenticated.theme-dark .summary-card span,
body.app-authenticated.theme-dark .sidebar-user small,
body.app-authenticated.theme-dark .record-description {
  color: #a9b8cb;
}

body.app-authenticated.theme-dark .module-btn:hover,
body.app-authenticated.theme-dark .module-btn.active {
  color: #8eb4ff;
  border-color: #405987;
  background: #22304a;
}

body.app-authenticated.theme-dark .empty-records,
body.app-authenticated.theme-dark .empty-state {
  color: var(--muted);
  border-color: #40506a;
  background: rgba(24, 34, 53, .72);
}

@media (max-width: 1040px) {
  .utility-theme span:last-child,
  .utility-fullscreen span:last-child {
    display: none;
  }
}

@media (max-width: 860px) {
  body.app-authenticated .app-topbar {
    left: 0;
    min-height: 60px;
    padding: 7px 10px;
  }

  body.app-authenticated #appView {
    padding: 76px 12px 24px;
  }

  .module-switch {
    width: min(270px, 88vw);
    box-shadow: 12px 0 32px rgba(23, 43, 77, .18);
  }

  .sidebar-brand {
    min-height: 76px;
  }

  .module-hero,
  .gate-hero {
    min-height: 104px;
  }
}

@media (max-width: 620px) {
  .topbar-context p,
  .clock-card,
  .utility-theme,
  .utility-fullscreen {
    display: none;
  }

  .topbar-context strong {
    font-size: 12px;
  }

  body.app-authenticated .status-pill {
    padding: 6px 8px;
  }

  .module-hero,
  .gate-hero {
    align-items: flex-start;
    min-height: 0;
    padding-top: 6px;
  }

  .module-hero h2,
  .gate-hero h2 {
    font-size: 24px;
  }

  .summary-card {
    min-height: 84px;
  }
}
