:root {
  --verde: #3f6b3f;
  --verde-oscuro: #2c4d2c;
  --fondo: #f5f7f4;
  --borde: #e1e5de;
}

body {
  background: var(--fondo);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #24291f;
}

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

.sidebar {
  width: 240px;
  background: var(--verde-oscuro);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width 0.18s ease, padding 0.18s ease;
}

.app-shell.sidebar-hidden .sidebar {
  width: 0;
  padding: 0;
  overflow: hidden;
  border: none;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0 0.6rem 1rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 0.5rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand:hover {
  color: #fff;
}

.sidebar-collapse-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 0.95rem;
  padding: 0.3rem 0.45rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.show-sidebar-btn {
  display: none;
  background: none;
  border: 1px solid var(--borde);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  color: var(--verde-oscuro);
  cursor: pointer;
  margin-right: 0.9rem;
}

.show-sidebar-btn:hover {
  background: var(--fondo);
}

.app-shell.sidebar-hidden .show-sidebar-btn {
  display: inline-flex;
  align-items: center;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sidebar-toggle:hover {
  color: #fff;
}

.sidebar-chevron {
  font-size: 0.68rem;
  opacity: 0.7;
  margin-right: 1.1rem;
  transition: transform 0.15s;
  flex-shrink: 0;
}

.sidebar-group.collapsed > .sidebar-toggle .sidebar-chevron {
  transform: rotate(-90deg);
}

.sidebar-group.collapsed > .sidebar-group-body {
  display: none;
}

.marca-icon {
  width: 34px;
  height: auto;
  flex-shrink: 0;
}

.sidebar-section {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
  padding: 0.9rem 1.2rem 0.3rem 1.2rem;
  margin: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1.2rem;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.97rem;
  transition: background 0.15s;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.sidebar-link.active {
  background: var(--verde);
  color: #fff;
  font-weight: 600;
}

.sidebar-link.disabled {
  opacity: 0.35;
  cursor: default;
}

.sidebar-subsection {
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.7;
  padding: 0.5rem 1.2rem 0.15rem 1.7rem;
  margin: 0;
}

.sidebar-subsection-sub {
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 0.65;
  padding: 0.45rem 1.2rem 0.15rem 2.3rem;
  margin: 0;
}

.sidebar-link.sidebar-link-sub {
  padding-left: 2.3rem;
  font-size: 0.92rem;
}

.sidebar-link.sidebar-link-sub2 {
  padding-left: 2.9rem;
  font-size: 0.88rem;
}

.sidebar-link.sidebar-link-sub3 {
  padding-left: 3.5rem;
  font-size: 0.85rem;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: relative;
  background: #fff;
  border-bottom: 1px solid var(--borde);
  padding: 1.1rem 2rem;
}

.topbar h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
  color: var(--verde-oscuro);
}

.topbar-establecimiento {
  display: block;
  font-size: 0.8rem;
  color: #8a9086;
  margin-top: 0.15rem;
}

.topbar-usuario {
  position: absolute;
  top: 1.1rem;
  right: 2rem;
  font-size: 0.8rem;
  color: #8a9086;
}

.topbar-usuario a {
  color: var(--verde-oscuro);
  margin-left: 0.4rem;
}

.page-body {
  padding: 1.6rem 2rem;
  flex: 1;
}

.card-panel {
  background: #fff;
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 1.4rem;
  margin-bottom: 1.3rem;
}

.table thead th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #5a6155;
  border-bottom: 2px solid var(--borde);
  white-space: nowrap;
}

.th-orden-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.th-orden-link:hover {
  color: var(--verde-oscuro, #2c4d2c);
  text-decoration: underline;
}

.th-orden-link i {
  font-size: 0.7rem;
}

.table td {
  vertical-align: middle;
  font-size: 0.9rem;
}

.badge-inactivo {
  background: #ececec;
  color: #777;
}

.btn-verde {
  background: var(--verde);
  border-color: var(--verde);
  color: #fff;
}

.btn-verde:hover {
  background: var(--verde-oscuro);
  border-color: var(--verde-oscuro);
  color: #fff;
}

.filtros-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.filtros-bar .form-label {
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
  color: #5a6155;
}

.filtros-bar .form-select,
.filtros-bar .form-control {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  height: auto;
}

.dashboard-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  background: linear-gradient(135deg, var(--verde-oscuro), var(--verde));
  border: none;
  color: #fff;
}

.dashboard-hero-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.dashboard-hero-logo {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 8px;
}

svg.dashboard-hero-logo {
  color: var(--verde-oscuro);
}

.dashboard-hero-nombre {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
}

.dashboard-hero-sub {
  color: rgba(255, 255, 255, 0.85) !important;
  font-size: 0.85rem;
}

.dashboard-hero-buscar {
  flex: 1 1 260px;
  display: flex;
  justify-content: center;
}

.dashboard-hero-buscar-group {
  max-width: 340px;
  width: 100%;
}

.dashboard-hero-buscar-group .input-group-text {
  background: #fff;
  border: none;
  color: var(--verde-oscuro);
}

.dashboard-hero-buscar-group .form-control {
  border: none;
  font-size: 1.15rem;
  padding: 0.55rem 0.75rem;
}

.dashboard-hero-buscar-group .form-control:focus {
  box-shadow: none;
}

.dashboard-hero-stats {
  display: flex;
  gap: 1.6rem;
  flex-wrap: wrap;
}

.dashboard-stat {
  text-align: center;
  min-width: 70px;
}

.dashboard-stat-valor {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
}

.dashboard-stat-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content, .page-body { padding: 0 !important; }
  .card-panel { border: 1px solid #ccc !important; break-inside: avoid; }

  /* Impresión acotada: al imprimir sólo una sección (ej. historial sanitario
     de un animal), body lleva la clase "imprimir-sanidad" y se ocultan los
     elementos marcados con "no-print-sanidad" además del sidebar/topbar. */
  body.imprimir-sanidad .no-print-sanidad { display: none !important; }
}
