:root {
  --header-h: 90px;
  --sidebar-w: 200px;
  --sidebar-collapsed-w: 80px;
  --blue-1: #0a2e5c;
  --blue-2: #0f4c8a;
  --blue-3: #1d6db4;
  --blue-4: #3aa0e3;
  --bg: #eff5fb;
  --panel: #ffffff;
  --text: #12304f;
  --text-soft: #6e87a3;
  --border: rgba(18, 65, 114, 0.08);
  --shadow: 0 14px 35px rgba(8, 44, 85, 0.18);
  --glow: 0 0 0 1px rgba(101, 188, 255, 0.3), 0 0 18px rgba(80, 176, 255, 0.35);
  --transition: 0.28s ease;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(180deg, #edf4fb 0%, #e7f0f9 100%);
  color: var(--text);
  overflow: hidden;
}

/* =========================
   LAYOUT PRINCIPAL
   ========================= */

.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) minmax(0, 1fr);
  grid-template-areas:
    "header header"
    "sidebar main";
  transition: grid-template-columns var(--transition);
}

.app.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed-w) 1fr;
}

.header {
  grid-area: header;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: linear-gradient(135deg, #0a2850 0%, #0f4e8f 45%, #2d8fd5 100%);
  color: #fff;
  box-shadow: 0 10px 30px rgba(8, 34, 65, 0.22);
  position: relative;
  z-index: 40;
}

.header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), transparent 32%, rgba(255, 255, 255, 0.02));
  pointer-events: none;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.main {
  grid-area: main;
  padding: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  background:
    radial-gradient(circle at top right, rgba(58, 160, 227, 0.14), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0));
}

.content-shell {
  min-height: calc(100dvh - var(--header-h) - 36px);
  min-width: 0;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 20px 45px rgba(16, 53, 95, 0.09);
  padding: 24px;
  backdrop-filter: blur(10px);
}

/* =========================
   HEADER
   ========================= */

.menu-toggle {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  flex: 0 0 44px;
}

.header-home-btn {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  flex: 0 0 44px;
  text-decoration: none;
}

.mobile-clock-toggle {
  min-height: 50px;
  width: auto;
  padding: 8px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(10px);
}

.menu-toggle:hover,
.header-home-btn:hover,
.mobile-clock-toggle:hover,
.section-chip:hover,
.profile-box:hover,
.clock-box:hover {
  transform: translateY(-1px);
  box-shadow: var(--glow);
  background: rgba(255, 255, 255, 0.14);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: var(--transition);
}

.brand-link:hover {
  transform: translateY(-1px) scale(1.02);
}

.brand-logo {
  height: 60px;
  width: auto;
  display: block;
  object-fit: contain;
}

.section-chip,
.clock-box,
.profile-box {
  display: flex;
  align-items: center;
  min-height: 56px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 14px;
  backdrop-filter: blur(10px);
  transition: var(--transition);
}

.section-chip {
  gap: 10px;
  min-width: 190px;
}

.section-chip-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  min-width: 0;
}

.section-chip-label {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.72;
}

.section-chip-name {
  font-size: 0.96rem;
  font-weight: 700;
  margin-top: 4px;
}

.clock-box {
  min-width: 116px;
  justify-content: center;
  text-align: center;
  flex-direction: column;
  line-height: 1.15;
}

.clock-day,
.clock-time {
  width: 100%;
  text-align: center;
  font-weight: 700;
  white-space: nowrap;
}

.clock-day {
  font-size: 0.82rem;
  opacity: 0.9;
  margin-bottom: 3px;
}

.clock-time {
  font-size: 1rem;
  letter-spacing: 0.05em;
}

.mobile-clock-wrap {
  position: relative;
  display: none;
}

.mobile-clock-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 180px;
  background: rgba(8, 43, 82, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 18px 40px rgba(3, 20, 40, 0.28);
  display: none;
  backdrop-filter: blur(12px);
}

.mobile-clock-dropdown.show {
  display: block;
}

/* =========================
   PERFIL
   ========================= */

.profile-box {
  gap: 10px;
  min-width: 170px;
  justify-content: flex-end;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.14));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  flex: 0 0 38px;
}

.profile-data {
  display: flex;
  flex-direction: column;
  text-align: right;
  line-height: 1.1;
}

.profile-name {
  font-weight: 700;
  font-size: 0.94rem;
}

.profile-role {
  font-size: 0.76rem;
  opacity: 0.8;
  margin-top: 4px;
}

.profile-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.profile-trigger {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  font: inherit;
  text-align: inherit;
  width: 100%;
  cursor: pointer;
}

.profile-trigger:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  background: rgba(8, 43, 82, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 18px 40px rgba(3, 20, 40, 0.28);
  backdrop-filter: blur(12px);
  display: none;
  z-index: 90;
}

.profile-dropdown.show {
  display: block;
}

.profile-dropdown-item {
  min-height: 44px;
  border-radius: 12px;
  padding: 10px 12px;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
}

.profile-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: var(--glow);
}

.profile-dropdown-user {
  padding: 10px 12px 12px;
  color: #fff;
}

.profile-dropdown-name {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.profile-dropdown-role {
  font-size: 0.8rem;
  opacity: 0.78;
  margin-top: 4px;
}

.profile-dropdown-divider {
  height: 1px;
  margin: 4px 8px 8px;
  background: rgba(255, 255, 255, 0.12);
}

/* =========================
   SIDEBAR
   ========================= */

.sidebar {
  grid-area: sidebar;
  background: linear-gradient(180deg, #0a2d59 0%, #0d477f 50%, #1d74b8 100%);
  color: #fff;
  padding: 16px 12px 18px;
  overflow: auto;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 20;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  padding: 6px 10px;
  gap: 8px;
  min-height: 34px;
}

.nav-item::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.03));
  opacity: 0;
  transition: var(--transition);
}

.nav-item:hover::before,
.nav-item.active::before {
  opacity: 1;
}

.nav-item:hover,
.nav-item.active {
  box-shadow: var(--glow);
  transform: translateX(2px);
}

.nav-icon {
  width: 28px;
  min-width: 28px;
  text-align: left;
  font-size: 1.1rem;
  position: relative;
  z-index: 1;
}

.nav-label {
  font-size: 0.96rem;
  font-weight: 600;
  white-space: nowrap;
  position: relative;
  z-index: 1;
  transition: opacity var(--transition), transform var(--transition), text-shadow var(--transition);
}

.app.sidebar-collapsed .nav-label {
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  width: 0;
}

.app.sidebar-collapsed .nav-item {
  justify-content: flex-start;
  padding-left: 16px;
  padding-right: 16px;
}

.mobile-overlay {
  display: none;
}

/* =========================
   COMPONENTES BASE
   ========================= */

.page-header {
  margin-bottom: 20px;
}

.page-title {
  margin: 0 0 8px;
  font-size: 1.6rem;
  font-weight: 800;
  color: #0d3b69;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-subtitle {
  margin: 0 0 22px;
  color: var(--text-soft);
  font-size: 0.96rem;
}

.section-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.section-search {
  min-width: 260px;
  flex: 1;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(18, 65, 114, 0.15);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  color: var(--text);
  outline: none;
  transition: var(--transition);
}

.section-search:focus {
  border-color: rgba(29, 109, 180, 0.55);
  box-shadow: 0 0 0 3px rgba(58, 160, 227, 0.14);
}

.section-btn {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue-2), var(--blue-4));
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.section-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.section-message,
[id$="Message"] {
  margin-bottom: 1rem;
}

.crud-total-chip,
.clientes-total-chip,
.notarios-total-chip,
.summary-chip {
  color: #1b568f;
  font-size: 1.10rem;
  font-weight: 600;
  white-space: nowrap;
}

/* =========================
   BUSCADOR CRUD COMÚN
   ========================= */

[data-page="clientes"] .input-group,
[data-page="notarios"] .input-group,
[data-page="expedientes"] .input-group,
[data-page="registros"] .input-group,
[data-page="ayuntamientos"] .input-group,
[data-page="otorgantes"] .input-group {
  transition: all 0.2s ease;
}

[data-page="clientes"] .input-group-text,
[data-page="notarios"] .input-group-text,
[data-page="expedientes"] .input-group-text,
[data-page="registros"] .input-group-text,
[data-page="ayuntamientos"] .input-group-text,
[data-page="otorgantes"] .input-group-text {
  background-color: #f1f5f9;
  border-right: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  border-radius: 6px 0 0 6px;
}

[data-page="clientes"] .input-group .form-control,
[data-page="notarios"] .input-group .form-control,
[data-page="expedientes"] .input-group .form-control,
[data-page="registros"] .input-group .form-control,
[data-page="ayuntamientos"] .input-group .form-control,
[data-page="otorgantes"] .input-group .form-control {
  border-left: 0;
  border-radius: 0 6px 6px 0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

[data-page="clientes"] .input-group:has(.btn-clear-search:not(.hidden)) .form-control,
[data-page="notarios"] .input-group:has(.btn-clear-search:not(.hidden)) .form-control,
[data-page="expedientes"] .input-group:has(.btn-clear-search:not(.hidden)) .form-control,
[data-page="registros"] .input-group:has(.btn-clear-search:not(.hidden)) .form-control,
[data-page="ayuntamientos"] .input-group:has(.btn-clear-search:not(.hidden)) .form-control,
[data-page="otorgantes"] .input-group:has(.btn-clear-search:not(.hidden)) .form-control {
  border-right: 0;
  border-radius: 0;
}

[data-page="clientes"] .input-group:focus-within .input-group-text i,
[data-page="notarios"] .input-group:focus-within .input-group-text i,
[data-page="expedientes"] .input-group:focus-within .input-group-text i,
[data-page="registros"] .input-group:focus-within .input-group-text i,
[data-page="ayuntamientos"] .input-group:focus-within .input-group-text i,
[data-page="otorgantes"] .input-group:focus-within .input-group-text i {
  color: #0d6efd;
}

[data-page="clientes"] .form-control:focus,
[data-page="notarios"] .form-control:focus,
[data-page="expedientes"] .form-control:focus,
[data-page="registros"] .form-control:focus,
[data-page="ayuntamientos"] .form-control:focus,
[data-page="otorgantes"] .form-control:focus {
  box-shadow: none;
}

[data-page="clientes"] .input-group:focus-within .input-group-text,
[data-page="notarios"] .input-group:focus-within .input-group-text,
[data-page="expedientes"] .input-group:focus-within .input-group-text,
[data-page="registros"] .input-group:focus-within .input-group-text,
[data-page="ayuntamientos"] .input-group:focus-within .input-group-text,
[data-page="otorgantes"] .input-group:focus-within .input-group-text {
  background-color: #e9f3ff;
  border-color: #86b7fe;
}

[data-page="clientes"] .input-group:focus-within .form-control,
[data-page="notarios"] .input-group:focus-within .form-control,
[data-page="expedientes"] .input-group:focus-within .form-control,
[data-page="registros"] .input-group:focus-within .form-control,
[data-page="ayuntamientos"] .input-group:focus-within .form-control,
[data-page="otorgantes"] .input-group:focus-within .form-control {
  border-color: #86b7fe;
  background-color: #fcfeff;
}

[data-page="clientes"] .input-group:focus-within .btn-clear-search,
[data-page="notarios"] .input-group:focus-within .btn-clear-search,
[data-page="expedientes"] .input-group:focus-within .btn-clear-search,
[data-page="registros"] .input-group:focus-within .btn-clear-search,
[data-page="ayuntamientos"] .input-group:focus-within .btn-clear-search,
[data-page="otorgantes"] .input-group:focus-within .btn-clear-search {
  background-color: #e9f3ff;
  border-color: #86b7fe;
  color: #0d6efd;
}

[data-page="clientes"] .btn-clear-search,
[data-page="notarios"] .btn-clear-search,
[data-page="expedientes"] .btn-clear-search,
[data-page="registros"] .btn-clear-search,
[data-page="ayuntamientos"] .btn-clear-search,
[data-page="otorgantes"] .btn-clear-search {
  border-left: 0;
  background-color: #f1f5f9;
  color: #6c757d;
  padding: 0 10px;
  display: flex;
  align-items: center;
  border-radius: 0 6px 6px 0;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

[data-page="clientes"] .btn-clear-search:hover,
[data-page="notarios"] .btn-clear-search:hover,
[data-page="expedientes"] .btn-clear-search:hover,
[data-page="registros"] .btn-clear-search:hover,
[data-page="ayuntamientos"] .btn-clear-search:hover,
[data-page="otorgantes"] .btn-clear-search:hover {
  background-color: #dbeafe;
  color: #0b5ed7;
}

[data-page="clientes"] .btn-clear-search:focus,
[data-page="notarios"] .btn-clear-search:focus,
[data-page="expedientes"] .btn-clear-search:focus,
[data-page="registros"] .btn-clear-search:focus,
[data-page="ayuntamientos"] .btn-clear-search:focus,
[data-page="otorgantes"] .btn-clear-search:focus {
  box-shadow: none;
}

[data-page="clientes"] .btn-clear-search.hidden,
[data-page="notarios"] .btn-clear-search.hidden,
[data-page="expedientes"] .btn-clear-search.hidden,
[data-page="registros"] .btn-clear-search.hidden,
[data-page="ayuntamientos"] .btn-clear-search.hidden,
[data-page="otorgantes"] .btn-clear-search.hidden {
  display: none;
}

/* =========================
   TABLAS CRUD COMUNES
   ========================= */

.table.table-crud {
  border-radius: 10px;
  overflow: hidden;
}

.table.table-crud thead th {
  background: linear-gradient(180deg, #1b568f 0%, #15497b 100%);
  color: #ffffff;
  font-weight: 600;
  border-bottom: none;
  white-space: nowrap;
  padding: 10px 12px;
  font-size: 0.85rem;
}

.table.table-crud thead th:hover {
  background: #1f5d99;
}

.table.table-crud thead th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.table.table-crud thead th.sortable>span:first-child {
  display: inline-block;
}

.table.table-crud thead th .sort-indicator {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-left: 8px;
  vertical-align: middle;
  line-height: 0.7;
  font-size: 0.7rem;
  opacity: 0.45;
}

.table.table-crud thead th .sort-indicator::before {
  content: "▲";
  display: block;
}

.table.table-crud thead th .sort-indicator::after {
  content: "▼";
  display: block;
  margin-top: 1px;
}

.table.table-crud thead th.sort-asc .sort-indicator,
.table.table-crud thead th.sort-desc .sort-indicator {
  opacity: 1;
}

.table.table-crud thead th.sort-asc .sort-indicator::before {
  color: #ffffff;
}

.table.table-crud thead th.sort-asc .sort-indicator::after {
  color: rgba(255, 255, 255, 0.35);
}

.table.table-crud thead th.sort-desc .sort-indicator::before {
  color: rgba(255, 255, 255, 0.35);
}

.table.table-crud thead th.sort-desc .sort-indicator::after {
  color: #ffffff;
}

.table.table-crud tbody>tr:nth-of-type(odd)>* {
  background-color: #ffffff !important;
}

.table.table-crud tbody>tr:nth-of-type(even)>* {
  background-color: #d6e9ff !important;
}

.table.table-crud tbody>tr:hover>* {
  background-color: #bcdcff !important;
  transition: background-color 0.2s ease;
}

.table.table-crud tbody td {
  vertical-align: middle;
  padding: 9px 12px;
  font-size: 0.88rem;
  line-height: 1.2;
}

.table.table-crud td.text-end,
.col-acciones {
  white-space: nowrap;
}

.table.table-crud .btn {
  border-radius: 8px;
}

.table.table-crud .btn.btn-sm {
  padding: 0.2rem 0.45rem;
  font-size: 0.8rem;
}

.col-acciones {
  width: 115px;
  min-width: 115px;
  max-width: 115px;
}

[data-page="clientes"] .col-acciones {
  width: 150px;
  min-width: 150px;
  max-width: 150px;
}

/* =========================
   MODALES Y FORMULARIOS
   ========================= */

.modal-header {
  background: linear-gradient(180deg, #1b568f, #15497b);
  color: #ffffff;
  border-bottom: none;
}

.modal-header .modal-title {
  font-weight: 600;
}

.form-label {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-left: 6px;
}

.modal-content {
  border-radius: 16px;
  border: 1px solid rgba(18, 65, 114, 0.12);
  box-shadow: 0 20px 45px rgba(10, 46, 92, 0.15);
}

.modal-dialog {
  margin-top: 1.75rem;
  margin-bottom: 1.75rem;
}

.modal-body {
  padding-top: 10px;
  max-height: calc(100vh - 210px);
  overflow-y: auto;
  overflow-x: hidden;
}

.modal-body .form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #4a6b8a;
  margin-bottom: 4px;
}

.modal-body .form-control,
.modal-body .form-select {
  border-radius: 10px;
  border: 1px solid #000000;
  padding: 8px 10px;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.modal-body .form-control:focus,
.modal-body .form-select:focus {
  border-color: #3aa0e3;
  box-shadow: 0 0 0 3px rgba(58, 160, 227, 0.15);
}

.modal-body .row.g-3>div {
  margin-bottom: 4px;
}

/* =========================
   HOME / TARJETAS / ACTIVIDAD
   ========================= */

.home-page,
.expedientes-page,
.consultas-page,
.varios-page,
.seguimiento-page,
.facturas-page,
.reportes-page,
.configuracion-page {}

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

.info-card,
.metric-card,
.summary-card,
.section-panel,
.error-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 249, 255, 0.96));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-card-title,
.section-panel-title {
  margin: 0 0 10px;
  color: #10385d;
  font-size: 1rem;
  font-weight: 800;
}

.info-card-text,
.empty-state,
.error-text {
  margin: 0;
  color: #54728d;
  line-height: 1.6;
}

.summary-label,
.metric-label {
  display: block;
  font-size: 0.84rem;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.summary-value,
.metric-value {
  font-size: 2rem;
  font-weight: 800;
  color: #0f3f6f;
}

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

.section-panel {
  margin-top: 18px;
}

.section-panel-head {
  margin-bottom: 12px;
}

.summary-link-btn {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(18, 65, 114, 0.14);
  border-radius: 12px;
  background: rgba(58, 160, 227, 0.08);
  color: #0f3f6f;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.summary-link-btn:hover {
  transform: translateY(-1px);
  background: rgba(58, 160, 227, 0.14);
  box-shadow: var(--shadow);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.activity-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(58, 160, 227, 0.08);
  color: #20496d;
  font-weight: 600;
}

.activity-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  line-height: 1.4;
}

.activity-icon {
  width: 18px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.activity-icon i {
  font-size: 0.92rem;
}

.activity-icon i.fa-circle-plus {
  color: #16a34a;
}

.activity-icon i.fa-pen {
  color: #2563eb;
}

.activity-icon i.fa-trash {
  color: #dc2626;
}

.activity-icon i.fa-clock-rotate-left {
  color: #64748b;
}

.activity-item-meta {
  margin-top: 4px;
  font-size: 0.84rem;
  color: #54728d;
  padding-left: 26px;
}

.loading-state {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #2f5d89;
  font-weight: 600;
  padding: 16px 0;
}

.error-card {
  max-width: 720px;
  margin: 28px auto 0;
  text-align: center;
}

.error-icon {
  font-size: 2.4rem;
  color: #0f5d99;
  margin-bottom: 14px;
}

/* =========================
   CONFIGURACIÓN
   ========================= */

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 520px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(16, 53, 95, 0.08);
}

.settings-label {
  font-weight: 700;
  color: #10385d;
}

/* =========================
   LOGIN
   ========================= */

.login-body {
  overflow: auto;
}

.login-wrapper {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-container {
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.login-logo {
  margin-bottom: 20px;
}

.login-logo img {
  max-width: 180px;
  height: auto;
}

.login-header {
  margin-bottom: 20px;
}

.login-header .page-title {
  justify-content: center;
  font-size: 1.8rem;
}

.login-header .page-subtitle {
  font-size: 1rem;
  opacity: 0.8;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-btn {
  margin-top: 6px;
}

.login-form .section-search {
  width: 100%;
}

/* =========================
   RESPONSIVE
   ========================= */

@media (max-width: 980px) {
  .section-chip {
    min-width: 140px;
    max-width: 140px;
    min-height: 44px;
    padding: 6px 10px;
    border-radius: 14px;
  }

  .clock-box {
    display: none;
  }

  .mobile-clock-wrap {
    display: block;
  }

  .mobile-clock-toggle {
    min-height: 44px;
    padding: 6px 10px;
    border-radius: 14px;
  }

  .profile-box {
    min-height: 44px;
    padding: 6px 10px;
    border-radius: 14px;
    min-width: auto;
  }

  .avatar {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .profile-data {
    display: none;
  }

  .section-chip-label {
    display: none;
  }

  .section-chip-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-logo {
    content: url('../images/logo_mobile.png');
    height: 24px;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app,
  .app.sidebar-collapsed {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: 200px;
    transform: translateX(-102%);
    transition: transform var(--transition);
    border-top-right-radius: 18px;
    z-index: 60;
  }

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

  .mobile-overlay {
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(7, 24, 43, 0.35);
    backdrop-filter: blur(2px);
    z-index: 50;
  }

  .app.mobile-sidebar-open .mobile-overlay {
    display: block;
  }

  .main {
    padding: 14px;
  }

  .content-shell {
    min-height: calc(100dvh - var(--header-h) - 28px);
    padding: 18px;
    border-radius: 20px;
  }
}

@media (max-width: 580px) {
  .header {
    padding: 0 12px;
  }

  .header-left,
  .header-right {
    gap: 8px;
  }

  .section-chip {
    min-width: 140px;
    max-width: 140px;
    padding: 6px 8px;
  }

  .menu-toggle {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    flex-basis: 40px;
  }

  .mobile-clock-toggle,
  .profile-box {
    min-height: 40px;
    padding: 5px 8px;
    border-radius: 12px;
  }

  .avatar {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .section-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .section-search,
  .section-btn {
    width: 100%;
  }

  .dashboard-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================
   Geoapify address autocomplete
========================= */
.geo-autocomplete-wrap {
  position: relative;
  width: 100%;
}

.geo-autocomplete-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 2000;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid rgba(15, 57, 105, 0.16);
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
  padding: 6px;
}

.geo-autocomplete-menu.hidden {
  display: none;
}

.geo-autocomplete-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 0;
  background: transparent;
  color: #1f2937;
  text-align: left;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.25;
  cursor: pointer;
}

.geo-autocomplete-item i {
  color: var(--blue-2, #0f4c81);
  margin-top: 2px;
}

.geo-autocomplete-item:hover,
.geo-autocomplete-item.active {
  background: rgba(13, 110, 253, 0.08);
  color: var(--blue-1, #0a2e5c);
}

.geo-autocomplete-status {
  padding: 10px 12px;
  color: #64748b;
  font-size: 0.88rem;
}

[data-page="expedientes"] .col-acciones {
  width: 175px;
  min-width: 175px;
  max-width: 175px;
}

[data-page="expedientes"] .table-crud th:nth-child(2),
[data-page="expedientes"] .table-crud td:nth-child(2) {
  width: 40%;
}

[data-page="expedientes"] .table-crud th:nth-child(4),
[data-page="expedientes"] .table-crud td:nth-child(4) {
  width: 26%;
}

[data-page="expedientes"] .table-crud td:nth-child(2) {
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-page="clientes"] .table-crud td:nth-child(2) {
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================
   Cliente autocomplete expedientes
========================= */

.cliente-autocomplete-wrap {
  position: relative;
  width: 100%;
}

.cliente-autocomplete-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 2100;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid rgba(15, 57, 105, 0.16);
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
  padding: 6px;
}
/* Autocomplete del modal Expedientes e Importes: input, lupa y botón de añadir como un único control */
.expediente-cliente-autocomplete,
.expediente-notario-autocomplete,
.expediente-registro-autocomplete,
.expediente-ayuntamiento-autocomplete,
.expediente-otorgante-autocomplete {
  border: 1px solid #212529;
  border-radius: 0.375rem;
  background: #fff;
  overflow: visible;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.expediente-cliente-autocomplete .input-group-text,
.expediente-cliente-autocomplete .form-control,
.expediente-cliente-autocomplete #expedienteAddClienteBtn,
.expediente-notario-autocomplete .input-group-text,
.expediente-notario-autocomplete .form-control,
.expediente-notario-autocomplete #expedienteAddNotarioBtn,
.expediente-registro-autocomplete .input-group-text,
.expediente-registro-autocomplete .form-control,
.expediente-registro-autocomplete #expedienteAddRegistroBtn,
.expediente-ayuntamiento-autocomplete .input-group-text,
.expediente-ayuntamiento-autocomplete .form-control,
.expediente-ayuntamiento-autocomplete #expedienteAddAyuntamientoBtn,
.expediente-otorgante-autocomplete .input-group-text,
.expediente-otorgante-autocomplete .form-control,
.expediente-otorgante-autocomplete #expedienteAddOtorganteBtn {
  border: 0;
  box-shadow: none;
  background-color: transparent;
  color: #212529;
  transition: color 0.16s ease, background-color 0.16s ease;
}

.expediente-cliente-autocomplete .input-group-text,
.expediente-notario-autocomplete .input-group-text,
.expediente-registro-autocomplete .input-group-text,
.expediente-ayuntamiento-autocomplete .input-group-text,
.expediente-otorgante-autocomplete .input-group-text {
  border-radius: 0.375rem 0 0 0.375rem;
}

.expediente-cliente-autocomplete .form-control:focus,
.expediente-notario-autocomplete .form-control:focus,
.expediente-registro-autocomplete .form-control:focus,
.expediente-ayuntamiento-autocomplete .form-control:focus,
.expediente-otorgante-autocomplete .form-control:focus {
  box-shadow: none;
}

.expediente-cliente-autocomplete #expedienteAddClienteBtn,
.expediente-notario-autocomplete #expedienteAddNotarioBtn,
.expediente-registro-autocomplete #expedienteAddRegistroBtn,
.expediente-ayuntamiento-autocomplete #expedienteAddAyuntamientoBtn,
.expediente-otorgante-autocomplete #expedienteAddOtorganteBtn {
  border-radius: 0 0.375rem 0.375rem 0;
}

.expediente-cliente-autocomplete:focus-within,
.expediente-notario-autocomplete:focus-within,
.expediente-registro-autocomplete:focus-within,
.expediente-ayuntamiento-autocomplete:focus-within,
.expediente-otorgante-autocomplete:focus-within {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.expediente-cliente-autocomplete:focus-within .input-group-text,
.expediente-cliente-autocomplete:focus-within .input-group-text i,
.expediente-cliente-autocomplete:focus-within #expedienteAddClienteBtn,
.expediente-cliente-autocomplete:focus-within #expedienteAddClienteBtn i,
.expediente-notario-autocomplete:focus-within .input-group-text,
.expediente-notario-autocomplete:focus-within .input-group-text i,
.expediente-notario-autocomplete:focus-within #expedienteAddNotarioBtn,
.expediente-notario-autocomplete:focus-within #expedienteAddNotarioBtn i,
.expediente-registro-autocomplete:focus-within .input-group-text,
.expediente-registro-autocomplete:focus-within .input-group-text i,
.expediente-registro-autocomplete:focus-within #expedienteAddRegistroBtn,
.expediente-registro-autocomplete:focus-within #expedienteAddRegistroBtn i,
.expediente-ayuntamiento-autocomplete:focus-within .input-group-text,
.expediente-ayuntamiento-autocomplete:focus-within .input-group-text i,
.expediente-ayuntamiento-autocomplete:focus-within #expedienteAddAyuntamientoBtn,
.expediente-ayuntamiento-autocomplete:focus-within #expedienteAddAyuntamientoBtn i,
.expediente-otorgante-autocomplete:focus-within .input-group-text,
.expediente-otorgante-autocomplete:focus-within .input-group-text i,
.expediente-otorgante-autocomplete:focus-within #expedienteAddOtorganteBtn,
.expediente-otorgante-autocomplete:focus-within #expedienteAddOtorganteBtn i {
  color: #0d6efd;
}

.expediente-cliente-autocomplete #expedienteAddClienteBtn:hover,
.expediente-cliente-autocomplete #expedienteAddClienteBtn:focus,
.expediente-cliente-autocomplete .expediente-cliente-search-trigger:hover,
.expediente-cliente-autocomplete .expediente-cliente-search-trigger:focus,
.expediente-notario-autocomplete #expedienteAddNotarioBtn:hover,
.expediente-notario-autocomplete #expedienteAddNotarioBtn:focus,
.expediente-notario-autocomplete .expediente-notario-search-trigger:hover,
.expediente-notario-autocomplete .expediente-notario-search-trigger:focus,
.expediente-registro-autocomplete #expedienteAddRegistroBtn:hover,
.expediente-registro-autocomplete #expedienteAddRegistroBtn:focus,
.expediente-registro-autocomplete .expediente-registro-search-trigger:hover,
.expediente-registro-autocomplete .expediente-registro-search-trigger:focus,
.expediente-ayuntamiento-autocomplete #expedienteAddAyuntamientoBtn:hover,
.expediente-ayuntamiento-autocomplete #expedienteAddAyuntamientoBtn:focus,
.expediente-ayuntamiento-autocomplete .expediente-ayuntamiento-search-trigger:hover,
.expediente-ayuntamiento-autocomplete .expediente-ayuntamiento-search-trigger:focus,
.expediente-otorgante-autocomplete #expedienteAddOtorganteBtn:hover,
.expediente-otorgante-autocomplete #expedienteAddOtorganteBtn:focus,
.expediente-otorgante-autocomplete .expediente-otorgante-search-trigger:hover,
.expediente-otorgante-autocomplete .expediente-otorgante-search-trigger:focus {
  color: #0d6efd;
  background-color: rgba(13, 110, 253, 0.08);
  box-shadow: none;
}


.expediente-cliente-autocomplete .expediente-cliente-search-trigger,
.expediente-notario-autocomplete .expediente-notario-search-trigger,
.expediente-registro-autocomplete .expediente-registro-search-trigger,
.expediente-ayuntamiento-autocomplete .expediente-ayuntamiento-search-trigger,
.expediente-otorgante-autocomplete .expediente-otorgante-search-trigger {
  cursor: pointer;
  user-select: none;
}

.expediente-cliente-autocomplete .expediente-cliente-search-trigger:hover i,
.expediente-cliente-autocomplete .expediente-cliente-search-trigger:focus i,
.expediente-cliente-autocomplete .expediente-cliente-search-trigger.is-active i,
.expediente-notario-autocomplete .expediente-notario-search-trigger:hover i,
.expediente-notario-autocomplete .expediente-notario-search-trigger:focus i,
.expediente-notario-autocomplete .expediente-notario-search-trigger.is-active i,
.expediente-registro-autocomplete .expediente-registro-search-trigger:hover i,
.expediente-registro-autocomplete .expediente-registro-search-trigger:focus i,
.expediente-registro-autocomplete .expediente-registro-search-trigger.is-active i,
.expediente-ayuntamiento-autocomplete .expediente-ayuntamiento-search-trigger:hover i,
.expediente-ayuntamiento-autocomplete .expediente-ayuntamiento-search-trigger:focus i,
.expediente-ayuntamiento-autocomplete .expediente-ayuntamiento-search-trigger.is-active i,
.expediente-otorgante-autocomplete .expediente-otorgante-search-trigger:hover i,
.expediente-otorgante-autocomplete .expediente-otorgante-search-trigger:focus i,
.expediente-otorgante-autocomplete .expediente-otorgante-search-trigger.is-active i {
  color: #0d6efd;
}

.expediente-cliente-autocomplete .cliente-autocomplete-menu,
.expediente-notario-autocomplete .cliente-autocomplete-menu,
.expediente-registro-autocomplete + .cliente-autocomplete-menu,
.expediente-ayuntamiento-autocomplete + .cliente-autocomplete-menu,
.expediente-otorgante-autocomplete + .cliente-autocomplete-menu {
  top: calc(100% + 7px);
}


.cliente-autocomplete-menu.hidden {
  display: none;
}

.cliente-autocomplete-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border: 0;
  background: transparent;
  color: #1f2937;
  text-align: left;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.25;
  cursor: pointer;
}

.cliente-autocomplete-item:hover,
.cliente-autocomplete-item.active {
  background: rgba(13, 110, 253, 0.08);
  color: var(--blue-1, #0a2e5c);
}

.cliente-autocomplete-name {
  font-weight: 700;
}

.cliente-autocomplete-meta {
  font-size: 0.8rem;
  color: #64748b;
}

.cliente-autocomplete-status {
  padding: 10px 12px;
  color: #64748b;
  font-size: 0.88rem;
}

/* Botones rápidos Expediente (versión simple) */
.expediente-action-btn {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.expediente-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(10, 46, 92, 0.18);
}

.expediente-action-btn i {
  transition: transform 0.18s ease;
}

.expediente-action-btn:hover i {
  transform: scale(1.12);
}

.expediente-action-btn:active {
  transform: translateY(0px) scale(0.98);
}

.expediente-action-btn:hover {
  filter: brightness(1.08);
}

.expediente-action-btn {
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

/* Tamaño uniforme para botones rápidos del modal de expediente */
.expediente-action-btn {
  min-width: 132px;
  justify-content: center;
}

/* Ajustes v5 importes expediente */
.expediente-submodal {
  z-index: 1065;
}

.modal-backdrop.show+.modal-backdrop.show {
  z-index: 1060;
}

.expediente-submodal .expediente-submodal-dialog {
  max-width: min(1320px, calc(100vw - 2rem));
  height: calc(100vh - 2rem);
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.expediente-submodal .modal-content {
  height: 100%;
}

.expediente-submodal .modal-body {
  max-height: none;
}

.col-varios-tipo {
  width: 110px;
  white-space: nowrap;
}

.col-varios-descripcion {
  min-width: 320px;
}


/* Confirmación global por encima de modales anidados */
#confirmAppModal {
  z-index: 1415;
}

.app-confirm-backdrop {
  z-index: 1410 !important;
}

/* Ajustes v8: expedientes y modales anidados */
[data-page="expedientes"] .col-acciones {
  width: 105px;
  min-width: 105px;
  max-width: 105px;
}

[data-page="expedientes"] .table-crud th:nth-child(2),
[data-page="expedientes"] .table-crud td:nth-child(2) {
  width: 48%;
}

.expediente-submodal {
  z-index: 1080;
}

.expediente-submodal .expediente-submodal-dialog {
  height: calc(100vh - 1rem);
  margin-top: .5rem;
  margin-bottom: .5rem;
}

#appMessageModal {
  z-index: 1405;
}

#confirmAppModal {
  z-index: 1415;
}

.app-message-backdrop {
  z-index: 1400 !important;
}

.app-confirm-backdrop {
  z-index: 1410 !important;
}


/* Ajustes v11 */
[data-page="expedientes"] .col-acciones {
  width: 135px !important;
  min-width: 135px !important;
  max-width: 135px !important;
}

[data-page="expedientes"] .table-crud th:nth-child(2),
[data-page="expedientes"] .table-crud td:nth-child(2) {
  width: 44%;
}

#expedienteRegistroGuardarBtn,
#expedienteAyuntamientoGuardarBtn,
#expedienteVariosGuardarBtn {
  min-width: 118px;
  padding-left: .55rem !important;
  padding-right: .55rem !important;
}

#expedienteRegistroGuardarBtn i,
#expedienteAyuntamientoGuardarBtn i {
  font-size: 1.08rem;
}

/* Botones de nuevo elemento dentro de buscadores de importes */
.expediente-add-related-btn {
  min-width: 46px;
  border-color: #0d6efd;
  color: #0d6efd;
  font-size: 1.05rem;
}

.expediente-add-related-btn:hover,
.expediente-add-related-btn:focus {
  background-color: #0d6efd;
  color: #fff;
}

/* Ajustes v15: confirmaciones de borrado por encima de submodales de expediente */
.expediente-delete-confirm {
  z-index: 1305 !important;
}

.expediente-delete-backdrop {
  z-index: 1300 !important;
}


/* Ajustes v16 */
#registroModal,
#ayuntamientoModal,
#otorganteModal {
  z-index: 1065;
}

#expedienteOtorganteBusqueda {
  min-width: 0;
}

/* Totales del modal de Expedientes */
#expedienteModal .modal-body {
  position: relative;
}

#expedienteModal .expediente-general-layout {
  width: 100%;
}

#expedienteModal .expediente-totales-col {
  padding-left: 0.75rem;
  padding-top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}

.expediente-totales-box {
  border: 1px solid #6c757d;
  border-radius: 0.35rem;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 0.15rem 0.45rem rgba(0, 0, 0, 0.08);
}

.expediente-totales-table {
  table-layout: fixed;
  margin-bottom: 0;
  font-size: 1rem;
}

.expediente-totales-table th,
.expediente-totales-table td {
  padding: 0.34rem 0.5rem;
  border-color: #6c757d !important;
  vertical-align: middle;
  line-height: 1.18;
}

.expediente-totales-table thead th {
  background: linear-gradient(180deg, #1b568f, #15497b);
  color: #ffffff;
  font-weight: 700;
  font-size: 1.08rem;
  text-align: center !important;
}

.expediente-totales-table thead th:nth-child(2),
.expediente-totales-table thead th:nth-child(3) {
  text-align: center !important;
}

.expediente-totales-table tbody td:first-child {
  background: #6c757d;
  color: #ffffff;
  font-weight: 600;
  width: 46%;
}

.expediente-totales-table th:nth-child(2),
.expediente-totales-table td:nth-child(2) {
  width: 22%;
}

.expediente-totales-table th:nth-child(3),
.expediente-totales-table td:nth-child(3) {
  width: 32%;
}

.expediente-totales-table tbody td:nth-child(3) {
  text-align: right !important;
}

@media (max-width: 991.98px) {
  #expedienteModal .expediente-totales-col {
    padding-left: calc(var(--bs-gutter-x) * .5);
    padding-top: 0;
    justify-content: stretch;
  }
}


/* Modal Generar Proforma */
#expedienteProformaModal .modal-dialog {
  max-width: min(1500px, 96vw);
}

#expedienteProformaModal .modal-content {
  max-height: 92vh;
}

#expedienteProformaModal form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 92vh;
}

#expedienteProformaModal .modal-header,
#expedienteProformaModal .modal-footer {
  flex: 0 0 auto;
}

#expedienteProformaModal .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 1rem;
}

#expedienteProformaModal .modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.125);
}

.expediente-numero-badge {
  font-size: 1.08rem;
  line-height: 1.25;
  letter-spacing: 0.02em;
  padding: 0.45rem 0.7rem;
}

.proforma-expediente-badge {
  font-size: 1.12rem;
}

.proforma-sticky-summary {
  position: sticky;
  top: -1px;
  z-index: 10;
  padding: 0.75rem;
  margin-top: -0.25rem;
  background: #f8fafc;
  border: 1px solid rgba(13, 110, 253, 0.18);
  border-radius: 0.5rem;
  box-shadow: 0 0.2rem 0.6rem rgba(0, 0, 0, 0.06);
  transform: translateZ(0);
  will-change: transform;
}

#proformaTotalesExpediente .form-label,
#proformaOtorgantesContainer .form-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 0.2rem;
}

#proformaTotalesExpediente .form-control,
#proformaOtorgantesContainer .form-control {
  font-size: 0.86rem;
  padding-left: 0.45rem;
  padding-right: 0.45rem;
}

#proformaTotalesExpediente .form-control {
  text-align: center;
}

.proforma-general-block {
  padding: 0.75rem 0.25rem;
}

@media (max-width: 991.98px) {

  #expedienteProformaModal .modal-content,
  #expedienteProformaModal form {
    max-height: 100vh;
  }

  .proforma-sticky-summary {
    top: 0;
  }

  .proforma-total-grid,
  .proforma-owner-main,
  .proforma-owner-identity,
  .proforma-owner-amounts,
  .proforma-owner-extra {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .proforma-empty-cell {
    display: none;
  }
}


.proforma-otorgante-card .card-body {
  padding: 0.9rem;
}

.proforma-total-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(100px, 1fr));
  gap: 0.5rem;
}

.proforma-otorgante-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.proforma-owner-line {
  display: grid;
  gap: 0.5rem;
  align-items: end;
}

.proforma-owner-main {
  grid-template-columns:
    minmax(82px, 0.8fr) minmax(220px, 3fr) minmax(82px, 0.8fr) minmax(95px, 1fr) minmax(105px, 1fr) minmax(105px, 1fr) minmax(105px, 1fr);
}

.proforma-owner-identity {
  grid-template-columns: minmax(260px, 5fr) minmax(120px, 2fr) minmax(260px, 5fr);
}

.proforma-owner-amounts {
  grid-template-columns:
    minmax(110px, 1fr) minmax(130px, 1fr) minmax(110px, 1fr) minmax(90px, 0.8fr) minmax(90px, 0.8fr);
}

.proforma-owner-extra {
  grid-template-columns: minmax(260px, 5fr) minmax(120px, 2fr) minmax(120px, 2fr) minmax(180px, 3fr);
}

.proforma-empty-cell {
  min-height: 1px;
}

#proformaTexto,
#proformaNotas {
  min-height: 5.25rem;
}

/* Ajustes Proforma v5 */
#proformaTotalesExpediente .form-control.proforma-total-ok {
  background-color: #b7f7c1;
  border-color: #198754;
  color: #0f5132;
}

#proformaTotalesExpediente .form-control.proforma-total-mismatch {
  background-color: #f8d7da;
  border-color: #f1aeb5;
}



.proforma-percentage-cell .form-label {
  color: #084298;
}

.proforma-percentage-input {
  width: 100%;
  text-align: center;
  background-color: #d9ecff;
  border-color: #000;
}

.proforma-owner-identity {
  grid-template-columns: minmax(260px, 6fr) minmax(82px, 0.8fr) minmax(300px, 5.2fr);
}

.proforma-owner-amounts {
  grid-template-columns:
    minmax(110px, 1fr) minmax(130px, 1fr) minmax(110px, 1fr) minmax(90px, 0.8fr) minmax(90px, 0.8fr);
}

#proformaOtorgantesContainer input[readonly][data-proforma-field^="importe_iva"],
#proformaOtorgantesContainer input[readonly][data-proforma-field="importe_irpf"],
#proformaOtorgantesContainer input[readonly][data-proforma-field="importe_subtotal"],
#proformaOtorgantesContainer input[readonly][data-proforma-field="importe_iva"],
#proformaOtorgantesContainer input[readonly][data-proforma-field="importe_total"],
#proformaOtorgantesContainer input.proforma-readonly-field[readonly] {
  background-color: #d8dde3;
  border-color: #b8c0cc;
  color: #495057;
  cursor: not-allowed;
}

/* Ajustes Proforma v10: centrar importes por otorgante */
#proformaOtorgantesContainer input[data-proforma-field="importe_registro"],
#proformaOtorgantesContainer input[data-proforma-field="importe_ayuntamiento"],
#proformaOtorgantesContainer input[data-proforma-field="importe_notaria"],
#proformaOtorgantesContainer input[data-proforma-field="importe_honorarios"],
#proformaOtorgantesContainer input[data-proforma-field="importe_iva_honorarios"],
#proformaOtorgantesContainer input[data-proforma-field="tipo_irpf"],
#proformaOtorgantesContainer input[data-proforma-field="importe_irpf"],
#proformaOtorgantesContainer input[data-proforma-field="importe_subtotal"],
#proformaOtorgantesContainer input[data-proforma-field="importe_iva"],
#proformaOtorgantesContainer input[data-proforma-field="importe_a_cuenta"],
#proformaOtorgantesContainer input[data-proforma-field="importe_total"],
#proformaOtorgantesContainer input[data-proforma-field="importe_otros"],
#proformaOtorgantesContainer input[data-proforma-field="importe_iva_otros"],
#proformaOtorgantesContainer input[data-proforma-field="importe_varios"],
#proformaOtorgantesContainer input[data-proforma-field="importe_iva_varios"] {
  text-align: center;
}

/* Proforma: conceptos de registros por otorgante */
.proforma-registros-block {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.proforma-registros-line {
  grid-template-columns: minmax(240px, 2fr) minmax(140px, .8fr) !important;
}

.proforma-registros-line .proforma-readonly-field {
  background-color: #d7dde3;
}

/* Proforma v9: compactar filas de registros/ayuntamientos */
.proforma-registros-block {
  gap: .18rem;
}

.proforma-registros-line {
  margin-bottom: 0;
}

.proforma-registros-line .form-label {
  margin-bottom: .15rem;
}


/* Proforma v10: compactar aun mas filas de Registros/Ayuntamientos */
.proforma-registros-block {
  gap: 0 !important;
  margin-top: -0.15rem;
}

.proforma-registros-line {
  gap: 0.35rem !important;
  margin-bottom: 0 !important;
  align-items: end;
}

.proforma-registros-line .form-label {
  margin-bottom: 0.05rem !important;
  line-height: 1.05;
}

.proforma-registros-line .form-control {
  min-height: 30px;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}

/* Proforma v11: Notaría pasa a conceptos y se compacta la cabecera principal */
.proforma-owner-main {
  grid-template-columns:
    minmax(82px, 0.7fr) minmax(210px, 2.4fr) minmax(78px, 0.7fr) minmax(90px, 0.8fr) minmax(100px, 0.9fr) minmax(90px, 0.8fr) minmax(100px, 0.9fr) minmax(100px, 0.9fr);
}

.proforma-registros-block {
  gap: 0 !important;
  margin-top: -0.25rem;
}

.proforma-registros-line .form-control {
  min-height: 28px;
  padding-top: 0.15rem;
  padding-bottom: 0.15rem;
}


/* Proforma v12: conceptos Registros/Ayuntamientos/Notaria/Varios mas compactos */
.proforma-registros-block {
  gap: 0 !important;
  margin-top: -0.35rem !important;
  margin-bottom: 0 !important;
}

.proforma-registros-line {
  gap: 0.25rem !important;
  margin-top: 0 !important;
  margin-bottom: -0.08rem !important;
  align-items: end !important;
}

.proforma-registros-line .form-label {
  margin-bottom: 0 !important;
  line-height: 1 !important;
}

.proforma-registros-line .form-control {
  min-height: 26px !important;
  padding-top: 0.1rem !important;
  padding-bottom: 0.1rem !important;
}

/* Proforma v14: OTROS/HONORARIOS muestran tipo IVA e importe IVA como conceptos */
.proforma-conceptos-iva-line {
  grid-template-columns: minmax(240px, 2fr) minmax(140px, .8fr) minmax(110px, .55fr) minmax(130px, .7fr) !important;
}


/* Proforma v15: SUBTOTAL + IVA en totales y cabecera por otorgante */
#proformaTotalesExpediente.proforma-total-grid {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

#proformaOtorgantesContainer input[data-proforma-field="importe_subtotal"],
#proformaOtorgantesContainer input[data-proforma-field="importe_iva"] {
  background-color: #d8dde3;
  border-color: #b8c0cc;
  color: #495057;
  cursor: not-allowed;
  text-align: center;
}

/* Proforma v16: ajuste de anchuras para totales y cabecera por otorgante */
#expedienteProformaModal .modal-xl {
  --bs-modal-width: min(1320px, 96vw);
}

#proformaTotalesExpediente.proforma-total-grid {
  grid-template-columns: repeat(10, minmax(82px, 1fr)) !important;
  gap: 0.28rem !important;
}

#proformaTotalesExpediente .proforma-total-cell .form-label {
  font-size: 0.72rem;
  line-height: 1;
  margin-bottom: 0.12rem;
  white-space: nowrap;
}

#proformaTotalesExpediente .form-control {
  font-size: 0.78rem;
  min-height: 30px;
  padding: 0.18rem 0.24rem;
}

.proforma-owner-main {
  grid-template-columns:
    minmax(64px, 0.52fr) minmax(270px, 2.9fr) minmax(64px, 0.52fr) minmax(86px, 0.75fr) minmax(92px, 0.82fr) minmax(82px, 0.72fr) minmax(92px, 0.82fr) minmax(92px, 0.82fr) !important;
  gap: 0.35rem !important;
}

.proforma-owner-main .form-label {
  font-size: 0.74rem;
  line-height: 1;
  margin-bottom: 0.12rem;
  white-space: nowrap;
}

.proforma-owner-main .form-control {
  font-size: 0.8rem;
  min-height: 30px;
  padding-left: 0.24rem;
  padding-right: 0.24rem;
}

.proforma-owner-main .proforma-percentage-input,
.proforma-owner-main input[data-proforma-field="tipo_irpf"] {
  padding-left: 0.12rem;
  padding-right: 0.12rem;
}

.proforma-registros-line {
  grid-template-columns: minmax(320px, 2.6fr) minmax(110px, .7fr) !important;
}

.proforma-conceptos-iva-line {
  grid-template-columns: minmax(320px, 2.7fr) minmax(105px, .65fr) minmax(82px, .45fr) minmax(105px, .65fr) !important;
}


/* Proforma v17: layout de conceptos en dos columnas y orden IVA antes del importe */
#proformaOtorgantesContainer .proforma-otorgante-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 0.55rem 0.75rem !important;
}

#proformaOtorgantesContainer .proforma-owner-main {
  grid-column: 1 / -1;
}

#proformaOtorgantesContainer .proforma-registros-block {
  min-width: 0;
}

#proformaOtorgantesContainer .proforma-registros-line {
  grid-template-columns: minmax(0, 2.4fr) minmax(92px, 0.75fr) !important;
}

#proformaOtorgantesContainer .proforma-conceptos-iva-line {
  grid-template-columns: minmax(0, 2.5fr) minmax(72px, 0.48fr) minmax(92px, 0.68fr) minmax(92px, 0.68fr) !important;
}

@media (max-width: 1100px) {
  #proformaOtorgantesContainer .proforma-otorgante-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Proforma v18: igualar ancho de campos de importes en conceptos por otorgante */
#proformaOtorgantesContainer .proforma-registros-line {
  grid-template-columns: minmax(0, 1fr) 100px !important;
}

#proformaOtorgantesContainer .proforma-conceptos-iva-line {
  grid-template-columns: minmax(0, 1fr) 74px 92px 100px !important;
}

#proformaOtorgantesContainer .proforma-registros-line>div:last-child .form-control,
#proformaOtorgantesContainer .proforma-conceptos-iva-line>div:last-child .form-control {
  width: 100%;
  text-align: center;
}

#proformaOtorgantesContainer .proforma-conceptos-iva-line>div:first-child .form-control {
  min-width: 0;
}

/* Configuración: Datos de Factura/Proforma */
#datosFacturaProformaModal {
  z-index: 1145;
}

.datos-factura-proforma-backdrop {
  z-index: 1140 !important;
}

#datosFacturaProformaModal .modal-dialog {
  max-width: min(760px, calc(100vw - 2rem));
}

#datosFacturaProformaModal .modal-body .row.g-3 {
  --bs-gutter-y: .75rem;
}

#datosFacturaProformaModal .modal-footer .btn {
  min-width: 110px;
}

/* Frame de filtros de facturación en Expedientes */
.expediente-facturacion-filter-frame {
  border: 1px solid rgba(13, 110, 253, 0.25);
  border-radius: 0.65rem;
  padding: 0.55rem 0.75rem 0.65rem;
  background: rgba(13, 110, 253, 0.035);
}

.expediente-facturacion-filter-frame legend {
  float: none;
  width: auto;
  margin: 0 0 0.25rem;
  padding: 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #0d6efd;
}

.btn-action-disabled {
  opacity: 0.45;
  cursor: not-allowed !important;
  pointer-events: none;
}

#expedienteModal.expediente-readonly-mode .modal-body input:not([type="hidden"]),
#expedienteModal.expediente-readonly-mode .modal-body textarea,
#expedienteModal.expediente-readonly-mode .modal-body select,
#expedienteProformaModal.proforma-readonly-mode .modal-body input:not([type="hidden"]),
#expedienteProformaModal.proforma-readonly-mode .modal-body textarea,
#expedienteProformaModal.proforma-readonly-mode .modal-body select {
  background-color: #d9dde3 !important;
  pointer-events: none;
}


/* Ajustes visuales toolbar/listado Expedientes */
[data-page="expedientes"] .expediente-toolbar-row {
  align-items: center !important;
}

[data-page="expedientes"] .expediente-search-group,
[data-page="expedientes"] .expediente-facturacion-filter-frame,
[data-page="expedientes"] .expediente-new-btn {
  align-self: center;
}

[data-page="expedientes"] .expediente-new-btn {
  min-height: 38px;
  height: 38px;
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

[data-page="expedientes"] .btn-expediente-delete-disabled,
[data-page="expedientes"] .btn-expediente-delete-disabled:disabled {
  color: #6c757d !important;
  border-color: #adb5bd !important;
  background-color: #e9ecef !important;
  opacity: 1 !important;
}


/* Ajustes finales de alineación y acciones en Expedientes */
[data-page="expedientes"] .expediente-toolbar-row > [class*="col-"] {
  display: flex;
  align-items: center !important;
}

[data-page="expedientes"] .expediente-filter-col {
  min-height: 38px;
}

[data-page="expedientes"] .expediente-facturacion-filter-frame {
  position: relative;
  min-height: 48px;
  height: 48px;
  margin: 0;
  padding: 0.45rem 0.75rem 0.35rem;
  display: flex;
  align-items: center;
}

[data-page="expedientes"] .expediente-facturacion-filter-frame legend {
  position: absolute;
  top: -0.62rem;
  left: 0.75rem;
  margin: 0;
  background: #fff;
  line-height: 1;
}

[data-page="expedientes"] .expediente-facturacion-checks {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin-top: 0;
}

[data-page="expedientes"] .expediente-facturacion-checks .form-check {
  display: flex;
  align-items: center;
  min-height: 24px;
}

[data-page="expedientes"] .expediente-facturacion-checks .form-check-input {
  margin-top: 0;
}

[data-page="expedientes"] .col-acciones .btn {
  width: 34px;
  min-width: 34px;
  height: 31px;
  padding-left: 0;
  padding-right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

[data-page="expedientes"] .btn-expediente-proforma {
  width: 34px !important;
  min-width: 34px !important;
}

[data-page="expedientes"] .btn-expediente-delete-disabled,
[data-page="expedientes"] .btn-expediente-delete-disabled:disabled {
  color: #6c757d !important;
  border-color: #adb5bd !important;
  background-color: #e9ecef !important;
  opacity: 1 !important;
}


/* Ajustes v10: filtro facturación más ancho y submodales con scroll vertical */
[data-page="expedientes"] .expediente-filter-col {
  min-width: 430px;
}

[data-page="expedientes"] .expediente-facturacion-filter-frame {
  min-width: 410px;
}

[data-page="expedientes"] .expediente-facturacion-checks {
  flex-wrap: nowrap;
  justify-content: center;
  gap: 1.25rem;
}

[data-page="expedientes"] .expediente-facturacion-checks .form-check {
  white-space: nowrap;
}

@media (max-width: 991.98px) {
  [data-page="expedientes"] .expediente-filter-col,
  [data-page="expedientes"] .expediente-facturacion-filter-frame {
    min-width: 0;
    width: 100%;
  }

  [data-page="expedientes"] .expediente-facturacion-checks {
    flex-wrap: wrap;
  }
}

#expedienteRegistrosModal .modal-content,
#expedienteAyuntamientosModal .modal-content,
#expedienteVariosModal .modal-content,
#expedienteOtorgantesModal .modal-content {
  max-height: calc(100vh - 1rem);
  display: flex;
  flex-direction: column;
}

#expedienteRegistrosModal .modal-body,
#expedienteAyuntamientosModal .modal-body,
#expedienteVariosModal .modal-body,
#expedienteOtorgantesModal .modal-body {
  overflow-y: auto !important;
  max-height: calc(100vh - 9rem) !important;
  min-height: 0;
}

#expedienteRegistrosModal .modal-header,
#expedienteRegistrosModal .modal-footer,
#expedienteAyuntamientosModal .modal-header,
#expedienteAyuntamientosModal .modal-footer,
#expedienteVariosModal .modal-header,
#expedienteVariosModal .modal-footer,
#expedienteOtorgantesModal .modal-header,
#expedienteOtorgantesModal .modal-footer {
  flex-shrink: 0;
}

/* Ajuste: filtro facturación pegado al botón Nuevo Expediente en listado */
[data-page="expedientes"] .expediente-actions-col {
  gap: 0.5rem;
}

[data-page="expedientes"] .expediente-search-group {
  width: 100%;
}

[data-page="expedientes"] .expediente-actions-col .expediente-facturacion-filter-frame {
  width: auto;
  flex: 1 1 auto;
  min-width: 285px;
}

[data-page="expedientes"] .expediente-actions-col .expediente-new-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

[data-page="expedientes"] .expediente-actions-col .expediente-facturacion-checks {
  justify-content: flex-end;
  gap: 0.75rem;
  font-size: 0.82rem;
  white-space: nowrap;
}

@media (max-width: 767.98px) {
  [data-page="expedientes"] .expediente-actions-col {
    gap: 0.5rem;
  }

  [data-page="expedientes"] .expediente-actions-col .expediente-facturacion-filter-frame,
  [data-page="expedientes"] .expediente-actions-col .expediente-new-btn {
    width: 100%;
    min-width: 0;
  }

  [data-page="expedientes"] .expediente-actions-col .expediente-facturacion-checks {
    justify-content: center;
  }
}


/* Ajuste v12: ampliar frame de facturación para evitar solapes */
[data-page="expedientes"] .expediente-actions-col {
  flex-wrap: nowrap;
}

[data-page="expedientes"] .expediente-actions-col .expediente-facturacion-filter-frame {
  flex: 0 0 430px;
  width: 430px;
  min-width: 430px;
  min-height: 48px;
  height: 48px;
  padding: 0.45rem 1rem 0.35rem;
}

[data-page="expedientes"] .expediente-actions-col .expediente-facturacion-checks {
  justify-content: center;
  gap: 1.15rem;
  font-size: 0.9rem;
}

[data-page="expedientes"] .expediente-actions-col .expediente-facturacion-checks .form-check {
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 991.98px) {
  [data-page="expedientes"] .expediente-actions-col {
    flex-wrap: wrap;
  }

  [data-page="expedientes"] .expediente-actions-col .expediente-facturacion-filter-frame {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 48px;
  }
}


/* Ajuste facturación: color propio para acciones de Facturar y diferenciación visual */
.btn-facturar,
.btn-outline-facturar:hover,
.btn-outline-facturar:focus {
  color: #fff !important;
  background-color: #A52A2A !important;
  border-color: #A52A2A !important;
}

.btn-facturar:hover,
.btn-facturar:focus {
  background-color: #8B2323 !important;
  border-color: #8B2323 !important;
  color: #fff !important;
}

.btn-outline-facturar {
  color: #A52A2A !important;
  border-color: #A52A2A !important;
  background-color: transparent !important;
}

.btn-factura {
  color: #fff !important;
  background-color: #A52A2A !important;
  border-color: #A52A2A !important;
}

.btn-factura:hover,
.btn-factura:focus {
  color: #fff !important;
  background-color: #8B2323 !important;
  border-color: #8B2323 !important;
}

.btn-outline-factura {
  color: #A52A2A !important;
  background-color: #fff !important;
  border-color: #A52A2A !important;
}

.btn-outline-factura:hover,
.btn-outline-factura:focus {
  color: #fff !important;
  background-color: #A52A2A !important;
  border-color: #A52A2A !important;
}

[data-page="facturas"] .col-acciones .btn {
  min-width: 34px;
  height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

[data-page="facturas"] .facturas-otorgante-col {
  min-width: 240px;
}

[data-page="expedientes"] .col-acciones .btn {
  min-width: 34px;
  height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

[data-page="expedientes"] .col-acciones .btn-expediente-facturar,
[data-page="expedientes"] .col-acciones .btn-expediente-ver-factura {
  min-width: 42px;
}

[data-page="expedientes"] .col-acciones .btn-expediente-delete-disabled,
[data-page="expedientes"] .col-acciones .btn-action-disabled {
  color: #8b949e !important;
  background-color: #e9ecef !important;
  border-color: #ced4da !important;
  opacity: 1 !important;
  cursor: not-allowed !important;
}


/* Ajuste facturación v2: más espacio para 4 botones en acciones y menos descripción */
[data-page="expedientes"] .col-acciones {
  width: 215px !important;
  min-width: 215px !important;
  max-width: 215px !important;
  white-space: nowrap;
}

[data-page="expedientes"] .table-crud th:nth-child(2),
[data-page="expedientes"] .table-crud td:nth-child(2) {
  width: 32% !important;
}

[data-page="expedientes"] .table-crud th:nth-child(4),
[data-page="expedientes"] .table-crud td:nth-child(4) {
  width: 22% !important;
}

[data-page="expedientes"] .col-acciones .btn {
  margin-right: 0.25rem !important;
}

[data-page="expedientes"] .col-acciones .btn:last-child {
  margin-right: 0 !important;
}

[data-page="expedientes"] .col-acciones .btn-expediente-facturar,
[data-page="expedientes"] .col-acciones .btn-expediente-ver-factura,
[data-page="expedientes"] .col-acciones .btn-expediente-proforma {
  min-width: 44px !important;
  width: 44px !important;
}

[data-page="facturas"] .col-acciones {
  width: 220px !important;
  min-width: 220px !important;
  max-width: 220px !important;
  white-space: nowrap;
}


[data-page="facturas"] td.col-acciones {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.35rem;
}

[data-page="facturas"] td.col-acciones .btn {
  margin-right: 0 !important;
  flex: 0 0 auto;
}

[data-page="facturas"] .table-crud .btn.btn-sm {
  width: 34px;
  min-width: 34px;
  height: 31px;
  padding-left: 0;
  padding-right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Ajuste Facturas: botones Ver Factura / Ver Proforma con fondo de color, icono blanco y hover común */
[data-page="facturas"] .btn-factura-print,
[data-page="facturas"] .btn-factura-proforma {
  color: #ffffff !important;
  border-radius: 0.55rem;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

[data-page="facturas"] .btn-factura-print i,
[data-page="facturas"] .btn-factura-proforma i {
  color: #ffffff !important;
}

[data-page="facturas"] .btn-factura-print:hover,
[data-page="facturas"] .btn-factura-print:focus,
[data-page="facturas"] .btn-factura-proforma:hover,
[data-page="facturas"] .btn-factura-proforma:focus {
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.20);
}

[data-page="facturas"] .btn-factura-print:hover,
[data-page="facturas"] .btn-factura-print:focus {
  background-color: #8B2323 !important;
  border-color: #8B2323 !important;
}

[data-page="facturas"] .btn-factura-proforma:hover,
[data-page="facturas"] .btn-factura-proforma:focus {
  background-color: #157347 !important;
  border-color: #146c43 !important;
}


/* =========================================================
   Ajuste Facturas: buscador con el mismo comportamiento CRUD común
   ========================================================= */
[data-page="facturas"] .input-group {
  transition: all 0.2s ease;
}

[data-page="facturas"] .input-group-text {
  background-color: #f1f5f9;
  border-right: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  border-radius: 6px 0 0 6px;
}

[data-page="facturas"] .input-group .form-control {
  border-left: 0;
  border-radius: 0 6px 6px 0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

[data-page="facturas"] .input-group:has(.btn-clear-search:not(.hidden)) .form-control {
  border-right: 0;
  border-radius: 0;
}

[data-page="facturas"] .input-group:focus-within .input-group-text i {
  color: #0d6efd;
}

[data-page="facturas"] .form-control:focus {
  box-shadow: none;
}

[data-page="facturas"] .input-group:focus-within .input-group-text {
  background-color: #e9f3ff;
  border-color: #86b7fe;
}

[data-page="facturas"] .input-group:focus-within .form-control {
  border-color: #86b7fe;
  background-color: #fcfeff;
}

[data-page="facturas"] .input-group:focus-within .btn-clear-search {
  background-color: #e9f3ff;
  border-color: #86b7fe;
  color: #0d6efd;
}

[data-page="facturas"] .btn-clear-search {
  border-left: 0;
  background-color: #f1f5f9;
  color: #6c757d;
  padding: 0 10px;
  display: flex;
  align-items: center;
  border-radius: 0 6px 6px 0;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

[data-page="facturas"] .btn-clear-search:hover {
  background-color: #dbeafe;
  color: #0b5ed7;
}

[data-page="facturas"] .btn-clear-search:focus {
  box-shadow: none;
}

[data-page="facturas"] .btn-clear-search.hidden {
  display: none !important;
}

/* =========================================================
   Ajuste Expedientes: textos abreviados y frame de facturación compacto
   ========================================================= */
[data-page="expedientes"] .expediente-actions-col .expediente-facturacion-filter-frame {
  flex: 0 0 320px;
  width: 320px;
  min-width: 320px;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

[data-page="expedientes"] .expediente-actions-col .expediente-facturacion-checks {
  gap: 0.85rem;
  font-size: 0.88rem;
}

[data-page="expedientes"] .expediente-actions-col .expediente-facturacion-checks .form-check-label {
  white-space: nowrap;
}

@media (max-width: 991.98px) {
  [data-page="expedientes"] .expediente-actions-col .expediente-facturacion-filter-frame {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }
}


/* Filtros de facturas: mismo formato que Expedientes / Filtro facturación */
[data-page="facturas"] .facturas-filter-col {
  min-height: 48px;
}

[data-page="facturas"] .facturas-tipo-filter-frame {
  position: relative;
  flex: 0 0 320px;
  width: 320px;
  min-width: 320px;
  min-height: 48px;
  height: 48px;
  margin: 0;
  padding: 0.45rem 0.75rem 0.35rem;
  display: flex;
  align-items: center;
}

[data-page="facturas"] .facturas-tipo-filter-frame legend {
  position: absolute;
  top: -0.62rem;
  left: 0.75rem;
  margin: 0;
  background: #fff;
  line-height: 1;
}

[data-page="facturas"] .facturas-tipo-checks {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin-top: 0;
  font-size: 0.88rem;
}

[data-page="facturas"] .facturas-tipo-checks .form-check {
  display: flex;
  align-items: center;
  min-height: 24px;
}

[data-page="facturas"] .facturas-tipo-checks .form-check-input {
  margin-top: 0;
}

[data-page="facturas"] .facturas-tipo-checks .form-check-label {
  white-space: nowrap;
}

@media (max-width: 991.98px) {
  [data-page="facturas"] .facturas-tipo-filter-frame {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }
}

/* Configuración: panel tipo Home */
.configuracion-dashboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: start;
}

.configuracion-card {
  min-height: 0;
  gap: 10px;
  padding: 16px;
  align-self: start;
}

.configuracion-card-heading {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 4px;
}

.configuracion-card .summary-label {
  color: #10385d;
  font-size: 1.08rem;
  font-weight: 800;
  margin-bottom: 0;
}

.configuracion-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(58, 160, 227, 0.10);
  color: #0f3f6f;
  font-size: 1.25rem;
}

.configuracion-card .summary-link-btn {
  margin-top: 0;
}

.configuracion-main-btn {
  justify-content: center;
  width: 100%;
  min-height: 50px;
  padding: 8px 14px;
  border-radius: 15px;
  border: 1px solid rgb(197, 62, 35);
  background: linear-gradient(135deg, rgb(227, 83, 54) 0%, rgb(197, 62, 35) 100%);
  color: #ffffff;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.15;
  box-shadow: 0 10px 20px rgba(227, 83, 54, 0.18);
}

.configuracion-main-btn:hover,
.configuracion-main-btn:focus {
  border-color: rgb(176, 52, 29);
  background: linear-gradient(135deg, rgb(197, 62, 35) 0%, rgb(166, 48, 26) 100%);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(227, 83, 54, 0.24);
}

.configuracion-main-btn i {
  color: #ffffff;
  font-size: 1.12rem;
}


/* Botones de acciones compactos con fondo e icono blanco */
.col-acciones .btn-primary,
.col-acciones .btn-danger,
.table-crud .btn-editar,
.table-crud .btn-eliminar,
.table-crud .tipo-documento-editar-btn,
.table-crud .tipo-documento-eliminar-btn,
.table-crud [data-registro-edit],
.table-crud [data-registro-delete],
.table-crud [data-ayuntamiento-edit],
.table-crud [data-ayuntamiento-delete],
.table-crud [data-varios-edit],
.table-crud [data-varios-delete],
.table-crud [data-otorgante-edit],
.table-crud [data-otorgante-delete],
.table-crud .btn-factura-expediente,
.table-crud .btn-factura-anular {
  min-width: 34px;
  height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.55rem;
}

.col-acciones .btn-primary i,
.col-acciones .btn-danger i,
.table-crud .btn-primary i,
.table-crud .btn-danger i,
.table-crud .btn-editar i,
.table-crud .btn-eliminar i,
.table-crud .tipo-documento-editar-btn i,
.table-crud .tipo-documento-eliminar-btn i {
  color: #fff;
}

/* Confirmación de eliminación de Tipo de Documento */
#confirmDeleteTipoDocumentoModal .modal-content {
  border: 0;
  border-radius: 0.9rem;
  overflow: hidden;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.28);
}

#confirmDeleteTipoDocumentoModal .modal-header {
  background: linear-gradient(135deg, #1f5f97 0%, #164f82 100%);
  color: #ffffff;
  border-bottom: 0;
  padding: 1rem 1.1rem;
}

#confirmDeleteTipoDocumentoModal .modal-title {
  color: #ffffff;
  font-weight: 800;
}

#confirmDeleteTipoDocumentoModal .modal-body {
  color: #18314f;
  padding: 1rem 1.1rem;
}

#confirmDeleteTipoDocumentoModal .confirm-delete-warning {
  color: #dc3545;
  font-weight: 800;
}

#confirmDeleteTipoDocumentoModal .modal-footer {
  background: #ffffff;
  border-top: 1px solid #dce3ec;
  padding: 0.95rem 1rem;
}

#confirmDeleteTipoDocumentoModal .btn-danger {
  background: #dc3545;
  border-color: #dc3545;
  color: #ffffff;
  font-weight: 700;
}

/* Tipo de IVA: campo valor más compacto */
.tipo-iva-modal .tipo-iva-valor-col {
  max-width: 110px;
}
.tipo-iva-modal .tipo-iva-valor-th,
.tipo-iva-modal .tipo-iva-valor-cell {
  width: 90px;
  white-space: nowrap;
}

/* Botón para añadir Tipo de Documento junto al select de Expedientes */
.expediente-tipo-documento-select-wrap .form-select {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.expediente-tipo-documento-select-wrap #expedienteAddTipoDocumentoBtn {
  min-width: 42px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  color: #111827;
  border-color: #111827;
  background-color: #fff;
}

.expediente-tipo-documento-select-wrap .form-select:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .18);
}

/* Al enfocar el select solo se marca el borde y el icono, sin simular click/hover del botón. */
.expediente-tipo-documento-select-wrap .form-select:focus + #expedienteAddTipoDocumentoBtn {
  color: #0d6efd;
  border-color: #0d6efd;
  background-color: #fff;
  box-shadow: none;
}

.expediente-tipo-documento-select-wrap #expedienteAddTipoDocumentoBtn:hover,
.expediente-tipo-documento-select-wrap #expedienteAddTipoDocumentoBtn:focus,
.expediente-tipo-documento-select-wrap #expedienteAddTipoDocumentoBtn:active {
  color: #fff;
  background-color: #0d6efd;
  border-color: #0d6efd;
  cursor: pointer;
}

/* Botón para añadir Tipo de IVA junto al select de Importes de Varios */
.expediente-tipo-iva-select-wrap .form-select {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.expediente-tipo-iva-select-wrap #expedienteAddTipoIvaBtn {
  min-width: 42px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  color: #111827;
  border-color: #111827;
  background-color: #fff;
}

.expediente-tipo-iva-select-wrap .form-select:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .18);
}

/* Al enfocar el select solo se marca el borde y el icono, sin simular click/hover del botón. */
.expediente-tipo-iva-select-wrap .form-select:focus + #expedienteAddTipoIvaBtn {
  color: #0d6efd;
  border-color: #0d6efd;
  background-color: #fff;
  box-shadow: none;
}


/* Select de Tipo de IVA en Importes de Varios: más compacto */
.expediente-tipo-iva-select-wrap {
  max-width: 150px;
}

.expediente-tipo-iva-select-wrap #expedienteVariosTipoIva {
  flex: 0 0 100px;
  max-width: 100px;
}

.expediente-tipo-iva-select-wrap #expedienteAddTipoIvaBtn:hover,
.expediente-tipo-iva-select-wrap #expedienteAddTipoIvaBtn:focus,
.expediente-tipo-iva-select-wrap #expedienteAddTipoIvaBtn:active {
  color: #fff;
  background-color: #0d6efd;
  border-color: #0d6efd;
  cursor: pointer;
}

/* Importes de Varios: el bloque IVA no debe ocupar una columna completa para que Fecha Pago quede junto al selector. */
#expedienteVariosTipoIvaGroup {
  width: auto;
}

/* Ajustes Gestión de Usuarios - Configuración */
.gestion-usuarios-modal .gestion-usuarios-form-row .form-control,
.gestion-usuarios-modal .gestion-usuarios-form-row .form-select,
.gestion-usuarios-modal .gestion-usuarios-form-row .btn {
  min-height: 38px;
}

.gestion-usuarios-modal #gestionUsuarioGuardarBtn {
  min-height: 38px;
  white-space: nowrap;
}

.gestion-usuarios-modal .gestion-usuarios-col-acciones,
.gestion-usuarios-modal .col-acciones {
  width: 190px;
  min-width: 190px;
  max-width: 190px;
}

.gestion-usuarios-modal .gestion-usuarios-col-rol {
  width: 95px;
  min-width: 95px;
  max-width: 115px;
  white-space: nowrap;
}

.gestion-usuarios-modal .gestion-usuarios-col-activo {
  width: 78px;
  min-width: 78px;
  max-width: 78px;
  white-space: nowrap;
}

.gestion-usuarios-modal .gestion-usuarios-col-acciones .btn {
  min-width: 34px;
  height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.55rem;
  margin-left: 0.15rem;
}

.gestion-usuarios-modal .gestion-usuarios-col-acciones .btn i {
  color: #ffffff;
}

/* Ajuste layout y botón password - Gestión de Usuarios */
.gestion-usuarios-modal .gestion-usuario-guardar-col {
  max-width: 170px;
}

.gestion-usuarios-modal #gestionUsuarioGuardarBtn {
  padding-left: 0.85rem !important;
  padding-right: 0.85rem !important;
  min-width: 132px;
}

.gestion-usuarios-modal .gestion-usuario-username-col {
  flex: 0 0 34%;
  max-width: 34%;
}

.gestion-usuarios-modal .gestion-usuario-password-col {
  flex: 0 0 24%;
  max-width: 24%;
}

.gestion-usuarios-modal .gestion-usuario-password-group {
  border-radius: 0.55rem;
  transition: box-shadow 0.18s ease;
}

.gestion-usuarios-modal .gestion-usuario-password-group .form-control {
  border-right: 0;
  box-shadow: none !important;
}

.gestion-usuarios-modal .gestion-usuario-password-eye-btn {
  min-height: 38px;
  min-width: 44px;
  border: 1px solid #1f2937 !important;
  border-left: 0 !important;
  border-radius: 0 0.55rem 0.55rem 0;
  background: #ffffff !important;
  color: #1f2937 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none !important;
  outline: 0 !important;
  transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.gestion-usuarios-modal .gestion-usuario-password-eye-btn i {
  color: #1f2937 !important;
  transition: color 0.18s ease;
}

.gestion-usuarios-modal .gestion-usuario-password-eye-btn:hover {
  background: #eaf3ff !important;
  color: #0d6efd !important;
}

.gestion-usuarios-modal .gestion-usuario-password-eye-btn:hover i {
  color: #0d6efd !important;
}

.gestion-usuarios-modal .gestion-usuario-password-group:focus-within {
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.gestion-usuarios-modal .gestion-usuario-password-group:focus-within .form-control,
.gestion-usuarios-modal .gestion-usuario-password-group:focus-within .gestion-usuario-password-eye-btn {
  border-color: #86b7fe !important;
}

.gestion-usuarios-modal .gestion-usuario-password-group:focus-within .gestion-usuario-password-eye-btn {
  background: #ffffff !important;
  box-shadow: none !important;
}

.gestion-usuarios-modal .gestion-usuario-password-group:focus-within .gestion-usuario-password-eye-btn:hover {
  background: #eaf3ff !important;
}

.gestion-usuarios-modal .gestion-usuario-password-eye-btn:disabled {
  background: #f3f4f6 !important;
  border-color: #ced4da !important;
  cursor: not-allowed;
  opacity: 0.65;
}

.gestion-usuarios-modal .gestion-usuario-password-eye-btn:disabled i {
  color: #6c757d !important;
}

@media (max-width: 991.98px) {
  .gestion-usuarios-modal .gestion-usuario-username-col,
  .gestion-usuarios-modal .gestion-usuario-password-col {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* =========================================================
   Configuración v07: tarjetas compactas por contenido
   - Evita que todas las tarjetas hereden la altura de la más alta
   - Agrupa los botones justo debajo del título
   ========================================================= */
[data-page="configuracion"] .configuracion-dashboard-grid {
  align-items: start !important;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

[data-page="configuracion"] .configuracion-card {
  min-height: 0 !important;
  height: auto !important;
  padding: 16px !important;
  gap: 12px !important;
  align-self: start !important;
}

[data-page="configuracion"] .configuracion-card-heading {
  margin-bottom: 8px !important;
}

[data-page="configuracion"] .configuracion-card .summary-link-btn,
[data-page="configuracion"] .configuracion-main-btn {
  margin-top: 0 !important;
}

[data-page="configuracion"] .configuracion-main-btn {
  min-height: 54px !important;
  border-radius: 16px !important;
  padding: 0 16px !important;
  font-size: 1rem !important;
}

[data-page="configuracion"] .configuracion-main-btn + .configuracion-main-btn {
  margin-top: 2px !important;
}

[data-page="configuracion"] .configuracion-card-icon {
  width: 42px !important;
  height: 42px !important;
  border-radius: 15px !important;
  font-size: 1.2rem !important;
}

[data-page="configuracion"] .configuracion-card .summary-label {
  font-size: 1.08rem !important;
}

/* Configuración: Prioridades de Impresión - drag & drop */
.prioridades-impresion-modal .modal-dialog {
  max-width: min(820px, calc(100vw - 2rem));
}

.prioridades-impresion-modal .modal-body > .text-muted {
  font-size: 0.98rem;
  margin-bottom: 1rem !important;
}

.prioridad-impresion-item {
  min-height: 64px;
  cursor: grab;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

.prioridad-impresion-item:hover {
  border-color: rgba(13, 110, 253, 0.35) !important;
  box-shadow: 0 8px 18px rgba(15, 57, 105, 0.10);
}

.prioridad-impresion-item.is-dragging {
  opacity: 0.58;
  cursor: grabbing;
  transform: scale(0.99);
  box-shadow: 0 12px 26px rgba(15, 57, 105, 0.20);
}

.prioridad-impresion-main {
  min-width: 0;
}

.prioridad-impresion-index {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #6c757d;
  color: #ffffff;
  font-weight: 800;
  font-size: 0.82rem;
  line-height: 1;
  flex: 0 0 24px;
}

.prioridad-drag-handle {
  width: 18px;
  min-width: 18px;
  color: #5f6b76;
  cursor: grab;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
}

.prioridad-drag-handle:hover {
  color: #0d3b69;
}

.prioridad-impresion-nombre {
  color: #12304f;
  font-size: 0.98rem;
  min-width: 0;
}

.prioridad-impresion-actions .btn:disabled {
  color: #9aa4af !important;
  border-color: #b8c1ca !important;
  background-color: #f8fafc !important;
  opacity: 1;
  cursor: not-allowed;
}

.prioridad-impresion-actions .btn:disabled i {
  color: #9aa4af !important;
}

.prioridades-impresion-modal #guardarPrioridadesImpresionBtn {
  min-width: 118px;
  font-weight: 700;
}

/* =========================================================
   Importes de Varios: evitar salto del selector IVA + botón
   ========================================================= */
#expedienteVariosTipoIvaGroup {
  flex: 0 0 175px !important;
  width: 175px !important;
  max-width: 175px !important;
}

#expedienteVariosModal .expediente-tipo-iva-select-wrap {
  display: inline-flex !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  width: 158px !important;
  max-width: 158px !important;
}

#expedienteVariosModal .expediente-tipo-iva-select-wrap #expedienteVariosTipoIva {
  flex: 0 0 112px !important;
  width: 112px !important;
  max-width: 112px !important;
}

#expedienteVariosModal .expediente-tipo-iva-select-wrap #expedienteAddTipoIvaBtn {
  flex: 0 0 42px !important;
  width: 42px !important;
  max-width: 42px !important;
}
