:root {
  --bg-top: #0a2342;
  --bg-bottom: #135099;
  --card: #ffffff;
  --text: #142032;
  --muted: #5a6a7d;
  --border: #d5dde8;
  --primary: #0f4c97;
  --primary-hover: #0c3d78;
  --danger: #b91c1c;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(10, 35, 66, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
}

/* Pantalla de login: ver /static/ui/login.css */

body.app-mode {
  min-height: 100vh;
  background: #e8ecf2;
}

.btn-primary {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  min-height: 48px;
}

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

.btn-secondary {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  background: #f0f3f8;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  min-height: 46px;
}

.btn-secondary:hover {
  background: #e5eaf2;
}

.btn-danger {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: #b42318;
  border: 1px solid #912018;
  border-radius: 10px;
  cursor: pointer;
  min-height: 46px;
}

.btn-danger:hover {
  background: #912018;
}

.user-hr-admin-actions {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.user-hr-admin-actions__hint {
  font-size: 0.9rem;
  margin: 0 0 0.65rem;
  opacity: 0.9;
}

.user-hr-admin-actions__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.user-hr-admin-actions__row .btn-secondary,
.user-hr-admin-actions__row .btn-danger {
  flex: 1 1 12rem;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1rem;
}

.btn-link {
  text-align: center;
  font-size: 0.88rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.btn-link:hover {
  text-decoration: underline;
}

.msg {
  margin-top: 1rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  font-size: 0.88rem;
  background: #e8f2fc;
  border: 1px solid #b8d4f0;
  color: #0b3d73;
}

.msg.msg-err {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.dashboard-stats-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.dashboard-stat-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  padding: 0.85rem;
}

.dashboard-stat-label {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.dashboard-stat-value {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
}

.hidden {
  display: none !important;
}

body.product-ficha-open {
  overflow: hidden;
}

.product-ficha-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  box-sizing: border-box;
}

.product-ficha-overlay.hidden {
  display: none !important;
}

.product-ficha-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 0;
}

.product-ficha-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 52rem;
  margin: 0.5rem auto 2rem;
  background: var(--card, #fff);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
}

.product-ficha-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.product-ficha-title {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
  padding-right: 0.5rem;
}

.product-ficha-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 1.25rem;
  padding: 1.15rem;
}

@media (max-width: 768px) {
  .product-ficha-body {
    grid-template-columns: 1fr;
  }
}

.product-ficha-media {
  text-align: center;
}

.product-ficha-img {
  max-width: 100%;
  max-height: min(42vh, 360px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fafc;
}

.product-ficha-img.hidden {
  display: none;
}

.product-ficha-noimg {
  margin: 1rem 0;
  color: var(--muted, #64748b);
}

.product-ficha-noimg.hidden {
  display: none;
}

.product-ficha-meta {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text, #0f172a);
}

.product-ficha-desc {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.product-ficha-prices {
  margin: 0 0 0.85rem;
  padding: 0.85rem 1rem;
  background: #f1f5f9;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.product-ficha-prices-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.product-ficha-price-list {
  margin: 0;
  padding-left: 1.15rem;
}

.product-ficha-price-list li {
  margin: 0.25rem 0;
}

.product-ficha-stock {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted, #64748b);
}


.product-ficha-cell {
  white-space: nowrap;
  vertical-align: middle;
}

.products-list-pager {
  margin-top: 0.75rem;
}

.products-pager-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  justify-content: center;
}

.products-pager-meta {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted, #64748b);
}

.product-category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.product-category-row select,
.product-category-row input[type="text"] {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border, #cbd5e1);
  font-size: 0.9rem;
}

tr.product-cat-divider td {
  background: #f1f5f9;
  padding: 0.45rem 0.65rem;
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
}

.product-table-thumb {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
  vertical-align: middle;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

a.product-table-imglnk {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

a.product-table-imglnk:focus {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: 2px;
}

.product-table-desc {
  display: block;
  max-width: 22rem;
  font-size: 0.86rem;
  line-height: 1.4;
  white-space: normal;
  color: var(--text, #0f172a);
}

.users-table td.product-table-desc-cell {
  vertical-align: top;
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
}

.session-user {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.session-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #064a8f);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.session-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.session-meta {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.session-hint {
  margin-top: 1rem;
  margin-bottom: 0;
}

.staff-block {
  margin-top: 1.35rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.block-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 700;
}

.staff-lead {
  margin-bottom: 0.75rem !important;
}

.btn-inline {
  width: auto;
  margin-bottom: 0.75rem;
}

.users-list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.users-list-actions .btn-inline {
  margin-bottom: 0;
}

/* — Dashboard: agenda semanal — */
.dashboard-cal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

.dashboard-cal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.dashboard-cal-week-label {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}

.dashboard-cal-wrap {
  margin-top: 0.25rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafbfd;
  min-height: 12rem;
}

.dashboard-cal-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(8.5rem, 1fr));
  gap: 0;
  min-width: 720px;
  border-bottom: 1px solid var(--border);
}

.dashboard-cal-day {
  border-right: 1px solid var(--border);
  min-height: 18rem;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.dashboard-cal-day:last-child {
  border-right: none;
}

.dashboard-cal-day.is-today .dashboard-cal-day-head {
  background: #e8f2ff;
  color: var(--primary);
}

.dashboard-cal-day-head {
  padding: 0.45rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: capitalize;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  flex-shrink: 0;
}

.dashboard-cal-day-body {
  flex: 1;
  padding: 0.35rem 0.35rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-content: flex-start;
}

.dashboard-cal-empty {
  padding: 1rem 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.dashboard-cal-event {
  cursor: pointer;
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
  font-size: 0.78rem;
  line-height: 1.25;
  color: #fff;
  background: linear-gradient(135deg, #0b6bcb 0%, #4a90d9 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  word-break: break-word;
}

.dashboard-cal-event--contract {
  background: linear-gradient(135deg, #0a5a9e 0%, #3d7aaa 100%);
}

.dashboard-cal-event--quote {
  background: linear-gradient(135deg, #6b21a8 0%, #9333ea 100%);
}

.dashboard-cal-event:hover {
  filter: brightness(1.05);
}

.dashboard-cal-event-time {
  opacity: 0.92;
  font-weight: 600;
  font-size: 0.72rem;
}

.dashboard-cal-event-sub {
  opacity: 0.9;
  font-size: 0.7rem;
  margin-top: 0.15rem;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfd;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.users-table th,
.users-table td {
  padding: 0.45rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.users-table th {
  background: #eef2f8;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.users-table tr:last-child td {
  border-bottom: none;
}

.users-table td.num {
  color: var(--muted);
  width: 2.5rem;
}

.users-table td.ticket-col-tech {
  max-width: 11rem;
  white-space: normal;
  word-break: break-word;
  font-size: 0.92rem;
  line-height: 1.35;
}

.users-table tr.clickable-row {
  cursor: pointer;
}

.users-table tr.clickable-row:hover {
  background: #f4f7fb;
}

.users-table tr.clickable-row.row-selected {
  background: #e8f2ff;
}

.nit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-top: 0.65rem;
}

.nit-row label {
  margin-top: 0;
}

.nit-field {
  flex: 1 1 200px;
  min-width: 0;
}

.nit-field--dv {
  flex: 0 0 3.75rem;
  width: 3.75rem;
  max-width: 4.25rem;
}

.nit-field--dv input {
  text-align: center;
}

.nit-actions {
  flex: 0 0 auto;
  align-self: flex-end;
  padding-bottom: 1px;
}

.nit-actions .btn-secondary {
  width: auto;
  white-space: nowrap;
  padding: 0.52rem 0.95rem;
  min-height: 0;
  font-size: 0.92rem;
}

#admin-create-block label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
  margin-top: 0.65rem;
}

#admin-create-block label:first-of-type,
#admin-create-block .check-row {
  margin-top: 0;
}

#admin-create-block input,
#admin-create-block select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fafbfd;
}

#admin-create-block .btn-primary {
  margin-top: 1rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.85rem 0 0.25rem;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
}

.check-row input {
  width: auto !important;
  margin: 0;
}

/* ——— App shell (post-login) ——— */
.app-shell {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

.sidebar {
  flex: 0 0 238px;
  width: 238px;
  min-width: 0;
  max-width: 238px;
  overflow: hidden;
  background: linear-gradient(180deg, #0a2342 0%, #0c2d52 100%);
  color: #e8f0fc;
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  padding: 0.35rem 0.5rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 0.75rem;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
}

.sidebar-brand strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
}

.sidebar-sub {
  font-size: 0.72rem;
  opacity: 0.85;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #dce8f7;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* :hover “pegado” en táctil puede dejar un ítem (p. ej. Tickets) pareciendo activo */
@media (hover: hover) and (pointer: fine) {
  .sidebar .nav-item:hover:not(.nav-current) {
    background: rgba(255, 255, 255, 0.08);
  }
}

/* Evita que :focus del clic anterior parezca un segundo ítem “seleccionado” */
.sidebar .nav-item:focus {
  outline: none;
}

.sidebar .nav-item:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 2px;
}

.sidebar .nav-item.nav-current:focus-visible {
  outline-color: rgba(255, 255, 255, 0.55);
}

.sidebar .nav-item.nav-current {
  background: rgba(11, 107, 203, 0.45);
  color: #fff;
}

.nav-item--soon {
  cursor: default;
  opacity: 0.55;
  font-weight: 500;
}

.nav-item--soon small {
  font-weight: 400;
  opacity: 0.9;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 0.85rem;
  margin-top: auto;
  min-width: 0;
  flex-shrink: 0;
}

.btn-sidebar-out {
  width: 100%;
  margin-bottom: 0.45rem;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
}

.btn-sidebar-out:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-sidebar-link {
  display: block;
  text-align: center;
  font-size: 0.78rem;
  color: #9ec9ff;
  margin-top: 0.25rem;
}

.main-content {
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  padding: 1.1rem 1.25rem 2rem;
  overflow-x: hidden;
  overflow-y: auto;
}

.main-view {
  max-width: 720px;
}

.main-view--wide {
  max-width: 960px;
}

.main-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(26, 35, 50, 0.06);
  padding: 1.25rem 1.35rem;
}

.main-card--spaced {
  margin-top: 1rem;
}

.main-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
}

.main-title--sub {
  font-size: 1.1rem;
}

.main-lead {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
}

.placeholder-box {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 2rem 1.25rem;
  text-align: center;
  background: #fafbfd;
}

.placeholder-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 0.65rem;
  left: 0.65rem;
  z-index: 40;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 40, 0.45);
  z-index: 25;
}

.sidebar-backdrop:not(.hidden) {
  display: block;
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: min(280px, 88vw);
    min-width: 0;
    max-width: none;
    flex: none;
  }

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

  .main-content {
    padding-top: 3.25rem;
  }
}

.hr-fieldset {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafbfd;
}

.hr-fieldset legend {
  padding: 0 0.35rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

#create-user-form label,
#client-form label,
#supplier-form label,
#product-form label,
#user-hr-form label,
.client-site-form label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
  margin-top: 0.65rem;
}

#create-user-form label:first-of-type,
#create-user-form .check-row,
#client-form label:first-of-type,
#supplier-form label:first-of-type,
#product-form label:first-of-type,
#supplier-form .check-row,
#user-hr-form label:first-of-type,
.client-site-form label:first-of-type {
  margin-top: 0;
}

.hr-fieldset label:first-of-type {
  margin-top: 0.5rem;
}

#create-user-form input,
#create-user-form select,
#create-user-form textarea,
#user-hr-form input,
#user-hr-form select,
#user-hr-form textarea,
#client-form input:not([type="file"]),
#client-form select,
#supplier-form input:not([type="file"]):not([type="checkbox"]),
#supplier-form select,
#product-form input,
.client-site-form input:not([type="checkbox"]),
.client-site-form select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fafbfd;
}

#client-form input[type="file"] {
  width: 100%;
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

#create-user-form .btn-primary,
#client-form .btn-primary,
#supplier-form .btn-primary,
#product-form .btn-primary,
#user-hr-form .btn-primary {
  margin-top: 1rem;
  width: auto;
  min-width: 200px;
}

#supplier-form .btn-secondary,
#product-form .btn-secondary {
  margin-top: 1rem;
  width: auto;
  min-width: 7.5rem;
}

.client-site-form .btn-secondary {
  margin-top: 1rem;
  width: auto;
}

#user-hr-form textarea {
  resize: vertical;
  min-height: 2.5rem;
  line-height: 1.4;
}

.user-hr-self-password {
  margin: 1.15rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--border);
}

.user-hr-self-password-title {
  font-size: 1.02rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  color: var(--text);
}

.user-hr-self-password-hint {
  font-size: 0.86rem;
  color: var(--muted);
  margin: 0 0 0.9rem;
  line-height: 1.45;
}

#user-hr-form #btn-user-hr-change-password {
  margin-top: 0.75rem;
  width: auto;
  min-width: 12rem;
}

.ticket-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.65rem 1rem;
  align-items: end;
  margin: 1rem 0 1.25rem;
}

.ticket-filters label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.ticket-filters select,
.ticket-filters .btn-secondary {
  width: 100%;
  min-height: 2.35rem;
}

#ticket-form input:not([type="checkbox"]),
#ticket-form select,
#ticket-form textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fafbfd;
}

#ticket-form input[type="datetime-local"],
#ticket-form input[type="date"],
#ticket-form input[type="time"] {
  line-height: normal;
  padding-top: 0.42rem;
  padding-bottom: 0.42rem;
  min-height: 2.75rem;
}

#ticket-form textarea.textarea-autogrow,
.crm-form textarea.textarea-autogrow {
  overflow: hidden;
  resize: none;
  max-height: none;
  min-height: 2.75rem;
  field-sizing: content;
}

#ticket-form .btn-primary,
#ticket-form .btn-secondary {
  margin-top: 1rem;
  margin-right: 0.5rem;
  width: auto;
  min-width: 160px;
}

#ticket-technician-ids {
  min-height: 7rem;
}

.ticket-install-preview {
  font-size: 0.9rem;
  color: var(--text);
  background: #f4f7fb;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
}

.ticket-install-preview ul {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
}

/* El enhancer CRM envuelve este bloque en .crm-form-grid (3 columnas); forzar 1 columna */
#ticket-quote-po-card > .crm-form-grid {
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
}

#ticket-quote-po-card > .crm-form-grid > .main-title,
#ticket-quote-po-card > .crm-form-grid > .ticket-install-preview,
#ticket-quote-po-card > .crm-form-grid > .ticket-po-equipment-list,
#ticket-quote-po-card > .crm-form-grid > .ticket-po-actions,
#ticket-quote-po-card > .crm-form-grid > .crm-field,
#ticket-quote-po-card > .crm-form-grid > .msg {
  grid-column: 1 / -1;
  width: 100%;
}

#ticket-po-sign-panel > .crm-form-grid {
  grid-template-columns: minmax(0, 1fr);
}

.ticket-po-equipment-list {
  margin: 0.75rem 0 0;
  width: 100%;
  min-width: 0;
}

.ticket-po-equipment-table {
  width: 100%;
  margin-bottom: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfd;
  overflow: visible;
}

.users-table.ticket-po-items-table {
  width: 100%;
  table-layout: fixed;
  font-size: 0.88rem;
}

.users-table.ticket-po-items-table th,
.users-table.ticket-po-items-table td {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  max-width: none;
  word-break: break-word;
  overflow-wrap: anywhere;
  vertical-align: middle;
}

.users-table.ticket-po-items-table th:nth-child(1),
.users-table.ticket-po-items-table td:nth-child(1) {
  width: 2.25rem;
}

.users-table.ticket-po-items-table th:nth-child(2),
.users-table.ticket-po-items-table td:nth-child(2) {
  width: 46%;
}

.users-table.ticket-po-items-table th:nth-child(3),
.users-table.ticket-po-items-table td:nth-child(3) {
  width: 11%;
}

.users-table.ticket-po-items-table th:nth-child(4),
.users-table.ticket-po-items-table td:nth-child(4) {
  width: 20%;
}

.users-table.ticket-po-items-table th:nth-child(5),
.users-table.ticket-po-items-table td:nth-child(5) {
  width: 14%;
}

.users-table.ticket-po-items-table .ticket-po-qty,
.users-table.ticket-po-items-table .ticket-po-unit {
  width: 100%;
  max-width: 100%;
  min-height: 2.1rem;
  box-sizing: border-box;
}

.ticket-po-extra-block {
  margin-top: 0.65rem;
  padding: 0.65rem 0.75rem;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
}

.ticket-po-extra-lines {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ticket-po-extra-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) 5.5rem 6.5rem auto;
  gap: 0.45rem;
  align-items: end;
}

.ticket-po-extra-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.ticket-po-extra-field > span {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.ticket-po-extra-field input {
  width: 100%;
  min-height: 2.1rem;
  box-sizing: border-box;
}

.ticket-po-extra-remove {
  align-self: end;
  white-space: nowrap;
  font-size: 0.78rem;
  padding: 0.35rem 0.55rem;
}

@media (max-width: 900px) {
  .ticket-po-extra-row {
    grid-template-columns: 1fr 1fr;
  }
  .ticket-po-extra-remove {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

.ticket-work-site-body {
  padding: 0.55rem 0.65rem;
  background: #f0f7ff;
  border: 1px solid #bcdcff;
  border-radius: 8px;
}

.ticket-work-site-line {
  margin: 0.15rem 0;
  font-size: 0.9rem;
}

.ticket-work-site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.vr-cl-email-wide {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.vr-inst-scope-area {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-family: inherit;
  line-height: 1.45;
}

.vr-maps-links a {
  font-weight: 600;
}

.ticket-po-row-covered {
  background: #f8fafc;
}

.ticket-po-covered-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 0.82rem;
  font-weight: 700;
}

.ticket-po-covered-assign {
  font-size: 0.84rem;
  color: var(--muted);
}

.ticket-po-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  clear: both;
  margin-top: 0.75rem;
  gap: 0.5rem;
}

#ticket-quote-po-card #btn-ticket-create-po {
  width: auto;
  min-width: 220px;
  max-width: 100%;
  display: block;
  align-self: flex-end;
  margin-top: 0.25rem;
  margin-left: auto;
}

.ticket-po-totals {
  display: block;
  clear: both;
  font-size: 0.88rem;
  color: var(--text);
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
}

.ticket-po-existing-table {
  width: 100%;
  font-size: 0.86rem;
  border-collapse: collapse;
}

.ticket-po-existing-table th,
.ticket-po-existing-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.ticket-po-existing-table th {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.ticket-po-status-pill {
  display: inline-block;
  font-size: 0.76rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-weight: 600;
}

.ticket-po-status-pill.is-pending {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.ticket-po-status-pill.is-signed {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.po-source-context {
  font-size: 0.88rem;
  color: var(--text);
  background: #f0f7ff;
  border: 1px solid #bcdcff;
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  margin: 0 0 0.85rem;
}

.po-source-context dl {
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0;
}

.po-source-context dt {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.po-source-context dd {
  margin: 0;
  font-weight: 600;
}

.po-sign-panel {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.85rem;
}

.policy-doc-wrap .policy-doc {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

.policy-doc__title {
  font-size: 1.35rem;
  margin: 0 0 0.35rem;
}

.policy-doc__company {
  margin: 0 0 1rem;
  font-size: 1.05rem;
}

.policy-doc__h {
  font-size: 1.05rem;
  margin: 1.15rem 0 0.4rem;
  color: var(--bg-top);
}

.policy-doc p {
  margin: 0.35rem 0;
}

.policy-doc ul {
  margin: 0.35rem 0 0.5rem;
  padding-left: 1.25rem;
}

.policy-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

#habeas-print-area .inline-field {
  display: inline-block;
  min-width: 8rem;
  max-width: 100%;
  padding: 0.2rem 0.35rem;
  margin: 0 0.15rem;
  border: none;
  border-bottom: 1px solid var(--text);
  background: transparent;
  font: inherit;
  color: inherit;
}

.habeas-signature-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  display: inline-block;
  max-width: 100%;
  overflow: auto;
  margin: 0.35rem 0 0.5rem;
}

#habeas-signature-pad {
  display: block;
  vertical-align: top;
  cursor: crosshair;
  touch-action: none;
}

.habeas-sig-thumb {
  display: block;
  border-radius: 4px;
}

/* Membrete (pantalla + impresión política / autorización) */
.habeas-print-sheet {
  max-width: 210mm;
  margin-left: auto;
  margin-right: auto;
}

.habeas-membrete-header {
  margin: 0 0 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 2px solid #0a2342;
}

.habeas-membrete-docx-banner {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: contain;
  object-position: center top;
  margin: 0 auto;
}

.habeas-membrete-docx-banner--missing {
  display: none !important;
}

.habeas-membrete-fallback-block {
  margin-bottom: 0.5rem;
}

.habeas-membrete-brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.habeas-membrete-logo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: linear-gradient(145deg, #0a2342, #135099);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.04em;
  flex-shrink: 0;
}

.habeas-membrete-headtext {
  flex: 1;
  min-width: 12rem;
}

.habeas-membrete-name {
  display: block;
  font-size: 1.15rem;
  color: #0a2342;
  letter-spacing: -0.02em;
}

.habeas-membrete-line {
  margin: 0.2rem 0 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.habeas-membrete-address {
  margin: 0;
  font-size: 0.82rem;
  font-style: normal;
  color: var(--text);
  line-height: 1.45;
}

.habeas-membrete-doc-title {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.habeas-membrete-footer {
  margin-top: 1.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.habeas-membrete-footer p {
  margin: 0;
}

.habeas-membrete-footer-pageline {
  display: none;
  font-size: 0.8rem;
  color: var(--text);
  margin-bottom: 0.35rem !important;
}

.habeas-membrete-footer-contact {
  font-size: 0.8rem;
  color: var(--text);
  margin-bottom: 0.35rem !important;
}

.habeas-membrete-footer-note {
  font-size: 0.75rem;
  color: var(--muted);
}

@media print {
  @page {
    size: A4;
    margin: 14mm 16mm 18mm 16mm;
  }

  .no-print,
  #btn-menu,
  #sidebar-backdrop,
  #sidebar {
    display: none !important;
  }

  body.app-mode {
    background: #fff;
  }

  #app-shell {
    display: block;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }

  .main-view {
    padding: 0 !important;
  }

  .main-card {
    box-shadow: none !important;
  }

  #view-habeas-data {
    max-width: none !important;
  }

  #view-habeas-data .habeas-print-sheet {
    max-width: none;
    margin: 0;
    padding: 0;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }

  .habeas-membrete-docx-banner {
    max-height: 220px;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .habeas-membrete-footer-pageline {
    display: block;
  }

  .habeas-membrete-page-num::after {
    content: counter(page);
  }

  .habeas-membrete-header {
    border-bottom-color: #0a2342;
    break-inside: avoid;
    page-break-after: avoid;
  }

  .habeas-membrete-footer {
    break-inside: avoid;
    page-break-before: avoid;
  }

  .policy-doc__h {
    break-after: avoid;
  }

  .habeas-signature-wrap {
    break-inside: avoid;
  }

  #habeas-print-area .inline-field {
    border-bottom-color: #000;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

/* — Cotizaciones: descripción general — */
#quote-description {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 6.5rem;
  max-height: 22rem;
  resize: vertical;
  line-height: 1.45;
}

/* — Cotizaciones: filas de equipo/servicio — */
.quote-lines-block {
  margin-top: 1rem;
}

.quote-lines-block--in-proposal {
  margin-top: 0.5rem;
  padding-top: 0.35rem;
}

.quote-proposal-section-title {
  margin: 1.15rem 0 0.4rem;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.quote-proposal-tip {
  margin: 0.35rem 0 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

#quote-lines-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.quote-line-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  background: #f8fafc;
  display: grid;
  gap: 0.55rem;
}

.quote-line-supply-block {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.quote-line-supply-lbl {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted-fg, #475569);
  margin: 0;
}

.quote-line-supply-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.quote-line-supply-search {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.quote-line-supply-clear {
  flex: 0 0 auto;
  min-height: auto;
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
}

.quote-line-supply-dd {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: 100%;
  margin: 0.15rem 0 0;
  padding: 0.2rem 0;
  list-style: none;
  max-height: 14rem;
  overflow-y: auto;
  background: var(--card, #fff);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.quote-line-supply-dd-item {
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  font-size: 0.88rem;
  line-height: 1.35;
}

.quote-line-supply-dd-item:hover,
.quote-line-supply-dd-item:focus {
  background: #e0f2fe;
  outline: none;
}

.quote-line-supply-dd-msg {
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
  color: var(--muted-fg, #64748b);
  margin: 0;
  list-style: none;
}

.quote-line-supply-dd-msg--sub {
  padding-top: 0;
  padding-bottom: 0.55rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text);
}

.quote-line-supply-dd-msg--sub strong {
  font-weight: 700;
}

.quote-line-qty-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.quote-line-qty-lbl {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted-fg, #475569);
  margin: 0;
}

.quote-line-qty {
  width: 6.5rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.quote-line-price-override-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.15rem;
}

.quote-line-price-override {
  width: 100%;
  max-width: 16rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.quote-line-check {
  margin: 0;
}

/* Fila de botones cotización: evita apilar al 100% de ancho como en login */
#quote-form .quote-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin-top: 1.25rem;
}

#quote-form .quote-form-actions .btn-primary,
#quote-form .quote-form-actions .btn-secondary {
  width: auto;
  flex: 1 1 9.5rem;
  margin-top: 0;
  max-width: 100%;
}

#quote-form .quote-proposal-card label {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

#quote-form .quote-proposal-card .check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  width: 100%;
}

#quote-form .quote-proposal-card input[type="text"],
#quote-form .quote-proposal-card input[type="number"],
#quote-form .quote-proposal-card textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

#quote-form textarea.textarea-plain {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 0 !important;
  resize: none !important;
  min-height: 0 !important;
  line-height: 1.5;
  color: inherit;
}

#quote-form textarea.textarea-plain:focus {
  outline: 2px solid rgba(11, 107, 203, 0.18) !important;
  outline-offset: 4px;
}

#quote-form .cc-editor {
  margin-top: 0.25rem;
  max-width: 64rem;
}

#quote-form .cc-title {
  margin: 0 0 0.45rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

#quote-form .cc-line {
  margin: 0.22rem 0;
  line-height: 1.5;
}

#quote-form .cc-help {
  margin: 0.15rem 0 0.55rem;
  font-size: 0.86rem;
  color: var(--muted, #64748b);
  line-height: 1.45;
}

#quote-form .cc-field {
  font: inherit;
  color: inherit;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  padding: 0 0.15rem 0.08rem;
  outline: none;
  border-radius: 0;
}

#quote-form .cc-field:focus {
  border-bottom-color: var(--primary);
}

#quote-form input.cc-field {
  display: inline-block;
  vertical-align: baseline;
}

#quote-form .cc-field--short {
  width: 4.5rem;
}

#quote-form .cc-field--mid {
  width: 15rem;
}

#quote-form .cc-field--long {
  width: 22rem;
  max-width: 100%;
}

#quote-form textarea.cc-field--block {
  width: 100%;
  box-sizing: border-box;
  min-height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  background: #fff;
  resize: vertical;
}

#quote-form textarea.cc-field--block:focus {
  outline: 2px solid rgba(11, 107, 203, 0.18);
  outline-offset: 2px;
}

#quote-form .quote-proposal-card .quote-proposal-svc-checks {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.92rem;
  margin: 0.35rem 0 0;
}

.quote-line-refs-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

@media (max-width: 720px) {
  .quote-line-refs-two {
    grid-template-columns: 1fr;
  }
}

.quote-line-ref {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.quote-line-ref-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted-fg, #475569);
  margin: 0;
}

.quote-line-ref-label .req-star {
  color: #b91c1c;
  font-weight: 700;
}

.quote-line-text {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.quote-line-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: flex-start;
}

.quote-line-thumb {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.35rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.quote-line-thumb-img {
  max-width: 120px;
  max-height: 90px;
  object-fit: cover;
  border-radius: 4px;
}

.quote-line-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.quote-line-filelbl {
  cursor: pointer;
  margin: 0;
  position: relative;
}

.quote-line-filelbl input.hidden {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.quote-line-image-input:disabled {
  cursor: not-allowed;
}

/* — Órdenes de compra — */
.po-readonly-summary {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem 0.9rem;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.92rem;
}

.po-readonly-summary dl {
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.po-readonly-summary dt {
  font-weight: 600;
  color: var(--muted);
}

.po-readonly-summary dd {
  margin: 0;
}

.po-quote-lookup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.po-quote-lookup-row input[type="text"] {
  flex: 1 1 200px;
  min-width: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fafbfd;
}

.po-quote-lookup-row .btn-secondary {
  width: auto;
  white-space: nowrap;
}

.po-lines-table-wrap {
  margin: 0.35rem 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfd;
  overflow: visible;
  max-width: 100%;
}

.po-lines-table {
  font-size: 0.88rem;
  table-layout: fixed;
  width: 100%;
}

.users-table.po-lines-table th,
.users-table.po-lines-table td {
  vertical-align: middle;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  max-width: none;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.users-table.po-lines-table th:nth-child(1),
.users-table.po-lines-table td:nth-child(1) {
  width: 36%;
}

.users-table.po-lines-table th:nth-child(2),
.users-table.po-lines-table td:nth-child(2) {
  width: 24%;
}

.users-table.po-lines-table th:nth-child(3),
.users-table.po-lines-table td:nth-child(3) {
  width: 12%;
}

.users-table.po-lines-table th:nth-child(4),
.users-table.po-lines-table td:nth-child(4) {
  width: 18%;
}

.users-table.po-lines-table th:nth-child(5),
.users-table.po-lines-table td:nth-child(5) {
  width: 10%;
}

.po-line-equip-cell .po-line-equip-label {
  display: block;
  font-weight: 600;
  line-height: 1.35;
  white-space: normal;
}

.po-lines-table select,
.po-lines-table input[type="number"],
.po-lines-table input[type="text"]:not([readonly]) {
  width: 100%;
  min-height: 2.1rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.25rem 0.4rem;
}

.po-lines-table input[readonly] {
  border: none;
  background: transparent;
  padding: 0;
  min-height: auto;
  color: var(--muted);
  font-size: 0.84rem;
}

.po-line-actions {
  white-space: nowrap;
  text-align: right;
}

.po-line-remove {
  min-height: 2.1rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.82rem;
}

.po-serial-line {
  margin-bottom: 0.65rem;
}

.po-serial-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.po-serial-hint {
  color: var(--muted-fg, #64748b);
  font-weight: 400;
  font-size: 0.82rem;
}

.po-order-item-serial {
  width: 100%;
  min-height: 2.25rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.25rem 0.4rem;
}

.po-pay-proof-lbl {
  cursor: pointer;
  margin: 0.35rem 0 0;
  position: relative;
  display: inline-block;
}

.po-pay-proof-lbl input.hidden {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.supplier-rut-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.supplier-rut-filelbl {
  cursor: pointer;
  margin: 0;
  position: relative;
}

#supplier-form label.supplier-rut-filelbl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  width: auto;
  min-width: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.supplier-rut-filelbl input.hidden {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

#supplier-rut-input:disabled {
  cursor: not-allowed;
}

/* Cotización: asignación múltiple de visita */
#view-quotes .quote-visit-assignees {
  width: 100%;
  max-width: 28rem;
  min-height: 6.5rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
}

/* --- Acordeón / paneles colapsables --- */
.accordion {
  overflow: hidden;
}

.accordion__header {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  width: auto;
  margin: 1rem;
  padding: 0.6rem 1.05rem;
  border: 1px solid var(--border, #d8dee9);
  background: #f0f3f8;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text, #0f172a);
  border-radius: 10px;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.accordion__header:hover {
  background: #e5eaf2;
}

.accordion.is-open .accordion__header {
  background: #e9eff8;
  border-color: var(--primary, #0f4c97);
  color: var(--primary, #0f4c97);
}

.accordion__header:focus-visible {
  outline: 2px solid var(--primary, #0f4c97);
  outline-offset: 2px;
}

.accordion__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: inherit;
}

.accordion__icon {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  opacity: 0.7;
  transform: rotate(-45deg);
  transition: transform 0.3s ease;
}

.accordion.is-open .accordion__icon {
  transform: rotate(45deg);
}

/* Colapsado = solo el botón visible (display:none garantiza ocultar todo) */
.accordion__body {
  display: none;
}

.accordion.is-open .accordion__body {
  display: block;
  animation: accordionFade 0.25s ease;
}

.accordion__inner {
  padding: 0 1rem 1rem;
}

@keyframes accordionFade {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .accordion.is-open .accordion__body {
    animation: none;
  }
  .accordion__icon {
    transition: none;
  }
}

.client-portal-box {
  border: 1px solid #d6dbe3;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-top: 0.5rem;
}

.client-portal-box legend {
  font-weight: 700;
  color: #0f4c97;
  padding: 0 0.4rem;
}

.client-portal-status {
  font-size: 0.82rem;
  font-weight: 600;
  color: #b42318;
  margin: 0 0 0.5rem;
}

.client-portal-status.is-on {
  color: #067647;
}

.client-portal-reveal {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.7rem;
  background: #eef4fc;
  border: 1px solid #cfe0f5;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #0f4c97;
  word-break: break-all;
}

/* Prioridad de tickets: color por nivel */
.prio-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.4;
  border: 1px solid transparent;
  white-space: nowrap;
}
.prio-badge.prio-low {
  background: #eef2f6;
  color: #475569;
  border-color: #d8e0ea;
}
.prio-badge.prio-normal {
  background: #e7f0fe;
  color: #1d4ed8;
  border-color: #c7dbfb;
}
.prio-badge.prio-high {
  background: #fff3e0;
  color: #b45309;
  border-color: #fbdba7;
}
.prio-badge.prio-urgent {
  background: #ffe9df;
  color: #c2410c;
  border-color: #fbc5ad;
}
.prio-badge.prio-critical {
  background: #fde2e1;
  color: #b91c1c;
  border-color: #f6b7b4;
}
.prio-badge.prio-emergency {
  background: #b91c1c;
  color: #fff;
  border-color: #991b1b;
  animation: prio-pulse 1.6s ease-in-out infinite;
}
@keyframes prio-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.5); }
  50% { box-shadow: 0 0 0 4px rgba(185, 28, 28, 0); }
}

.portal-tag {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0.02rem 0.4rem;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  vertical-align: middle;
}

/* --- Plantillas documentales --- */
.doc-tpl-wrap {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  margin-top: 0.75rem;
}
@media (min-width: 1100px) {
  .doc-tpl-wrap {
    grid-template-columns: 1fr 1fr;
  }
}
.doc-tpl-card {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.doc-tpl-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 0.6rem;
  margin-bottom: 0.7rem;
}
.doc-tpl-card__title {
  font-size: 1.02rem;
  margin: 0;
  color: #1e293b;
}
.doc-tpl-name {
  font-size: 0.82rem;
  color: #64748b;
}
.doc-tpl-badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}
.doc-tpl-badge--ok {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}
.doc-tpl-badge--warn {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}
.doc-tpl-card__seq,
.doc-tpl-card__upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.7rem;
  font-size: 0.85rem;
}
.doc-tpl-card__seq label {
  display: inline-flex;
  flex-direction: column;
  font-size: 0.72rem;
  color: #475569;
  gap: 0.15rem;
}
.doc-seq-yearly-lbl {
  flex-direction: row !important;
  align-items: center;
  gap: 0.3rem !important;
  font-size: 0.8rem !important;
}
.doc-tpl-next {
  background: #eef2ff;
  color: #3730a3;
  border-radius: 8px;
  padding: 0.15rem 0.55rem;
  font-weight: 600;
}
.doc-tpl-vars {
  margin-top: 0.4rem;
  font-size: 0.8rem;
}
.doc-tpl-vars summary {
  cursor: pointer;
  color: #2563eb;
}
.doc-tpl-vars-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.5rem;
}
.doc-tpl-var {
  background: #f1f5f9;
  border-radius: 6px;
  padding: 0.05rem 0.35rem;
  font-size: 0.74rem;
  color: #334155;
}

/* ===== Asistente de cierre de servicio ===== */
.closure-assistant {
  margin-top: 1rem;
  display: grid;
  gap: 0.85rem;
}
.closure-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.6rem;
}
.closure-kpi {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.7rem;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.closure-kpi-ico {
  font-size: 1.25rem;
  line-height: 1;
}
.closure-kpi-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748b;
}
.closure-kpi-val {
  font-size: 0.98rem;
  color: #0f172a;
  word-break: break-word;
}
.closure-check-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.closure-pill {
  font-size: 0.74rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.12rem 0.6rem;
}
.closure-pill--ok {
  background: #dcfce7;
  color: #15803d;
}
.closure-pill--warn {
  background: #fef9c3;
  color: #a16207;
}
.closure-check-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.35rem;
}
.closure-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
  font-size: 0.88rem;
  border: 1px solid #e2e8f0;
}
.closure-check.is-ok {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}
.closure-check.is-missing {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}
.closure-check-ico {
  font-weight: 700;
}
.closure-banner {
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
}
.closure-banner--warn {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}
.closure-banner--ok {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}
.closure-banner--info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}
.closure-approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.closure-actions .btn-primary {
  font-weight: 600;
}
.closure-actions .btn-primary.btn-disabled,
.closure-actions .btn-primary[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: auto;
}

/* Calificación por estrellas */
.star-rating {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin: 0.2rem 0 0.4rem;
}
.star-rating-star {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
  color: #cbd5e1;
  padding: 0 0.05rem;
  transition: color 0.12s ease, transform 0.12s ease;
}
.star-rating-star:hover:not(:disabled) {
  transform: scale(1.12);
}
.star-rating-star.is-on {
  color: #f59e0b;
}
.star-rating-star:disabled {
  cursor: default;
}
.star-rating-clear {
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.78rem;
  cursor: pointer;
  margin-left: 0.4rem;
  text-decoration: underline;
}

/* Modal de vista previa */
.vr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.vr-modal {
  background: #fff;
  border-radius: 16px;
  width: min(900px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
}
.vr-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}
.vr-modal-body {
  padding: 1rem;
  overflow: auto;
  display: grid;
  gap: 0.85rem;
}
.vr-preview-block h4 {
  margin: 0 0 0.25rem;
  font-size: 0.92rem;
  color: #0f172a;
}
.vr-preview-block p {
  margin: 0;
  font-size: 0.9rem;
  color: #334155;
}
.vr-preview-frame {
  width: 100%;
  height: 60vh;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

/* Indicadores de aprobación/facturación en dashboard */
.dash-kpi-card--warn {
  border-left: 4px solid #f59e0b;
}
.dash-kpi-card--ok {
  border-left: 4px solid #22c55e;
}
.dash-kpi-card--danger {
  border-left: 4px solid #ef4444;
}
.dash-kpi-card--info {
  border-left: 4px solid #3b82f6;
}
.dash-alert-card {
  margin: 0.75rem 0;
  padding: 1rem 1.1rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
}
.dash-pending-sign-list {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}
.dash-pending-sign-list .link-btn {
  background: none;
  border: none;
  color: #1d4ed8;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font: inherit;
}

.vr-field-locked {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #475569 !important;
  cursor: not-allowed;
}
.vr-ph-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
@media (min-width: 900px) {
  .vr-ph-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.vr-ph-cell {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 0.4rem;
}
.vr-ph-label {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 0.25rem;
  font-weight: 600;
  color: #64748b;
}
.vr-ph-thumb {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: contain;
  object-position: center top;
  display: block;
  margin: 0.25rem 0;
}
.vr-ph-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.25rem;
}

@media (max-width: 640px) {
  .closure-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .closure-actions button {
    width: 100%;
  }
  .vr-preview-frame {
    height: 50vh;
  }
}
