:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --line: #dbe3ee;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --sidebar: #0f172a;
  --sidebar-text: #e2e8f0;
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 76px;
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

.app-shell {
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 18px 14px;
  z-index: 1000;
  transition: width 0.22s ease, transform 0.22s ease;
  overflow-x: hidden;
  overflow-y: auto;
}

.sidebar-backdrop {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 22px;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex: 0 0 auto;
}

.brand-text {
  min-width: 0;
}

.brand h2 {
  margin: 0;
  font-size: 16px;
  color: #fff;
  white-space: nowrap;
}

.brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
}

.sidebar-toggle {
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.45);
  color: #fff;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 14px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle:hover {
  background: rgba(30, 41, 59, 0.82);
  border-color: rgba(191, 219, 254, 0.35);
}

.sidebar-toggle-mobile {
  display: none;
}

.sidebar-toggle-icon {
  line-height: 1;
}

.sidebar-toggle-closed {
  display: none;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu a {
  color: var(--sidebar-text);
  padding: 11px 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  transition: background 0.18s ease, color 0.18s ease;
}

.menu a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.menu a.active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-weight: 600;
}

.menu-group {
  display: grid;
  gap: 6px;
}

.menu-group-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  padding: 11px 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  font: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease;
}

.menu-group-toggle:hover,
.menu-group.is-open .menu-group-toggle,
.menu-group.is-active .menu-group-toggle {
  background: rgba(255, 255, 255, 0.08);
}

.menu-group-main {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.menu-group-caret {
  transition: transform 0.18s ease;
  font-size: 12px;
  color: #94a3b8;
}

.menu-group.is-open .menu-group-caret {
  transform: rotate(90deg);
}

.menu-group-items {
  display: none;
  margin-left: 12px;
  padding-left: 10px;
  border-left: 1px solid rgba(148, 163, 184, 0.18);
}

.menu-group.is-open .menu-group-items,
.menu-group.is-active .menu-group-items {
  display: grid;
  gap: 6px;
}

.menu-icon {
  width: 20px;
  text-align: center;
  flex: 0 0 20px;
}

.menu-text {
  white-space: nowrap;
}

/* Content */
.content {
  margin-left: var(--sidebar-width);
  padding: 24px;
  transition: margin-left 0.22s ease;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

.topbar-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-user {
  white-space: nowrap;
}

.profile-menu {
  position: relative;
}

.profile-menu-toggle {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 8px 12px;
  box-shadow: var(--shadow-soft);
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.profile-menu-toggle:hover {
  background: #f8fafc;
}

.profile-avatar {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(180deg, #1d4ed8 0%, #1e40af 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex: 0 0 auto;
}

.profile-meta {
  display: grid;
  text-align: left;
  gap: 2px;
}

.profile-caret {
  color: var(--muted);
  font-size: 11px;
}

.profile-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  padding: 8px;
  z-index: 60;
}

.profile-menu-header {
  display: grid;
  gap: 4px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid #eef2f7;
  margin-bottom: 6px;
}

.profile-menu-header span {
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

.profile-menu-link {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
}

.profile-menu-link:hover {
  background: #f8fafc;
}

.profile-menu-form {
  margin: 0;
}

.profile-menu-logout {
  color: #b42318;
}

/* Collapsed sidebar */
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .content {
  margin-left: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .menu-text {
  display: none;
}

body.sidebar-collapsed .brand {
  justify-content: center;
}

body.sidebar-collapsed .brand-left {
  justify-content: center;
}

body.sidebar-collapsed .menu a {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

body.sidebar-collapsed .menu-icon {
  width: auto;
  flex: 0 0 auto;
}

body.sidebar-collapsed .sidebar-toggle-open {
  display: none;
}

body.sidebar-collapsed .sidebar-toggle-closed {
  display: inline;
}

body.sidebar-collapsed .menu-group-toggle {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

body.sidebar-collapsed .menu-group-caret,
body.sidebar-collapsed .menu-group-items {
  display: none !important;
}

body.sidebar-collapsed .profile-meta {
  display: none;
}

/* Generic UI */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-soft);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-header h3 {
  margin: 0;
}

.filter-card {
  padding: 0;
  overflow: visible;
}

.filter-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
}

.filter-card-title {
  min-width: 0;
}

.filter-card-title h3 {
  margin: 0;
  font-size: 17px;
}

.filter-toggle {
  border: 1px solid #cfd8e3;
  background: #fff;
  color: #334155;
  border-radius: 10px;
  min-height: 36px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.filter-toggle:hover {
  background: #f8fafc;
  border-color: #b9c7d8;
  transform: translateY(-1px);
}

.filter-toggle-icon {
  color: var(--muted);
  font-size: 12px;
  transition: transform 0.18s ease;
}

.filter-card.is-open .filter-toggle-icon {
  transform: rotate(90deg);
}

.filter-card-body {
  padding: 18px;
  border-top: 1px solid #eef2f7;
}

.filter-card:not(.is-open) .filter-card-body {
  display: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.stat-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.table th {
  font-size: 13px;
  color: var(--muted);
  background: #f8fafc;
}

.table tbody tr:nth-child(odd) {
  background: #ffffff;
}

.table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.table tbody tr:hover {
  background: #eef4ff;
}

.table-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 16px;
  margin-top: 4px;
  border-top: 1px solid #eef2f7;
  flex-wrap: wrap;
}

.table-pager-left,
.table-pager-controls,
.table-pager-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table-pager-summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.table-pager-size {
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}

.table-pager-size select {
  width: auto;
  min-width: 72px;
  height: 36px;
  padding: 6px 28px 6px 10px;
  border-radius: 10px;
  background-color: #fff;
}

.table-pager-btn {
  min-width: 36px;
  height: 36px;
  border: 1px solid #d7e0ea;
  border-radius: 10px;
  background: #fff;
  color: #334155;
  padding: 0 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

.table-pager-btn:hover:not(:disabled) {
  background: #eef4ff;
  border-color: #bfdbfe;
  color: var(--primary);
  transform: translateY(-1px);
}

.table-pager-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.table-pager-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.table-pager-gap {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 0 2px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  min-height: 36px;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.16);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.18);
}

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

.btn-secondary {
  background: #eef2f7;
  color: #0f172a;
  border-color: #d7e0ea;
}

.btn-secondary:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.btn-outline {
  background: #fff;
  color: #334155;
  border-color: #cfd8e3;
}

.btn-outline:hover {
  background: #f8fafc;
  border-color: #b9c7d8;
}

.btn-danger {
  background: #fff1f2;
  color: #b42318;
  border-color: #f8c9cf;
}

.btn-danger:hover {
  background: #ffe4e6;
  border-color: #fda4af;
}

.btn-sm {
  padding: 6px 10px;
  min-height: 32px;
  font-size: 12px;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inline-form {
  display: inline-flex;
  margin: 0;
  align-items: center;
}

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

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

.form-group {
  display: grid;
  gap: 6px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8fafc;
}

.checkbox-grid label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  color: #334155;
}

.checkbox-grid input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font: inherit;
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.flash-success {
  background: #dcfce7;
  color: #166534;
}

.flash-danger {
  background: #fee2e2;
  color: #991b1b;
}

.flash-warning {
  background: #fef3c7;
  color: #92400e;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.info-grid > div {
  min-height: 78px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
  color: #0f172a;
  line-height: 1.5;
}

.info-grid > div > strong:first-child {
  display: block;
  margin-bottom: 8px;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.page-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  margin-bottom: 18px;
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid #e2e8f0;
  background: transparent;
  box-shadow: none;
}

.page-toolbar--compact {
  gap: 10px;
  padding: 10px 0;
}

.page-toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.page-toolbar-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1 1 auto;
}

.page-toolbar-actions .lookup-field,
.page-toolbar-actions .pdf-download-form,
.page-toolbar-actions .inline-form {
  margin: 0;
}

.page-toolbar-actions .pdf-download-form,
.page-toolbar-actions .inline-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.page-toolbar-actions .btn,
.page-toolbar-actions .action-menu-summary {
  min-height: 42px;
  border-radius: 999px;
}

.page-toolbar-group--navegacion {
  margin-right: auto;
}

.page-toolbar-group--navegacion .page-toolbar-actions {
  justify-content: flex-start;
}

.page-toolbar-group--navegacion .btn-secondary {
  border-color: #cbd5e1;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.page-toolbar-group--registro .btn-primary,
.page-toolbar-group--facturacion .btn-primary,
.page-toolbar-group--acciones .btn-primary {
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.16);
}

.page-toolbar-group--navegacion .btn-secondary::before {
  content: "\2190";
  margin-right: 8px;
  font-weight: 900;
}

.page-toolbar-group--documentos .pdf-download-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: auto;
}

.page-toolbar-group--documentos .pdf-download-form select {
  min-width: 0;
  min-height: 42px;
  border-radius: 999px;
  padding-left: 14px;
  padding-right: 36px;
  background-color: #fff;
}

.page-toolbar-actions input[type="text"],
.page-toolbar-actions input[type="search"],
.page-toolbar-actions select {
  min-width: 180px;
}

.page-toolbar-actions .btn {
  margin: 0;
}

.action-menu {
  position: relative;
}

.action-menu-summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.action-menu.is-open-anchor .action-menu-summary {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #1e3a8a;
}

.action-menu-summary::-webkit-details-marker {
  display: none;
}

.action-menu-caret {
  display: inline-flex;
  transition: transform 0.18s ease;
}

.action-menu[open] .action-menu-caret {
  transform: rotate(90deg);
}

.action-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1200;
  min-width: 240px;
  max-width: min(280px, calc(100vw - 24px));
  max-height: min(360px, calc(100vh - 24px));
  overflow-y: auto;
  padding: 10px;
  border: 1px solid #dbe4ee;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
}

.action-menu.is-floating .action-menu-panel {
  position: fixed;
  top: var(--action-menu-top, 0);
  left: var(--action-menu-left, 0);
  right: auto;
  width: min(280px, calc(100vw - 24px));
  max-height: var(--action-menu-max-height, min(360px, calc(100vh - 24px)));
}

.action-menu--left .action-menu-panel {
  left: 0;
  right: auto;
}

.action-menu-items {
  display: grid;
  gap: 4px;
}

.action-menu-section-label {
  padding: 8px 12px 4px;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.action-menu-divider {
  height: 1px;
  margin: 6px 0;
  background: #e2e8f0;
}

.action-menu-link {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #0f172a;
  padding: 10px 12px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

.action-menu-link:hover {
  background: #f8fafc;
}

.action-menu-link.is-danger {
  color: #b42318;
}

.action-menu-link.is-danger:hover {
  background: #fff1f2;
}

.action-menu-form {
  margin: 0;
}

.action-menu-form-stack {
  display: grid;
  gap: 10px;
}

.action-menu-form-stack select,
.action-menu-form-stack .btn {
  width: 100%;
}

.action-menu--sm .action-menu-panel {
  min-width: 220px;
}

.table-action-cell {
  white-space: nowrap;
}

.table tr.is-menu-active td {
  background: #f8fafc;
}

.record-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.record-overview-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.record-overview-card span {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.record-overview-card strong {
  display: block;
  margin-top: 8px;
  color: #0f172a;
  font-size: 20px;
  line-height: 1.2;
}

.record-overview-card .topbar-subtitle {
  margin-top: 6px;
}

.view-tabs {
  display: grid;
  gap: 16px;
}

.view-tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fafc;
}

.view-tab-btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #475569;
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.view-tab-btn:hover {
  background: #eef2f7;
}

.view-tab-btn.is-active {
  background: #0f172a;
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.view-tab-panel {
  display: none;
}

.view-tab-panel.is-active {
  display: block;
}

.view-tab-panel-stack {
  display: grid;
  gap: 16px;
}

.detail-hero {
  display: grid;
  gap: 20px;
}

.detail-hero-main {
  display: grid;
  gap: 14px;
}

.detail-hero-main h2 {
  margin: 0;
  font-size: 28px;
}

.detail-hero-main p {
  margin: 0;
  color: var(--muted);
}

.detail-hero-with-image {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.detail-media {
  flex: 0 0 auto;
}

.detail-thumb {
  width: 120px;
  height: 120px;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #fff;
}

.detail-thumb-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  background: #f8fafc;
}

.detail-eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-title-block {
  display: grid;
  gap: 6px;
}

.detail-keyfacts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.detail-keyfact {
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.detail-keyfact-label {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-keyfact-value {
  display: block;
  margin-top: 8px;
  color: #0f172a;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.detail-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  color: #334155;
  font-size: 14px;
}

.detail-actions-panel {
  display: grid;
  gap: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.detail-action-group {
  display: grid;
  gap: 8px;
}

.detail-action-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.detail-grid-span {
  grid-column: 1 / -1;
}

.thumb-60 {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.right {
  text-align: right;
}

.cell-center {
  text-align: center;
}

.cell-total {
  text-align: right;
  white-space: nowrap;
}

/* Login */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #eff6ff 0%, #f8fafc 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.auth-card h1 {
  margin: 0 0 8px;
}

.auth-card p {
  margin: 0 0 20px;
  color: var(--muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Responsive */
@media (max-width: 1024px) {
  .content {
    padding: 18px;
  }

  .topbar h1 {
    font-size: 24px;
  }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    width: min(280px, 86vw);
  }

  .content {
    margin-left: 0;
    padding: 16px;
  }

  .sidebar-toggle-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-toggle-desktop {
    display: none;
  }

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

  body.sidebar-mobile-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 999;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-user {
    display: block;
  }

  .profile-menu-toggle {
    padding: 8px;
  }

  .profile-meta {
    display: none;
  }

  .form-row,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .page-toolbar-group {
    width: 100%;
  }

  .page-toolbar-label {
    min-width: 0;
  }

  .page-toolbar-actions {
    width: 100%;
  }

  .page-toolbar-group--documentos .pdf-download-form {
    width: 100%;
  }

  .page-toolbar-group--documentos .pdf-download-form select,
  .page-toolbar-group--documentos .pdf-download-form .btn {
    width: 100%;
  }

  .detail-grid,
  .detail-hero-with-image {
    grid-template-columns: 1fr;
  }

  .table-pager {
    align-items: stretch;
  }

  .table-pager,
  .table-pager-left,
  .table-pager-controls {
    flex-direction: column;
  }

  .table-pager-controls {
    align-items: stretch;
  }

  .table-pager-btn {
    width: 100%;
  }
}
.list-toolbar {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.list-toolbar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.list-search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.list-search-wrap input {
  flex: 1 1 360px;
  min-width: 260px;
  max-width: 520px;
}

.list-search-status {
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}

.table-card {
  overflow-x: auto;
}

.table-card .table {
  min-width: 1100px;
}

@media (max-width: 700px) {
  .filter-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-toggle {
    width: 100%;
  }

  .list-toolbar-top,
  .list-search-wrap {
    flex-direction: column;
    align-items: stretch;
  }

  .list-search-wrap input,
  .list-search-wrap .btn {
    width: 100%;
    max-width: none;
  }

  .page-toolbar-actions input[type="text"],
  .page-toolbar-actions input[type="search"],
  .page-toolbar-actions select,
  .page-toolbar-actions .btn,
  .page-toolbar-actions .pdf-download-form,
  .page-toolbar-actions .inline-form {
    width: 100%;
  }

  .record-overview,
  .view-tab-list {
    grid-template-columns: 1fr;
  }

  .view-tab-list {
    display: grid;
  }

  .view-tab-btn {
    width: 100%;
    text-align: left;
  }

  .action-menu,
  .action-menu-summary {
    width: 100%;
  }

}

.select-filter-wrap {
  display: grid;
  gap: 8px;
}

.select-filter-input {
  background: #f8fafc;
}

.lookup-field {
  position: relative;
}

.lookup-input {
  background: #fff;
}

.lookup-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  max-height: 260px;
  overflow-y: auto;
}

.lookup-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eef2f7;
}

.lookup-item:last-child {
  border-bottom: 0;
}

.lookup-item:hover {
  background: #f8fafc;
}

.lookup-item-title {
  font-weight: 600;
}

.lookup-item-subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.lookup-empty {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.help-text {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.pdf-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.pdf-template-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  display: grid;
  gap: 14px;
}

.pdf-template-card.is-default {
  border-color: rgba(29, 78, 216, 0.35);
  box-shadow: 0 12px 28px rgba(29, 78, 216, 0.12);
}

.pdf-template-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.pdf-template-logo,
.pdf-logo-preview {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #eef4ff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.pdf-template-logo img,
.pdf-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.pdf-template-logo span,
.pdf-logo-preview span {
  font-size: 30px;
  font-weight: 700;
  color: var(--primary);
}

.pdf-template-meta {
  display: grid;
  gap: 4px;
}

.pdf-template-meta span {
  color: var(--muted);
  font-size: 12px;
}

.pdf-template-mini-preview {
  position: relative;
  width: 132px;
  min-width: 132px;
  height: 110px;
  border-radius: 18px;
  border: 1px solid #dbe3ee;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  overflow: hidden;
}

.pdf-template-mini-preview::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 10px;
  right: 10px;
  height: var(--pdf-header-height, 54px);
  border-radius: var(--pdf-header-radius, 14px);
  background: var(--pdf-primary, #0E5DA8);
}

.pdf-template-mini-preview::after {
  content: "";
  position: absolute;
  inset: auto 10px 10px;
  height: 18px;
  border-radius: 999px;
  background: var(--pdf-accent, #0A3D73);
}

.pdf-template-mini-logo {
  position: absolute;
  top: calc(12px + ((var(--pdf-header-height, 54px) - var(--pdf-logo-size, 40px)) / 2) + var(--pdf-logo-y-offset, 0px));
  left: var(--pdf-logo-x, 28px);
  width: var(--pdf-logo-size, 40px);
  height: var(--pdf-logo-size, 40px);
  border-radius: var(--pdf-logo-shape-radius, 999px);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  z-index: 1;
}

.pdf-template-mini-logo img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}

.pdf-template-mini-logo span {
  font-weight: 800;
  color: var(--pdf-primary, #0E5DA8);
}

.pdf-template-mini-copy {
  position: absolute;
  top: 24px;
  left: calc(var(--pdf-logo-x, 28px) + var(--pdf-logo-size, 40px) + 16px);
  right: 10px;
  color: var(--pdf-on-color-text, #fff);
  display: grid;
  gap: 4px;
  z-index: 1;
}

.pdf-template-mini-copy strong,
.pdf-template-mini-copy small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdf-template-mini-copy strong {
  font-size: 12px;
}

.pdf-template-mini-copy small {
  font-size: 10px;
  opacity: 0.88;
}

.pdf-template-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pdf-template-colors span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #334155;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
}

.pdf-template-colors i {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.pdf-logo-card {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  background: #f8fafc;
}

.pdf-logo-fields {
  display: grid;
  gap: 14px;
}

.pdf-settings-shell {
  display: grid;
  gap: 18px;
}

.pdf-settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.pdf-settings-sections {
  display: grid;
  gap: 18px;
}

.pdf-settings-section {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.pdf-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.pdf-preview-panel {
  position: sticky;
  top: 24px;
}

.pdf-preview-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
  box-shadow: var(--shadow-soft);
}

.pdf-preview-sheet {
  border: 1px solid #d7e3f0;
  border-radius: 22px;
  background: #ffffff;
  min-height: 520px;
  padding: 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

.pdf-preview-header {
  position: relative;
  min-height: 72px;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 22px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px dashed #c7d6e6;
}

.pdf-preview-logo-side,
.pdf-preview-text-side {
  position: absolute;
  top: 0;
  bottom: 0;
}

.pdf-preview-logo-side {
  left: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(248,250,252,0.96) 100%);
}

.pdf-preview-text-side {
  right: 0;
}

.pdf-preview-guide {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed rgba(100, 116, 139, 0.35);
  pointer-events: none;
}

.pdf-preview-guide-top {
  top: 12px;
}

.pdf-preview-guide-middle {
  top: 50%;
}

.pdf-preview-guide-bottom {
  bottom: 12px;
}

.pdf-preview-logo-frame {
  position: absolute;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pdf-preview-logo-frame img,
.pdf-preview-logo-frame span {
  object-fit: contain;
}

.pdf-preview-logo-frame span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}

.pdf-preview-copy {
  position: absolute;
  display: grid;
  gap: 6px;
  color: #fff;
  z-index: 2;
}

.pdf-preview-copy strong {
  font-size: 18px;
  line-height: 1.05;
}

.pdf-preview-copy small {
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.88;
}

.pdf-preview-body {
  display: grid;
  gap: 16px;
}

.pdf-preview-block {
  height: 64px;
  border-radius: 16px;
  border: 1px solid #dbe3ee;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.pdf-preview-block.is-soft {
  height: 128px;
}

.pdf-preview-lines {
  display: grid;
  gap: 10px;
}

.pdf-preview-lines span {
  height: 10px;
  border-radius: 999px;
  background: #e8eef6;
}

.pdf-preview-lines span:nth-child(1) {
  width: 88%;
}

.pdf-preview-lines span:nth-child(2) {
  width: 100%;
}

.pdf-preview-lines span:nth-child(3) {
  width: 72%;
}

.pdf-preview-footer {
  margin-top: 24px;
  border-radius: 999px;
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 10px 14px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.pdf-download-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pdf-download-form select {
  min-width: 220px;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #334155;
}

.checkbox-inline input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
}

.checkbox-card {
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  align-self: end;
}

@media (max-width: 700px) {
  .pdf-logo-card {
    grid-template-columns: 1fr;
  }

  .pdf-control-grid,
  .pdf-settings-layout {
    grid-template-columns: 1fr;
  }

  .pdf-preview-panel {
    position: static;
  }
}

.search-select {
  position: relative;
}

.search-select-source {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.search-select-trigger {
  width: 100%;
  min-height: 44px;
  border: 1px solid #d1d9e6;
  border-radius: 12px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  text-align: left;
  font: inherit;
  color: #142033;
}

.search-select.is-empty .search-select-trigger {
  color: #60708a;
}

.search-select-trigger:focus {
  outline: none;
  border-color: #1f6feb;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15);
}

.search-select-caret {
  color: #60708a;
  font-size: 0.8rem;
}

.search-select-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  z-index: 40;
  background: #fff;
  border: 1px solid #d1d9e6;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(18, 31, 53, 0.14);
  padding: 0.7rem;
  display: none;
}

.search-select.is-open .search-select-panel {
  display: block;
}

.search-select-input {
  width: 100%;
  border: 1px solid #d1d9e6;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  margin-bottom: 0.6rem;
}

.search-select-options {
  max-height: 260px;
  overflow-y: auto;
  display: grid;
  gap: 0.35rem;
}

.search-select-option,
.search-select-empty {
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: #f6f8fb;
  padding: 0.7rem 0.8rem;
  text-align: left;
  font: inherit;
  color: #142033;
}

.search-select-option:hover,
.search-select-option.is-selected {
  background: #e8f0ff;
}

.search-select-empty {
  color: #60708a;
}
