html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

html {
  position: relative;
  min-height: 100%;
}

/* =========================================================
   Paleta (extraída del diseño de referencia)
   ========================================================= */
:root {
  --app-sidebar-bg: #213c59;
  --app-sidebar-text: #dae6f1;
  --app-sidebar-active-bg: #32506c;
  --app-sidebar-accent: #dda552;
  --app-primary: #315c7f;
  --app-primary-hover: #274a65;
  --app-primary-text: #f7fbfd;
  --app-body-bg: #f7f9fb;
  --app-body-text: #1b2a3a;
  --app-border: #e5e9ee;
  --app-muted: #5a6b7d;
}

body {
  background-color: var(--app-body-bg);
  color: var(--app-body-text);
}

a {
  color: var(--app-primary);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.border-top {
  border-top: 1px solid #e5e5e5;
}

.border-bottom {
  border-bottom: 1px solid #e5e5e5;
}

.box-shadow {
  box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}

button.accept-policy {
  font-size: 1rem;
  line-height: inherit;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* =========================================================
   Layout: menú lateral + barra superior
   ========================================================= */
.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.app-sidebar {
  width: 230px;
  flex-shrink: 0;
  background-color: var(--app-sidebar-bg);
  color: var(--app-sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.75rem;
  transition: width .18s ease;
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0 0.5rem 1.25rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar-brand-icon {
  display: block;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  background-color: var(--app-sidebar-accent);
  object-fit: contain;
  padding: 4px;
}

.app-sidebar-brand-text {
  flex: 1;
  min-width: 0;
}

.app-sidebar-brand-title {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.1;
  color: #fff;
  white-space: nowrap;
}

.app-sidebar-brand-subtitle {
  font-size: 0.75rem;
  opacity: 0.75;
  white-space: nowrap;
}

.app-sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--app-sidebar-text);
  cursor: pointer;
}

.app-sidebar-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.app-sidebar-toggle .app-nav-icon {
  transition: transform .18s ease;
}

/* Sidebar colapsada: solo iconos */
html.sidebar-collapsed .app-sidebar {
  width: 76px;
}

html.sidebar-collapsed .app-sidebar-brand {
  flex-direction: column;
  gap: 0.5rem;
}

html.sidebar-collapsed .app-sidebar-brand-text,
html.sidebar-collapsed .app-nav-link span {
  display: none;
}

html.sidebar-collapsed .app-sidebar-toggle .app-nav-icon {
  transform: rotate(180deg);
}

html.sidebar-collapsed .app-nav-link {
  justify-content: center;
}

.app-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.app-sidebar-nav-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  color: var(--app-sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background-color .15s ease;
}

.app-nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: currentColor;
}

.app-nav-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--app-sidebar-text);
}

.app-nav-link.active {
  background-color: var(--app-sidebar-active-bg);
  color: #fff;
  font-weight: 600;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background-color: #fff;
  border-bottom: 1px solid var(--app-border);
}

.app-topbar-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--app-body-text);
}

.app-topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-topbar-username {
  font-size: 0.85rem;
  color: var(--app-muted);
}

.app-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--app-primary);
  color: var(--app-primary-text);
  font-size: 0.8rem;
  font-weight: 700;
}

.app-logout {
  text-decoration: none;
  color: var(--app-muted) !important;
  padding: 0 !important;
  font-size: 0.85rem;
}

.app-login-link {
  font-weight: 600;
}

.app-content {
  flex: 1;
  padding: 1.5rem;
}

@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
  }

  .app-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 0.75rem 1rem;
  }

  .app-sidebar-brand {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
  }

  .app-sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
  }
}

/* =========================================================
   Checkboxes y switches
   ========================================================= */
.form-check-input {
  cursor: pointer;
  width: 1.15em;
  height: 1.15em;
  margin-top: 0.1em;
}

.form-check-input:checked {
  background-color: var(--app-primary);
  border-color: var(--app-primary);
}

.form-switch .form-check-input {
  width: 2.5em;
  height: 1.35em;
}

.form-check-label {
  cursor: pointer;
  padding-left: 0.15rem;
}

/* =========================================================
   Botones y enlaces
   ========================================================= */
.btn-primary {
  color: var(--app-primary-text);
  background-color: var(--app-primary);
  border-color: var(--app-primary);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
  background-color: var(--app-primary-hover) !important;
  border-color: var(--app-primary-hover) !important;
  color: var(--app-primary-text) !important;
}

.btn-outline-primary {
  color: var(--app-primary);
  border-color: var(--app-primary);
}

.btn-outline-primary:hover {
  background-color: var(--app-primary);
  border-color: var(--app-primary);
  color: var(--app-primary-text);
}

.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
  color: #fff;
  background-color: var(--app-primary);
  border-color: var(--app-primary-hover);
}

/* =========================================================
   Badges de estado (estilo "pill" suave, como en el diseño de referencia)
   ========================================================= */
.badge {
  font-weight: 600;
  border-radius: 999px;
  padding: 0.35em 0.75em;
}

.text-bg-success {
  background-color: #ecfdf5 !important;
  color: #007a55 !important;
}

.text-bg-info {
  background-color: #e0edf8 !important;
  color: #295171 !important;
}

.text-bg-secondary {
  background-color: #eef1f4 !important;
  color: #51606f !important;
}

.text-bg-danger {
  background-color: #fef2f2 !important;
  color: #e7000b !important;
}

.text-bg-warning {
  background-color: #fef6e7 !important;
  color: #92660a !important;
}

/* =========================================================
   Dashboard
   ========================================================= */
.icon-svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: currentColor;
}

.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.dashboard-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.dashboard-header-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.kpi-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.kpi-icon-info {
  background-color: #e0edf8;
  color: #295171;
}

.kpi-icon-success {
  background-color: #ecfdf5;
  color: #007a55;
}

.kpi-icon-warning {
  background-color: #fef6e7;
  color: #92660a;
}

.kpi-icon-danger {
  background-color: #fef2f2;
  color: #e7000b;
}

.dashboard-section-label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--app-muted);
  margin-bottom: 1rem;
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.quick-action-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.5rem;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  color: var(--app-body-text);
  text-decoration: none;
  text-align: center;
  font-size: 0.85rem;
  transition: border-color .15s ease, background-color .15s ease;
}

.quick-action-tile .icon-svg {
  width: 20px;
  height: 20px;
  color: var(--app-primary);
}

.quick-action-tile:hover {
  border-color: var(--app-primary);
  background-color: var(--app-body-bg);
  color: var(--app-body-text);
}

/* =========================================================
   Ficha de detalle (cliente, etc.): grid de campos estilo tarjeta
   ========================================================= */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.1rem 1.5rem;
}

.detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--app-muted);
  margin-bottom: 0.2rem;
}

.detail-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--app-body-text);
}

.detail-value.text-muted {
  font-weight: 400;
}

/* =========================================================
   Cabecera de ficha (cliente, etc.): icono + nombre + acciones
   ========================================================= */
.entity-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background-color: #e0edf8;
  color: #295171;
  flex-shrink: 0;
}

.entity-avatar .icon-svg {
  width: 20px;
  height: 20px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--app-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  color: var(--app-primary);
}

.back-link .icon-svg {
  width: 12px;
  height: 12px;
}
